hedgewars/uAIAmmoTests.pas
changeset 7550 3c4b4cb40f40
parent 7501 1763dc3bc9b7
child 7620 fa3bc79dc0b8
equal deleted inserted replaced
7508:763d3961400b 7550:3c4b4cb40f40
    45 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    45 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    46 function TestSniperRifle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    46 function TestSniperRifle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    47 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    47 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    48 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    48 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    49 function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    49 function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
       
    50 function TestKamikaze(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    50 function TestAirAttack(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    51 function TestAirAttack(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    51 function TestTeleport(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    52 function TestTeleport(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    52 function TestHammer(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    53 function TestHammer(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    53 function TestCake(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    54 function TestCake(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    54 
    55 
    82             (proc: nil;              flags: 0), // amGirder
    83             (proc: nil;              flags: 0), // amGirder
    83             (proc: nil;              flags: 0), // amTeleport
    84             (proc: nil;              flags: 0), // amTeleport
    84             //(proc: @TestTeleport;    flags: amtest_OnTurn), // amTeleport
    85             //(proc: @TestTeleport;    flags: amtest_OnTurn), // amTeleport
    85             (proc: nil;              flags: 0), // amSwitch
    86             (proc: nil;              flags: 0), // amSwitch
    86             (proc: @TestMortar;      flags: 0), // amMortar
    87             (proc: @TestMortar;      flags: 0), // amMortar
    87             (proc: nil;              flags: 0), // amKamikaze
    88             (proc: @TestKamikaze;    flags: 0), // amKamikaze
    88             (proc: @TestCake;        flags: amtest_OnTurn or amtest_NoTarget), // amCake
    89             (proc: @TestCake;        flags: amtest_OnTurn or amtest_NoTarget), // amCake
    89             (proc: nil;              flags: 0), // amSeduction
    90             (proc: nil;              flags: 0), // amSeduction
    90             (proc: @TestWatermelon;  flags: 0), // amWatermelon
    91             (proc: @TestWatermelon;  flags: 0), // amWatermelon
    91             (proc: nil;              flags: 0), // amHellishBomb
    92             (proc: nil;              flags: 0), // amHellishBomb
    92             (proc: nil;              flags: 0), // amNapalm
    93             (proc: nil;              flags: 0), // amNapalm
   165         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   166         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   166                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t <= 0);
   167                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t <= 0);
   167         
   168         
   168         EX:= trunc(x);
   169         EX:= trunc(x);
   169         EY:= trunc(y);
   170         EY:= trunc(y);
   170         if Me^.Hedgehog^.BotLevel = 1 then
   171         if Level = 1 then
   171             value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   172             value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   172         else value:= RateExplosion(Me, EX, EY, 101);
   173         else value:= RateExplosion(Me, EX, EY, 101);
   173         if value = 0 then
   174         if value = 0 then
   174             value:= - Metric(Targ.X, Targ.Y, EX, EY) div 64;
   175             value:= - Metric(Targ.X, Targ.Y, EX, EY) div 64;
   175         if valueResult <= value then
   176         if valueResult <= value then
   328         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   329         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   329                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t = 0);
   330                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t = 0);
   330     EX:= trunc(x);
   331     EX:= trunc(x);
   331     EY:= trunc(y);
   332     EY:= trunc(y);
   332     if t < 50 then 
   333     if t < 50 then 
   333         if Me^.Hedgehog^.BotLevel = 1 then
   334         if Level = 1 then
   334             Score:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   335             Score:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   335         else Score:= RateExplosion(Me, EX, EY, 101)
   336         else Score:= RateExplosion(Me, EX, EY, 101)
   336     else 
   337     else 
   337         Score:= BadTurn;
   338         Score:= BadTurn;
   338 
   339 
   359     TestTime: Longword;
   360     TestTime: Longword;
   360     x, y, dY, meX, meY: real;
   361     x, y, dY, meX, meY: real;
   361     t: LongInt;
   362     t: LongInt;
   362 begin
   363 begin
   363 valueResult:= BadTurn;
   364 valueResult:= BadTurn;
   364 TestTime:= 0;
   365 TestTime:= 500;
   365 ap.ExplR:= 0;
   366 ap.ExplR:= 0;
   366 meX:= hwFloat2Float(Me^.X);
   367 meX:= hwFloat2Float(Me^.X);
   367 meY:= hwFloat2Float(Me^.Y);
   368 meY:= hwFloat2Float(Me^.Y);
   368 repeat
   369 repeat
   369     inc(TestTime, 1000);
   370     inc(TestTime, 900);
   370     // Try to overshoot slightly, seems to pay slightly better dividends in terms of hitting cluster
   371     // Try to overshoot slightly, seems to pay slightly better dividends in terms of hitting cluster
   371     if meX<Targ.X then
   372     if meX<Targ.X then
   372         Vx:= ((Targ.X+10) - meX) / (TestTime + tDelta)
   373         Vx:= ((Targ.X+10) - meX) / (TestTime + tDelta)
   373     else
   374     else
   374         Vx:= ((Targ.X-10) - meX) / (TestTime + tDelta);
   375         Vx:= ((Targ.X-10) - meX) / (TestTime + tDelta);
   396 
   397 
   397      if valueResult < Score then
   398      if valueResult < Score then
   398         begin
   399         begin
   399         ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level));
   400         ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level));
   400         ap.Power:= trunc(sqrt(r) * cMaxPower) + AIrndSign(random(Level) * 15);
   401         ap.Power:= trunc(sqrt(r) * cMaxPower) + AIrndSign(random(Level) * 15);
   401         ap.Time:= TestTime;
   402         ap.Time:= TestTime div 1000 * 1000;
   402         ap.ExplR:= 90;
   403         ap.ExplR:= 90;
   403         ap.ExplX:= EX;
   404         ap.ExplX:= EX;
   404         ap.ExplY:= EY;
   405         ap.ExplY:= EY;
   405         valueResult:= Score
   406         valueResult:= Score
   406         end;
   407         end;
   407      end
   408      end
   408 until (TestTime = 4000);
   409 until (TestTime = 4100);
   409 TestClusterBomb:= valueResult
   410 TestClusterBomb:= valueResult
   410 end;
   411 end;
   411 
   412 
   412 function TestWatermelon(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   413 function TestWatermelon(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   413 const tDelta = 24;
   414 const tDelta = 24;
   416     TestTime: Longword;
   417     TestTime: Longword;
   417     x, y, dY, meX, meY: real;
   418     x, y, dY, meX, meY: real;
   418     t: LongInt;
   419     t: LongInt;
   419 begin
   420 begin
   420 valueResult:= BadTurn;
   421 valueResult:= BadTurn;
   421 TestTime:= 0;
   422 TestTime:= 500;
   422 ap.ExplR:= 0;
   423 ap.ExplR:= 0;
   423 meX:= hwFloat2Float(Me^.X);
   424 meX:= hwFloat2Float(Me^.X);
   424 meY:= hwFloat2Float(Me^.Y);
   425 meY:= hwFloat2Float(Me^.Y);
   425 repeat
   426 repeat
   426     inc(TestTime, 1000);
   427     inc(TestTime, 900);
   427     Vx:= (Targ.X - meX) / (TestTime + tDelta);
   428     Vx:= (Targ.X - meX) / (TestTime + tDelta);
   428     Vy:= cGravityf * ((TestTime + tDelta) div 2) - ((Targ.Y-50) - meY) / (TestTime + tDelta);
   429     Vy:= cGravityf * ((TestTime + tDelta) div 2) - ((Targ.Y-50) - meY) / (TestTime + tDelta);
   429     r:= sqr(Vx)+sqr(Vy);
   430     r:= sqr(Vx)+sqr(Vy);
   430     if not (r > 1) then
   431     if not (r > 1) then
   431         begin
   432         begin
   450             
   451             
   451         if valueResult < Score then
   452         if valueResult < Score then
   452             begin
   453             begin
   453             ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level));
   454             ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level));
   454             ap.Power:= trunc(sqrt(r) * cMaxPower) + AIrndSign(random(Level) * 15);
   455             ap.Power:= trunc(sqrt(r) * cMaxPower) + AIrndSign(random(Level) * 15);
   455             ap.Time:= TestTime;
   456             ap.Time:= TestTime div 1000 * 1000;
   456             ap.ExplR:= 300;
   457             ap.ExplR:= 300;
   457             ap.ExplX:= EX;
   458             ap.ExplX:= EX;
   458             ap.ExplY:= EY;
   459             ap.ExplY:= EY;
   459             valueResult:= Score
   460             valueResult:= Score
   460             end;
   461             end;
   461         end
   462         end
   462 until (TestTime = 4000);
   463 until (TestTime = 4100);
   463 TestWatermelon:= valueResult
   464 TestWatermelon:= valueResult
   464 end;
   465 end;
   465 
   466 
   466 
   467 
   467     function Solve(TX, TY, MX, MY: LongInt): LongWord;
   468     function Solve(TX, TY, MX, MY: LongInt): LongWord;
   598 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   599 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   599 var Vx, Vy, x, y, t, dmgMod: real;
   600 var Vx, Vy, x, y, t, dmgMod: real;
   600     d: Longword;
   601     d: Longword;
   601     fallDmg, valueResult: LongInt;
   602     fallDmg, valueResult: LongInt;
   602 begin
   603 begin
   603 if Me^.Hedgehog^.BotLevel > 3 then exit(BadTurn);
   604 if Level > 3 then exit(BadTurn);
   604 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent;
   605 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent;
   605 Level:= Level; // avoid compiler hint
   606 Level:= Level; // avoid compiler hint
   606 ap.ExplR:= 0;
   607 ap.ExplR:= 0;
   607 ap.Time:= 0;
   608 ap.Time:= 0;
   608 ap.Power:= 1;
   609 ap.Power:= 1;
       
   610 
   609 x:= hwFloat2Float(Me^.X);
   611 x:= hwFloat2Float(Me^.X);
   610 y:= hwFloat2Float(Me^.Y);
   612 y:= hwFloat2Float(Me^.Y);
       
   613 
   611 if Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) < 40 then
   614 if Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) < 40 then
   612     begin
   615     begin
   613     TestDesertEagle:= BadTurn;
   616     TestDesertEagle:= BadTurn;
   614     exit(BadTurn);
   617     exit(BadTurn);
   615     end;
   618     end;
       
   619 
   616 t:= 2 / sqrt(sqr(Targ.X - x)+sqr(Targ.Y-y));
   620 t:= 2 / sqrt(sqr(Targ.X - x)+sqr(Targ.Y-y));
   617 Vx:= (Targ.X - x) * t;
   621 Vx:= (Targ.X - x) * t;
   618 Vy:= (Targ.Y - y) * t;
   622 Vy:= (Targ.Y - y) * t;
   619 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
   623 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
   620 d:= 0;
   624 d:= 0;
   648 function TestSniperRifle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   652 function TestSniperRifle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   649 var Vx, Vy, x, y, t, dmg, dmgMod: real;
   653 var Vx, Vy, x, y, t, dmg, dmgMod: real;
   650     d: Longword;
   654     d: Longword;
   651     fallDmg, valueResult: LongInt;
   655     fallDmg, valueResult: LongInt;
   652 begin
   656 begin
   653 if Me^.Hedgehog^.BotLevel > 3 then exit(BadTurn);
   657 if Level > 3 then exit(BadTurn);
   654 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent;
   658 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent;
   655 Level:= Level; // avoid compiler hint
   659 Level:= Level; // avoid compiler hint
   656 ap.ExplR:= 0;
   660 ap.ExplR:= 0;
   657 ap.Time:= 0;
   661 ap.Time:= 0;
   658 ap.Power:= 1;
   662 ap.Power:= 1;
   698 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   702 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   699 var valueResult, a, v1, v2: LongInt;
   703 var valueResult, a, v1, v2: LongInt;
   700     x, y, trackFall: LongInt;
   704     x, y, trackFall: LongInt;
   701     dx, dy: real;
   705     dx, dy: real;
   702 begin
   706 begin
   703     if Me^.Hedgehog^.BotLevel < 3 then trackFall:= afTrackFall
   707     if Level < 3 then trackFall:= afTrackFall
   704     else trackFall:= 0;
   708     else trackFall:= 0;
   705     Level:= Level; // avoid compiler hint
   709 
   706     ap.ExplR:= 0;
   710     ap.ExplR:= 0;
   707     ap.Time:= 0;
   711     ap.Time:= 0;
   708     ap.Power:= 1;
   712     ap.Power:= 1;
   709     x:= hwRound(Me^.X);
   713     x:= hwRound(Me^.X);
   710     y:= hwRound(Me^.Y);
   714     y:= hwRound(Me^.Y);
   747 
   751 
   748 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   752 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   749 var valueResult, v1, v2, i: LongInt;
   753 var valueResult, v1, v2, i: LongInt;
   750     x, y, trackFall: LongInt;
   754     x, y, trackFall: LongInt;
   751 begin
   755 begin
   752     if Me^.Hedgehog^.BotLevel = 1 then trackFall:= afTrackFall
   756     if Level = 1 then trackFall:= afTrackFall
   753     else trackFall:= 0;
   757     else trackFall:= 0;
   754     Level:= Level; // avoid compiler hint
   758 
   755     ap.ExplR:= 0;
   759     ap.ExplR:= 0;
   756     ap.Time:= 0;
   760     ap.Time:= 0;
   757     ap.Power:= 1;
   761     ap.Power:= 1;
   758     x:= hwRound(Me^.X);
   762     x:= hwRound(Me^.X);
   759     y:= hwRound(Me^.Y) + 4;
   763     y:= hwRound(Me^.Y) + 4;
   803 
   807 
   804 function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   808 function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   805 var valueResult, v1, v2: LongInt;
   809 var valueResult, v1, v2: LongInt;
   806     x, y, trackFall: LongInt;
   810     x, y, trackFall: LongInt;
   807 begin
   811 begin
   808     if Me^.Hedgehog^.BotLevel = 1 then trackFall:= afTrackFall
   812     if Level = 1 then trackFall:= afTrackFall
   809     else trackFall:= 0;
   813     else trackFall:= 0;
   810     Level:= Level; // avoid compiler hint
   814 
   811     ap.ExplR:= 0;
   815     ap.ExplR:= 0;
   812     ap.Time:= 0;
   816     ap.Time:= 0;
   813     ap.Power:= 1;
   817     ap.Power:= 1;
   814     x:= hwRound(Me^.X);
   818     x:= hwRound(Me^.X);
   815     y:= hwRound(Me^.Y);
   819     y:= hwRound(Me^.Y);
   820     RateShove call)}
   824     RateShove call)}
   821     v1:= RateShove(Me, x - 13, y
   825     v1:= RateShove(Me, x - 13, y
   822             , 30, 30, 25
   826             , 30, 30, 25
   823             , -1, -0.8, trackFall or afSetSkip);
   827             , -1, -0.8, trackFall or afSetSkip);
   824     v1:= v1 +
   828     v1:= v1 +
   825         RateShove(Me, x, y
   829         RateShove(Me, x - 2, y
   826             , 30, 30, 25
   830             , 30, 30, 25
   827             , -1, -0.8, trackFall);
   831             , -1, -0.8, trackFall);
   828     // now try opposite direction
   832     // now try opposite direction
   829     v2:= RateShove(Me, x + 13, y
   833     v2:= RateShove(Me, x + 13, y
   830             , 30, 30, 25
   834             , 30, 30, 25
   831             , 1, -0.8, trackFall or afSetSkip);
   835             , 1, -0.8, trackFall or afSetSkip);
   832     v2:= v2 +
   836     v2:= v2 +
   833         RateShove(Me, x, y
   837         RateShove(Me, x + 2, y
   834             , 30, 30, 25
   838             , 30, 30, 25
   835             , 1, -0.8, trackFall);
   839             , 1, -0.8, trackFall);
   836 
   840 
   837     if (v2 > v1) 
   841     if (v2 > v1) 
   838         or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then
   842         or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then
   850         valueResult:= BadTurn
   854         valueResult:= BadTurn
   851     else
   855     else
   852         inc(valueResult);
   856         inc(valueResult);
   853 
   857 
   854     TestWhip:= valueResult;
   858     TestWhip:= valueResult;
       
   859 end;
       
   860 
       
   861 function TestKamikaze(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
       
   862 const step = 8;
       
   863 var valueResult, i, v, tx: LongInt;
       
   864     trackFall: LongInt;
       
   865     t, d, x, y, dx, dy, cx: real;
       
   866 begin
       
   867     ap.ExplR:= 0;
       
   868     ap.Time:= 0;
       
   869     ap.Power:= 1;
       
   870 
       
   871     if Level = 1 then 
       
   872         trackFall:= afTrackFall
       
   873     else if Level = 2 then
       
   874         trackFall:= 0
       
   875     else
       
   876         exit(BadTurn);
       
   877         
       
   878     valueResult:= 0;
       
   879     v:= 0;
       
   880 
       
   881     x:= hwFloat2Float(Me^.X);
       
   882     y:= hwFloat2Float(Me^.Y);
       
   883     d:= sqrt(sqr(Targ.X - x) + sqr(Targ.Y - y));
       
   884     if d < 10 then
       
   885         begin
       
   886         dx:= 0;
       
   887         dy:= 8;
       
   888         ap.Angle:= 2048
       
   889         end
       
   890     else
       
   891         begin
       
   892         t:= step / d;
       
   893         dx:= (Targ.X - x) * t;
       
   894         dy:= (Targ.Y - y) * t;
       
   895 
       
   896         ap.Angle:= DxDy2AttackAnglef(dx, -dy)
       
   897         end;
       
   898     
       
   899     if dx >= 0 then cx:= 0.45 else cx:= -0.45;
       
   900 
       
   901     for i:= 0 to 512 div step - 2 do
       
   902         begin
       
   903         valueResult:= valueResult + 
       
   904             RateShove(Me, trunc(x), trunc(y)
       
   905                 , 30, 30, 25
       
   906                 , cx, -0.9, trackFall or afSetSkip);
       
   907                 
       
   908         x:= x + dx;
       
   909         y:= y + dy;
       
   910         end;
       
   911     if dx = 0 then
       
   912         begin
       
   913         x:= hwFloat2Float(Me^.X);
       
   914         y:= hwFloat2Float(Me^.Y);
       
   915         tx:= trunc(x);
       
   916         v:= RateShove(Me, tx, trunc(y)
       
   917                 , 30, 30, 25
       
   918                 , -cx, -0.9, trackFall);
       
   919         for i:= 1 to 512 div step - 2 do
       
   920             begin
       
   921             y:= y + dy;
       
   922             v:= v + 
       
   923                 RateShove(Me, tx, trunc(y)
       
   924                     , 30, 30, 25
       
   925                     , -cx, -0.9, trackFall or afSetSkip);
       
   926             end
       
   927         end;
       
   928     if v > valueResult then
       
   929         begin
       
   930         ap.Angle:= -2048;
       
   931         valueResult:= v
       
   932         end;
       
   933         
       
   934     v:= RateShove(Me, trunc(x), trunc(y)
       
   935             , 30, 30, 25
       
   936             , cx, -0.9, trackFall);
       
   937     valueResult:= valueResult + v - KillScore * friendlyfactor div 100 * 1024;
       
   938     
       
   939     if v < 65536 then
       
   940         inc(valueResult, RateExplosion(Me, trunc(x), trunc(y), 30));
       
   941 
       
   942     TestKamikaze:= valueResult;
   855 end;
   943 end;
   856 
   944 
   857 function TestHammer(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   945 function TestHammer(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   858 var rate: LongInt;
   946 var rate: LongInt;
   859 begin
   947 begin
  1006 function TestCake(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
  1094 function TestCake(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
  1007 var valueResult, v1, v2: LongInt;
  1095 var valueResult, v1, v2: LongInt;
  1008     x, y, trackFall: LongInt;
  1096     x, y, trackFall: LongInt;
  1009     cake: TGear;
  1097     cake: TGear;
  1010 begin
  1098 begin
  1011     Level:= Level; // avoid compiler hint
  1099     if (Level > 2) then
       
  1100         exit(BadTurn);
  1012     ap.ExplR:= 0;
  1101     ap.ExplR:= 0;
  1013     ap.Time:= 0;
  1102     ap.Time:= 0;
  1014     ap.Power:= BadTurn; // use it as max score value in checkCakeWalk
  1103     ap.Power:= BadTurn; // use it as max score value in checkCakeWalk
  1015 
  1104 
  1016     FillChar(cake, sizeof(cake), 0);
  1105     FillChar(cake, sizeof(cake), 0);