hedgewars/uAI.pas
changeset 5600 c6da15eddab3
parent 5396 4a0a8f32b7e3
child 5611 099868c5bba5
child 6317 83b93a2d2741
equal deleted inserted replaced
5598:265429f7ba85 5600:c6da15eddab3
   169          Actions:= MadeActions;
   169          Actions:= MadeActions;
   170          Me:= Hedgehog
   170          Me:= Hedgehog
   171          end
   171          end
   172     end;
   172     end;
   173 
   173 
   174     function PosInThinkStack(Me: PGear): boolean;
       
   175     var i: Longword;
       
   176     begin
       
   177     i:= 0;
       
   178     while (i < Stack.Count) do
       
   179           begin
       
   180           if(not(hwAbs(Stack.States[i].Hedgehog.X - Me^.X) +
       
   181                  hwAbs(Stack.States[i].Hedgehog.Y - Me^.Y) > _2)) and
       
   182               (Stack.States[i].Hedgehog.Message = Me^.Message) then exit(true);
       
   183           inc(i)
       
   184           end;
       
   185     PosInThinkStack:= false
       
   186     end;
       
   187 
       
   188 
       
   189 var Actions: TActions;
   174 var Actions: TActions;
   190     ticks, maxticks, steps, tmp: Longword;
   175     ticks, maxticks, steps, tmp: Longword;
   191     BaseRate, BestRate, Rate: integer;
   176     BaseRate, BestRate, Rate: integer;
   192     GoInfo: TGoInfo;
   177     GoInfo: TGoInfo;
   193     CanGo: boolean;
   178     CanGo: boolean;
   222     AddAction(Actions, Me^.Message, aim_push, 250, 0, 0);
   207     AddAction(Actions, Me^.Message, aim_push, 250, 0, 0);
   223     if (Me^.Message and gmLeft) <> 0 then AddAction(Actions, aia_WaitXL, hwRound(Me^.X), 0, 0, 0)
   208     if (Me^.Message and gmLeft) <> 0 then AddAction(Actions, aia_WaitXL, hwRound(Me^.X), 0, 0, 0)
   224                                       else AddAction(Actions, aia_WaitXR, hwRound(Me^.X), 0, 0, 0);
   209                                       else AddAction(Actions, aia_WaitXR, hwRound(Me^.X), 0, 0, 0);
   225     steps:= 0;
   210     steps:= 0;
   226 
   211 
   227     while (not StopThinking) and (not PosInThinkStack(Me)) do
   212     while (not StopThinking) do
   228        begin
   213        begin
   229 {$HINTS OFF}
   214 {$HINTS OFF}
   230        CanGo:= HHGo(Me, @AltMe, GoInfo);
   215        CanGo:= HHGo(Me, @AltMe, GoInfo);
   231 {$HINTS ON}
   216 {$HINTS ON}
   232        inc(ticks, GoInfo.Ticks);
   217        inc(ticks, GoInfo.Ticks);