141 Actions:= MadeActions; |
141 Actions:= MadeActions; |
142 Me:= Hedgehog |
142 Me:= Hedgehog |
143 end |
143 end |
144 end; |
144 end; |
145 |
145 |
|
146 function PosInThinkStack(Me: PGear): boolean; |
|
147 var i: Longword; |
|
148 begin |
|
149 i:= 0; |
|
150 Result:= false; |
|
151 while (i < Stack.Count) and not Result do |
|
152 begin |
|
153 Result:= abs(Stack.States[i].Hedgehog.X - Me.X) + |
|
154 abs(Stack.States[i].Hedgehog.Y - Me.Y) <= 2; |
|
155 inc(i) |
|
156 end |
|
157 end; |
|
158 |
146 |
159 |
147 var Actions: TActions; |
160 var Actions: TActions; |
148 ticks, maxticks, steps: Longword; |
161 ticks, maxticks, steps: Longword; |
149 BaseRate, BestRate, Rate: integer; |
162 BaseRate, BestRate, Rate: integer; |
150 GoInfo: TGoInfo; |
163 GoInfo: TGoInfo; |
171 Pop(ticks, Actions, Me^); |
184 Pop(ticks, Actions, Me^); |
172 AddAction(Actions, Me.Message, aim_push, 250); |
185 AddAction(Actions, Me.Message, aim_push, 250); |
173 AddAction(Actions, aia_WaitX, round(Me.X), 0); |
186 AddAction(Actions, aia_WaitX, round(Me.X), 0); |
174 AddAction(Actions, Me.Message, aim_release, 0); |
187 AddAction(Actions, Me.Message, aim_release, 0); |
175 steps:= 0; |
188 steps:= 0; |
176 |
189 |
177 while true do |
190 while (not StopThinking) and (not PosInThinkStack(Me)) do |
178 begin |
191 begin |
179 CanGo:= HHGo(Me, @AltMe, GoInfo); |
192 CanGo:= HHGo(Me, @AltMe, GoInfo); |
180 inc(ticks, GoInfo.Ticks); |
193 inc(ticks, GoInfo.Ticks); |
181 if ticks > maxticks then break; |
194 if ticks > maxticks then break; |
182 if GoInfo.JumpType = jmpHJump then // hjump support |
195 if GoInfo.JumpType = jmpHJump then // hjump support |
203 else if Rate < BestRate then break; |
216 else if Rate < BestRate then break; |
204 if ((Me.State and gstAttacked) = 0) |
217 if ((Me.State and gstAttacked) = 0) |
205 and ((steps mod 4) = 0) then TestAmmos(Actions, Me); |
218 and ((steps mod 4) = 0) then TestAmmos(Actions, Me); |
206 if GoInfo.FallPix >= FallPixForBranching then |
219 if GoInfo.FallPix >= FallPixForBranching then |
207 Push(ticks, Actions, Me^, Me^.Message xor 3); // aia_Left xor 3 = aia_Right |
220 Push(ticks, Actions, Me^, Me^.Message xor 3); // aia_Left xor 3 = aia_Right |
208 if StopThinking then exit |
|
209 end; |
221 end; |
210 |
222 |
211 if BestRate > BaseRate then exit |
223 if BestRate > BaseRate then exit |
212 end |
224 end |
213 end; |
225 end; |