hedgewars/uAIAmmoTests.pas
changeset 8895 95177c18e38c
parent 8862 85eb1f4b4a5f
child 8903 b35752efd5df
equal deleted inserted replaced
8893:8f92e94d0b32 8895:95177c18e38c
   162             y:= y + dY;
   162             y:= y + dY;
   163             dX:= dX + windSpeed;
   163             dX:= dX + windSpeed;
   164             dY:= dY + cGravityf;
   164             dY:= dY + cGravityf;
   165             dec(t)
   165             dec(t)
   166         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 
   167                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t <= 0);
   167                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5))) or (t <= 0);
   168         
   168         
   169         EX:= trunc(x);
   169         EX:= trunc(x);
   170         EY:= trunc(y);
   170         EY:= trunc(y);
   171         if Level = 1 then
   171         if Level = 1 then
   172             value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   172             value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   225                 y:= y + dY;
   225                 y:= y + dY;
   226                 dX:= dX + windSpeed;
   226                 dX:= dX + windSpeed;
   227                 dY:= dY + cGravityf;
   227                 dY:= dY + cGravityf;
   228                 dec(t)
   228                 dec(t)
   229             until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   229             until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   230                    ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (y > cWaterLine);
   230                    ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5))) or (y > cWaterLine);
   231 
   231 
   232             if TestCollWithLand(trunc(x), trunc(y), 5) and (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) > 21) then
   232             if TestCollExcludingObjects(trunc(x), trunc(y), 5) and (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) > 21) then
   233                 begin
   233                 begin
   234                 timer := 500;
   234                 timer := 500;
   235                 t2 := 0.5 / sqrt(sqr(dX) + sqr(dY));
   235                 t2 := 0.5 / sqrt(sqr(dX) + sqr(dY));
   236                 dX := dX * t2;
   236                 dX := dX * t2;
   237                 dY := dY * t2;
   237                 dY := dY * t2;
   242                 until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 22)
   242                 until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 22)
   243                     or (x < 0)
   243                     or (x < 0)
   244                     or (y < 0)
   244                     or (y < 0)
   245                     or (trunc(x) > LAND_WIDTH)
   245                     or (trunc(x) > LAND_WIDTH)
   246                     or (trunc(y) > LAND_HEIGHT)
   246                     or (trunc(y) > LAND_HEIGHT)
   247                     or not TestCollWithLand(trunc(x), trunc(y), 5)
   247                     or not TestCollExcludingObjects(trunc(x), trunc(y), 5)
   248                     or (timer = 0)
   248                     or (timer = 0)
   249                 end;
   249                 end;
   250             EX:= trunc(x);
   250             EX:= trunc(x);
   251             EY:= trunc(y);
   251             EY:= trunc(y);
   252             // Try to prevent AI from thinking firing into water will cause a drowning
   252             // Try to prevent AI from thinking firing into water will cause a drowning
   302             y:= y + dY;
   302             y:= y + dY;
   303             dX:= dX + windSpeed;
   303             dX:= dX + windSpeed;
   304             dY:= dY + cGravityf;
   304             dY:= dY + cGravityf;
   305             dec(t)
   305             dec(t)
   306         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   306         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   307                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t <= 0);
   307                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5))) or (t <= 0);
   308         EX:= trunc(x);
   308         EX:= trunc(x);
   309         EY:= trunc(y);
   309         EY:= trunc(y);
   310 
   310 
   311         value:= RateShove(trunc(x), trunc(y), 5, 1, trunc((abs(dX)+abs(dY))*20), -dX, -dY, afTrackFall);
   311         value:= RateShove(trunc(x), trunc(y), 5, 1, trunc((abs(dX)+abs(dY))*20), -dX, -dY, afTrackFall);
   312         // LOL copypasta: this is score for digging with... snowball
   312         // LOL copypasta: this is score for digging with... snowball
   354             x:= x + Vx;
   354             x:= x + Vx;
   355             y:= y + dY;
   355             y:= y + dY;
   356             dY:= dY + cGravityf;
   356             dY:= dY + cGravityf;
   357             dec(t)
   357             dec(t)
   358         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or 
   358         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or 
   359                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 6))) or (t = 0);
   359                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 6))) or (t = 0);
   360         EX:= trunc(x);
   360         EX:= trunc(x);
   361         EY:= trunc(y);
   361         EY:= trunc(y);
   362         if t < 50 then
   362         if t < 50 then
   363             Score:= RateExplosion(Me, EX, EY, 97)  // average of 17 attempts, most good, but some failing spectacularly
   363             Score:= RateExplosion(Me, EX, EY, 97)  // average of 17 attempts, most good, but some failing spectacularly
   364         else
   364         else
   406             x:= x + Vx;
   406             x:= x + Vx;
   407             y:= y + dY;
   407             y:= y + dY;
   408             dY:= dY + cGravityf;
   408             dY:= dY + cGravityf;
   409             dec(t)
   409             dec(t)
   410         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   410         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   411                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t = 0);
   411                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5))) or (t = 0);
   412     EX:= trunc(x);
   412     EX:= trunc(x);
   413     EY:= trunc(y);
   413     EY:= trunc(y);
   414     if t < 50 then 
   414     if t < 50 then 
   415         if Level = 1 then
   415         if Level = 1 then
   416             Score:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   416             Score:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   466         x:= x + Vx;
   466         x:= x + Vx;
   467         y:= y + dY;
   467         y:= y + dY;
   468         dY:= dY + cGravityf;
   468         dY:= dY + cGravityf;
   469         dec(t)
   469         dec(t)
   470     until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   470     until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   471            ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t = 0);
   471            ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5))) or (t = 0);
   472     EX:= trunc(x);
   472     EX:= trunc(x);
   473     EY:= trunc(y);
   473     EY:= trunc(y);
   474     if t < 50 then 
   474     if t < 50 then 
   475         Score:= RateExplosion(Me, EX, EY, 41)
   475         Score:= RateExplosion(Me, EX, EY, 41)
   476     else 
   476     else 
   519             x:= x + Vx;
   519             x:= x + Vx;
   520             y:= y + dY;
   520             y:= y + dY;
   521             dY:= dY + cGravityf;
   521             dY:= dY + cGravityf;
   522             dec(t)
   522             dec(t)
   523        until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or 
   523        until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or 
   524                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 6))) or (t = 0);
   524                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 6))) or (t = 0);
   525         
   525         
   526         EX:= trunc(x);
   526         EX:= trunc(x);
   527         EY:= trunc(y);
   527         EY:= trunc(y);
   528         if t < 50 then 
   528         if t < 50 then 
   529             Score:= RateExplosion(Me, EX, EY, 200) + RateExplosion(Me, EX, EY + 120, 200)
   529             Score:= RateExplosion(Me, EX, EY, 200) + RateExplosion(Me, EX, EY + 120, 200)
   600         y:= y + dY;
   600         y:= y + dY;
   601         dY:= dY + cGravityf;
   601         dY:= dY + cGravityf;
   602         EX:= trunc(x);
   602         EX:= trunc(x);
   603         EY:= trunc(y);
   603         EY:= trunc(y);
   604     until (((Me = CurrentHedgehog^.Gear) and TestColl(EX, EY, 4)) or 
   604     until (((Me = CurrentHedgehog^.Gear) and TestColl(EX, EY, 4)) or 
   605            ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, EX, EY, 4))) or (EY > cWaterLine);
   605            ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, EX, EY, 4))) or (EY > cWaterLine);
   606 
   606 
   607     if (EY < cWaterLine) and (dY >= 0) then
   607     if (EY < cWaterLine) and (dY >= 0) then
   608         begin
   608         begin
   609         Score:= RateExplosion(Me, EX, EY, 91);
   609         Score:= RateExplosion(Me, EX, EY, 91);
   610         if (Score = 0) then
   610         if (Score = 0) then
   654     x:= x + vX;
   654     x:= x + vX;
   655     y:= y + vY;
   655     y:= y + vY;
   656     rx:= trunc(x);
   656     rx:= trunc(x);
   657     ry:= trunc(y);
   657     ry:= trunc(y);
   658     if ((Me = CurrentHedgehog^.Gear) and TestColl(rx, ry, 2)) or 
   658     if ((Me = CurrentHedgehog^.Gear) and TestColl(rx, ry, 2)) or 
   659         ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, rx, ry, 2)) then
   659         ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, rx, ry, 2)) then
   660     begin
   660     begin
   661         x:= x + vX * 8;
   661         x:= x + vX * 8;
   662         y:= y + vY * 8;
   662         y:= y + vY * 8;
   663         valueResult:= RateShotgun(Me, vX, vY, rx, ry);
   663         valueResult:= RateShotgun(Me, vX, vY, rx, ry);
   664      
   664