--- a/hedgewars/GSHandlers.inc Mon Sep 11 18:27:49 2006 +0000
+++ b/hedgewars/GSHandlers.inc Mon Sep 11 21:44:38 2006 +0000
@@ -742,6 +742,7 @@
team: PTeam;
end;
thexchcnt: Longword;
+ currsorter: PGear;
procedure doStepTeamHealthSorterWork(Gear: PGear);
var i: integer;
@@ -754,8 +755,11 @@
{$WARNINGS OFF}
team.DrawHealthY:= ny + (oy - ny) * Gear.Timer div 640;
{$WARNINGS ON}
-if Gear.Timer = 0 then
+if (Gear.Timer = 0) or (currsorter <> Gear) then
+ begin
+ if currsorter = Gear then currsorter:= nil;
DeleteGear(Gear)
+ end
end;
procedure doStepTeamHealthSorter(Gear: PGear);
@@ -789,7 +793,8 @@
ny:= t
end;
Gear.Timer:= 640;
-Gear.doStep:= doStepTeamHealthSorterWork
+Gear.doStep:= doStepTeamHealthSorterWork;
+currsorter:= Gear
end;
////////////////////////////////////////////////////////////////////////////////
--- a/hedgewars/uAI.pas Mon Sep 11 18:27:49 2006 +0000
+++ b/hedgewars/uAI.pas Mon Sep 11 21:44:38 2006 +0000
@@ -246,6 +246,7 @@
begin
Walk(@WalkMe);
if (StartTicks > GameTicks - 1500) and not StopThinking then SDL_Delay(2000);
+ if BestActions.Score = BadTurn then AddAction(BestActions, aia_Skip, 0, 250);
end else
else begin
Walk(@WalkMe);
@@ -282,14 +283,19 @@
end;
procedure ProcessBot;
+const StartTicks: Longword = 0;
begin
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
if (Gear <> nil)
and ((Gear.State and gstHHDriven) <> 0)
- and (TurnTimeLeft < cHedgehogTurnTime - 5)
- and ((Gear.State and gstHHThinking) = 0) then
- if (BestActions.Pos >= BestActions.Count) then StartThink(Gear)
- else ProcessAction(BestActions, Gear)
+ and (TurnTimeLeft < cHedgehogTurnTime - 5) then
+ if ((Gear.State and gstHHThinking) = 0) then
+ if (BestActions.Pos >= BestActions.Count) then
+ begin
+ StartThink(Gear);
+ StartTicks:= GameTicks
+ end else ProcessAction(BestActions, Gear)
+ else if (GameTicks - StartTicks) > cMaxAIThinkTime then StopThinking:= true
end;
end.
--- a/hedgewars/uAIActions.pas Mon Sep 11 18:27:49 2006 +0000
+++ b/hedgewars/uAIActions.pas Mon Sep 11 21:44:38 2006 +0000
@@ -52,6 +52,7 @@
aia_AwareExpl = $80000005;
aia_HJump = $80000006;
aia_LJump = $80000007;
+ aia_Skip = $80000008;
aim_push = $80000000;
aim_release = $80000001;
@@ -161,6 +162,7 @@
aia_AwareExpl: AwareOfExplosion(X, Y, Param);
aia_HJump: ParseCommand('hjump');
aia_LJump: ParseCommand('ljump');
+ aia_Skip: ParseCommand('skip');
end else
begin
s:= ActionIdToStr[Action];
--- a/hedgewars/uAIAmmoTests.pas Mon Sep 11 18:27:49 2006 +0000
+++ b/hedgewars/uAIAmmoTests.pas Mon Sep 11 21:44:38 2006 +0000
@@ -56,13 +56,14 @@
{amMine} nil,
{amDEagle} TestDesertEagle,
{amDynamite} nil,
-{amBaseballBat} TestBaseballBat,
-{amFirePunch} TestFirePunch
+{amFirePunch} TestFirePunch,
+{amBaseballBat} TestBaseballBat
);
+const BadTurn = Low(integer);
+
implementation
uses uMisc, uAIMisc, uLand;
-const BadTurn = Low(integer);
function Metric(x1, y1, x2, y2: integer): integer;
begin
@@ -117,7 +118,7 @@
ExplR:= 100;
ExplX:= EX;
ExplY:= EY;
- Result:= Score - random((Level - 1) * 2500)
+ Result:= Score
end;
end
until (rTime >= 4500)
@@ -197,8 +198,9 @@
y:= y + vY;
if TestColl(round(x), round(y), 2) then
begin
- Result:= RateShove(Me, round(x), round(y), 25, 25) * 2 - Level * 4000;
- if Result = 0 then Result:= - Metric(Targ.X, Targ.Y, round(x), round(y)) div 64;
+ Result:= RateShove(Me, round(x), round(y), 25, 25) * 2;
+ if Result = 0 then Result:= - Metric(Targ.X, Targ.Y, round(x), round(y)) div 64
+ else dec(Result, Level * 4000);
exit
end
until (abs(Targ.X - x) + abs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024);
@@ -237,7 +239,7 @@
function TestBaseballBat(Me: PGear; Targ: TPoint; Level: Integer; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
begin
ExplR:= 0;
-if (Level < 2) and (abs(Me.X - Targ.X) + abs(Me.Y - Targ.Y) >= 25) then
+if (Level > 2) and (abs(Me.X - Targ.X) + abs(Me.Y - Targ.Y) >= 25) then
begin
Result:= BadTurn;
exit
@@ -245,7 +247,8 @@
Time:= 0;
Power:= 1;
Angle:= DxDy2AttackAngle(hwSign(Targ.X - Me.X), 1);
-Result:= RateShove(Me, round(Me.X) + 10 * hwSign(Targ.X - Me.X), round(Me.Y), 15, 30)
+Result:= RateShove(Me, round(Me.X) + 10 * hwSign(Targ.X - Me.X), round(Me.Y), 15, 30);
+if Result <= 0 then Result:= BadTurn
end;
function TestFirePunch(Me: PGear; Targ: TPoint; Level: Integer; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
@@ -262,7 +265,8 @@
Angle:= DxDy2AttackAngle(hwSign(Targ.X - Me.X), 1);
Result:= 0;
for i:= 0 to 4 do
- Result:= Result + RateShove(Me, round(Me.X) + 10 * hwSign(Targ.X - Me.X), round(Me.Y) - 20 * i - 5, 10, 30)
+ Result:= Result + RateShove(Me, round(Me.X) + 10 * hwSign(Targ.X - Me.X), round(Me.Y) - 20 * i - 5, 10, 30);
+if Result <= 0 then Result:= BadTurn
end;
end.
--- a/hedgewars/uGame.pas Mon Sep 11 18:27:49 2006 +0000
+++ b/hedgewars/uGame.pas Mon Sep 11 21:44:38 2006 +0000
@@ -59,7 +59,7 @@
inc(SendEmptyPacketTicks, Lag);
if SendEmptyPacketTicks >= cSendEmptyPacketTime then
begin
- SendIPC('N');
+ SendIPC('+');
SendEmptyPacketTicks:= 0
end
end;
--- a/hedgewars/uMisc.pas Mon Sep 11 18:27:49 2006 +0000
+++ b/hedgewars/uMisc.pas Mon Sep 11 21:44:38 2006 +0000
@@ -47,6 +47,7 @@
GameFlags : Longword = 0;
TurnTimeLeft : Longword = 0;
cHedgehogTurnTime: Longword = 45000;
+ cMaxAIThinkTime : Longword = 5000;
cCloudsNumber : integer = 9;
cConsoleHeight : integer = 320;