hedgewars/uAI2.pas
branchtransitional_engine
changeset 16068 a236360669cc
child 16069 6c5b3c576fc6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hedgewars/uAI2.pas	Sun Oct 27 17:00:17 2024 +0100
@@ -0,0 +1,50 @@
+unit uAI2;
+
+interface
+
+procedure ProcessBot;
+procedure initModule;
+
+implementation
+uses uLandUtils, uFloat, uVariables, uTypes;
+
+{$linklib hwengine_future}
+
+function create_ai(game_field: pointer): pointer; cdecl; external;
+procedure ai_clear_team(ai: pointer); cdecl; external;
+procedure ai_add_team_hedgehog(ai: pointer; x, y: real); cdecl; external;
+procedure ai_think(ai: pointer); cdecl; external;
+procedure dispose_ai(ai: pointer); cdecl; external;
+
+var ai: pointer;
+
+procedure ProcessBot;
+var currHedgehogIndex, itHedgehog: Longword;
+begin
+    if ai = nil then
+    begin
+        ai:= create_ai(gameField)
+    end;
+    
+    ai_clear_team(ai);
+    
+    currHedgehogIndex:= CurrentTeam^.CurrHedgehog;
+    itHedgehog:= currHedgehogIndex;
+    repeat
+        with CurrentTeam^.Hedgehogs[itHedgehog] do
+            if (Gear <> nil) and (Effects[heFrozen] = 0) then
+            begin
+                ai_add_team_hedgehog(ai, hwFloat2float(Gear^.X), hwFloat2float(Gear^.Y))
+            end;
+        itHedgehog:= Succ(itHedgehog) mod CurrentTeam^.HedgehogsNumber;
+    until (itHedgehog = currHedgehogIndex);
+
+end;
+
+procedure initModule;
+begin
+    ai:= nil
+end;
+
+end.
+