author | unc0rr |
Fri, 23 Jun 2006 20:02:41 +0000 | |
changeset 70 | 82d93eeecebe |
parent 66 | 9643d75baf1e |
child 71 | 5f56c6979496 |
permissions | -rw-r--r-- |
4 | 1 |
unit uAIMisc; |
2 |
interface |
|
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
3 |
uses SDLh, uConsts, uGears; |
4 | 4 |
|
64 | 5 |
type TTarget = record |
6 |
Point: TPoint; |
|
7 |
Score: integer; |
|
8 |
end; |
|
9 |
TTargets = record |
|
10 |
Count: Longword; |
|
11 |
ar: array[0..cMaxHHIndex*5] of TTarget; |
|
4 | 12 |
end; |
64 | 13 |
|
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
14 |
procedure FillTargets; |
70 | 15 |
procedure FillBonuses(isAfterAttack: boolean); |
16 |
function RatePlace(Gear: PGear): integer; |
|
64 | 17 |
function DxDy2AttackAngle(const _dY, _dX: Extended): integer; |
4 | 18 |
function TestColl(x, y, r: integer): boolean; |
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
19 |
function RateExplosion(Me: PGear; x, y, r: integer): integer; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
20 |
function HHGo(Gear: PGear): boolean; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
21 |
|
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
22 |
var ThinkingHH: PGear; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
23 |
Targets: TTargets; |
4 | 24 |
|
25 |
implementation |
|
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
26 |
uses uTeams, uMisc, uLand, uCollisions; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
27 |
const KillScore = 200; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
28 |
MAXBONUS = 1024; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
29 |
|
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
30 |
type TBonus = record |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
31 |
X, Y: integer; |
70 | 32 |
Radius: integer; |
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
33 |
Score: integer; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
34 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
35 |
var bonuses: record |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
36 |
Count: Longword; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
37 |
ar: array[0..Pred(MAXBONUS)] of TBonus; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
38 |
end; |
4 | 39 |
|
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
40 |
procedure FillTargets; |
4 | 41 |
var t: PTeam; |
64 | 42 |
i: Longword; |
4 | 43 |
begin |
44 |
Targets.Count:= 0; |
|
45 |
t:= TeamsList; |
|
46 |
while t <> nil do |
|
47 |
begin |
|
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
48 |
for i:= 0 to cMaxHHIndex do |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
49 |
if (t.Hedgehogs[i].Gear <> nil) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
50 |
and (t.Hedgehogs[i].Gear <> ThinkingHH) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
51 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
52 |
with Targets.ar[Targets.Count], t.Hedgehogs[i] do |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
53 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
54 |
Point.X:= Round(Gear.X); |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
55 |
Point.Y:= Round(Gear.Y); |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
56 |
if t <> CurrentTeam then Score:= Gear.Health |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
57 |
else Score:= -Gear.Health |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
58 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
59 |
inc(Targets.Count) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
60 |
end; |
4 | 61 |
t:= t.Next |
64 | 62 |
end |
4 | 63 |
end; |
64 |
||
70 | 65 |
procedure FillBonuses(isAfterAttack: boolean); |
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
66 |
var Gear: PGear; |
70 | 67 |
MyColor: Longword; |
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
68 |
|
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
69 |
procedure AddBonus(x, y: integer; r: Longword; s: integer); |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
70 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
71 |
bonuses.ar[bonuses.Count].x:= x; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
72 |
bonuses.ar[bonuses.Count].y:= y; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
73 |
bonuses.ar[bonuses.Count].Radius:= r; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
74 |
bonuses.ar[bonuses.Count].Score:= s; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
75 |
inc(bonuses.Count); |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
76 |
TryDo(bonuses.Count <= MAXBONUS, 'Bonuses overflow', true) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
77 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
78 |
|
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
79 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
80 |
bonuses.Count:= 0; |
70 | 81 |
MyColor:= PHedgehog(ThinkingHH.Hedgehog).Team.Color; |
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
82 |
Gear:= GearsList; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
83 |
while Gear <> nil do |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
84 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
85 |
case Gear.Kind of |
70 | 86 |
gtCase: AddBonus(round(Gear.X), round(Gear.Y), 33, 25); |
87 |
gtMine: AddBonus(round(Gear.X), round(Gear.Y), 46, -50); |
|
88 |
gtDynamite: AddBonus(round(Gear.X), round(Gear.Y), 150, -75); |
|
89 |
gtHedgehog: begin |
|
90 |
if Gear.Damage >= Gear.Health then AddBonus(round(Gear.X), round(Gear.Y), 50, -25); |
|
91 |
if isAfterAttack |
|
92 |
and (ThinkingHH.Hedgehog <> Gear.Hedgehog) |
|
93 |
and (MyColor = PHedgehog(Gear.Hedgehog).Team.Color) then AddBonus(round(Gear.X), round(Gear.Y), 100, -1); |
|
94 |
end; |
|
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
95 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
96 |
Gear:= Gear.NextGear |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
97 |
end |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
98 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
99 |
|
70 | 100 |
function RatePlace(Gear: PGear): integer; |
101 |
var i, r: integer; |
|
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
102 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
103 |
Result:= 0; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
104 |
for i:= 0 to Pred(bonuses.Count) do |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
105 |
with bonuses.ar[i] do |
70 | 106 |
begin |
107 |
r:= round(sqrt(sqr(Gear.X - X) + sqr(Gear.Y - y))); |
|
108 |
if r < Radius then |
|
109 |
inc(Result, Score * (Radius - r)) |
|
110 |
end; |
|
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
111 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
112 |
|
64 | 113 |
function DxDy2AttackAngle(const _dY, _dX: Extended): integer; |
4 | 114 |
const piDIVMaxAngle: Extended = pi/cMaxAngle; |
115 |
asm |
|
116 |
fld _dY |
|
117 |
fld _dX |
|
118 |
fpatan |
|
119 |
fld piDIVMaxAngle |
|
120 |
fdiv |
|
121 |
sub esp, 4 |
|
122 |
fistp dword ptr [esp] |
|
123 |
pop eax |
|
124 |
end; |
|
125 |
||
126 |
function TestColl(x, y, r: integer): boolean; |
|
127 |
begin |
|
128 |
Result:=(((x-r) and $FFFFF800) = 0)and(((y-r) and $FFFFFC00) = 0) and (Land[y-r, x-r] <> 0); |
|
129 |
if Result then exit; |
|
130 |
Result:=(((x-r) and $FFFFF800) = 0)and(((y+r) and $FFFFFC00) = 0) and (Land[y+r, x-r] <> 0); |
|
131 |
if Result then exit; |
|
132 |
Result:=(((x+r) and $FFFFF800) = 0)and(((y-r) and $FFFFFC00) = 0) and (Land[y-r, x+r] <> 0); |
|
133 |
if Result then exit; |
|
134 |
Result:=(((x+r) and $FFFFF800) = 0)and(((y+r) and $FFFFFC00) = 0) and (Land[y+r, x+r] <> 0); |
|
135 |
end; |
|
136 |
||
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
137 |
function RateExplosion(Me: PGear; x, y, r: integer): integer; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
138 |
var i, dmg: integer; |
4 | 139 |
begin |
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
140 |
Result:= 0; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
141 |
// add our virtual position |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
142 |
with Targets.ar[Targets.Count] do |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
143 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
144 |
Point.x:= round(Me.X); |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
145 |
Point.y:= round(Me.Y); |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
146 |
Score:= - ThinkingHH.Health |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
147 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
148 |
// rate explosion |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
149 |
for i:= 0 to Targets.Count do |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
150 |
with Targets.ar[i] do |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
151 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
152 |
dmg:= r - Round(sqrt(sqr(Point.x - x) + sqr(Point.y - y))); |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
153 |
if dmg > 0 then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
154 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
155 |
dmg:= dmg shr 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
156 |
if dmg > abs(Score) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
157 |
if Score > 0 then inc(Result, KillScore) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
158 |
else dec(Result, KillScore * 3) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
159 |
else |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
160 |
if Score > 0 then inc(Result, dmg) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
161 |
else dec(Result, dmg * 3) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
162 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
163 |
end; |
70 | 164 |
Result:= Result * 1024 |
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
165 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
166 |
|
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
167 |
function HHGo(Gear: PGear): boolean; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
168 |
var pX, pY: integer; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
169 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
170 |
Result:= false; |
4 | 171 |
repeat |
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
172 |
pX:= round(Gear.X); |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
173 |
pY:= round(Gear.Y); |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
174 |
if pY + cHHRadius >= cWaterLine then exit; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
175 |
if (Gear.State and gstFalling) <> 0 then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
176 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
177 |
Gear.dY:= Gear.dY + cGravity; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
178 |
if Gear.dY > 0.35 then exit; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
179 |
Gear.Y:= Gear.Y + Gear.dY; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
180 |
if TestCollisionYwithGear(Gear, 1) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
181 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
182 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
183 |
Gear.dY:= 0 |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
184 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
185 |
continue |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
186 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
187 |
{if ((Gear.Message and gm_LJump )<>0) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
188 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
189 |
Gear.Message:= 0; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
190 |
if not HHTestCollisionYwithGear(Gear, -1) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
191 |
if not TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
192 |
if not TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
193 |
if not (TestCollisionXwithGear(Gear, Sign(Gear.dX)) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
194 |
or HHTestCollisionYwithGear(Gear, -1)) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
195 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
196 |
Gear.dY:= -0.15; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
197 |
Gear.dX:= Sign(Gear.dX) * 0.15; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
198 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
199 |
exit |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
200 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
201 |
end;} |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
202 |
if (Gear.Message and gm_Left )<>0 then Gear.dX:= -1.0 else |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
203 |
if (Gear.Message and gm_Right )<>0 then Gear.dX:= 1.0 else exit; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
204 |
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
205 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
206 |
if not (TestCollisionXwithXYShift(Gear, 0, -6, Sign(Gear.dX)) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
207 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
208 |
if not (TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX)) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
209 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
210 |
if not (TestCollisionXwithXYShift(Gear, 0, -4, Sign(Gear.dX)) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
211 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
212 |
if not (TestCollisionXwithXYShift(Gear, 0, -3, Sign(Gear.dX)) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
213 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
214 |
if not (TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
215 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
216 |
if not (TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
217 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
218 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
219 |
|
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
220 |
if not TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.X:= Gear.X + Gear.dX; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
221 |
if not TestCollisionYwithGear(Gear, 1) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
222 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
223 |
Gear.Y:= Gear.Y + 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
224 |
if not TestCollisionYwithGear(Gear, 1) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
225 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
226 |
Gear.Y:= Gear.Y + 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
227 |
if not TestCollisionYwithGear(Gear, 1) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
228 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
229 |
Gear.Y:= Gear.Y + 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
230 |
if not TestCollisionYwithGear(Gear, 1) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
231 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
232 |
Gear.Y:= Gear.Y + 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
233 |
if not TestCollisionYwithGear(Gear, 1) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
234 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
235 |
Gear.Y:= Gear.Y + 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
236 |
if not TestCollisionYwithGear(Gear, 1) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
237 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
238 |
Gear.Y:= Gear.Y + 1; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
239 |
if not TestCollisionYwithGear(Gear, 1) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
240 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
241 |
Gear.Y:= Gear.Y - 6; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
242 |
Gear.dY:= 0; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
243 |
Gear.dX:= 0.0000001 * Sign(Gear.dX); |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
244 |
Gear.State:= Gear.State or gstFalling |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
245 |
end |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
246 |
end |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
247 |
end |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
248 |
end |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
249 |
end |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
250 |
end |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
251 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
252 |
if (pX <> round(Gear.X))and ((Gear.State and gstFalling) = 0) then |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
253 |
begin |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
254 |
Result:= true; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
255 |
exit |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
256 |
end; |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
257 |
until (pX = round(Gear.X)) and (pY = round(Gear.Y)) and ((Gear.State and gstFalling) = 0); |
4 | 258 |
end; |
259 |
||
260 |
end. |