- Fix 'new team' regression
authorunc0rr
Wed, 13 Sep 2006 19:26:16 +0000
changeset 144 e6084b0c9316
parent 143 3dacbd83209b
child 145 e593d5266e01
- Fix 'new team' regression - Some improvements to AI
QTfrontend/hwform.cpp
hedgewars/uAI.pas
hedgewars/uAIActions.pas
--- a/QTfrontend/hwform.cpp	Mon Sep 11 21:44:38 2006 +0000
+++ b/QTfrontend/hwform.cpp	Wed Sep 13 19:26:16 2006 +0000
@@ -153,7 +153,7 @@
 void HWForm::NewTeam()
 {
 	tmpTeam = new HWTeam("unnamed");
-
+	tmpTeam->SetToPage(this);
 	ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM);
 }
 
--- a/hedgewars/uAI.pas	Mon Sep 11 21:44:38 2006 +0000
+++ b/hedgewars/uAI.pas	Wed Sep 13 19:26:16 2006 +0000
@@ -164,7 +164,7 @@
 
 
 var Actions: TActions;
-    ticks, maxticks, steps, BotLevel: Longword;
+    ticks, maxticks, steps, BotLevel, tmp: Longword;
     BaseRate, BestRate, Rate: integer;
     GoInfo: TGoInfo;
     CanGo: boolean;
@@ -176,8 +176,9 @@
 Stack.Count:= 0;
 BotLevel:= PHedgehog(Me.Hedgehog).BotLevel;
 
-Push(0, Actions, Me^, aia_Left);
-Push(0, Actions, Me^, aia_Right);
+tmp:= random(2) + 1;
+Push(0, Actions, Me^, tmp);
+Push(0, Actions, Me^, tmp xor 3);
 
 if (Me.State and gstAttacked) = 0 then maxticks:= max(0, TurnTimeLeft - 5000 - 4000 * BotLevel)
                                   else maxticks:= TurnTimeLeft;
@@ -189,6 +190,7 @@
 while (Stack.Count > 0) and not StopThinking do
     begin
     Pop(ticks, Actions, Me^);
+
     AddAction(Actions, Me.Message, aim_push, 250);
     AddAction(Actions, aia_WaitX, round(Me.X), 0);
     AddAction(Actions, Me.Message, aim_release, 0);
@@ -199,6 +201,7 @@
        CanGo:= HHGo(Me, @AltMe, GoInfo);
        inc(ticks, GoInfo.Ticks);
        if ticks > maxticks then break;
+       
        if (BotLevel < 5) and (GoInfo.JumpType = jmpHJump) then // hjump support
           if Push(ticks, Actions, AltMe, Me^.Message) then
              with Stack.States[Pred(Stack.Count)] do
@@ -210,6 +213,7 @@
           if Push(ticks, Actions, AltMe, Me^.Message) then
              with Stack.States[Pred(Stack.Count)] do
                   AddAction(MadeActions, aia_LJump, 0, 305);
+
        if not CanGo then break;
        inc(steps);
        Actions.actions[Actions.Count - 2].Param:= round(Me.X);
@@ -267,6 +271,7 @@
 begin
 if ((Me.State and gstAttacking) <> 0) or isInMultiShoot then exit;
 Me.State:= Me.State or gstHHThinking;
+Me.Message:= 0;
 StopThinking:= false;
 ThinkingHH:= Me;
 FillTargets;
@@ -288,7 +293,7 @@
 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
      if (Gear <> nil)
         and ((Gear.State and gstHHDriven) <> 0)
-        and (TurnTimeLeft < cHedgehogTurnTime - 5) then
+        and (TurnTimeLeft < cHedgehogTurnTime - 50) then
         if ((Gear.State and gstHHThinking) = 0) then
            if (BestActions.Pos >= BestActions.Count) then
               begin
--- a/hedgewars/uAIActions.pas	Mon Sep 11 21:44:38 2006 +0000
+++ b/hedgewars/uAIActions.pas	Wed Sep 13 19:26:16 2006 +0000
@@ -86,7 +86,7 @@
                      );
 
 {$IFDEF TRACEAIACTIONS}
-const SpecActionIdToStr: array[$80000000..$80000006] of string[16] = (
+const SpecActionIdToStr: array[$80000000..$80000008] of string[16] = (
 {aia_Weapon}             'aia_Weapon',
 {aia_WaitX}              'aia_WaitX',
 {aia_WaitY}              'aia_WaitY',
@@ -94,7 +94,8 @@
 {aia_LookRight}          'aia_LookRight',
 {aia_AwareExpl}          'aia_AwareExpl',
 {aia_HJump}              'aia_HJump',
-{aia_LJump}              'aia_LJump'
+{aia_LJump}              'aia_LJump',
+{aia_Skip}               'aia_Skip'
 );
 
 procedure DumpAction(Action: TAction; Me: PGear);