Changeset 548 for trunk/AI


Ignore:
Timestamp:
Apr 21, 2024, 10:57:18 AM (8 months ago)
Author:
chronos
Message:
  • Fixed: Bad unit drawing in battle dialog.
  • Modified: Code cleanup.
Location:
trunk/AI/StdAI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/AI/StdAI/AI.pas

    r531 r548  
    231231        else
    232232        begin
    233           Quality := trunc(100 * (ln(mi.Attack) + ln(mi.Defense) +
    234             ln(mi.Speed / 150) * 1.7 - ln(mi.Cost)));
     233          Quality := Trunc(100 * (Ln(mi.Attack) + Ln(mi.Defense) +
     234            Ln(mi.Speed / 150) * 1.7 - Ln(mi.Cost)));
    235235          if mi.Cap and (1 shl (mcFanatic - mcFirstNonCap)) <> 0 then
    236             Inc(Quality, trunc(100 * ln(1.5)));
     236            Inc(Quality, Trunc(100 * Ln(1.5)));
    237237          if mi.Cap and (1 shl (mcLongRange - mcFirstNonCap)) <> 0 then
    238             Inc(Quality, trunc(100 * ln(1.5)));
     238            Inc(Quality, Trunc(100 * Ln(1.5)));
    239239        end;
    240240      end
     
    242242      begin
    243243        Category := mctGroundDefender;
    244         Quality := trunc(100 * (ln(mi.Defense) - ln(mi.Cost) * 0.6));
     244        Quality := Trunc(100 * (Ln(mi.Defense) - Ln(mi.Cost) * 0.6));
    245245        if mi.Cap and (1 shl (mcFanatic - mcFirstNonCap)) <> 0 then
    246           Inc(Quality, trunc(100 * ln(1.5)));
     246          Inc(Quality, Trunc(100 * Ln(1.5)));
    247247      end;
    248248    dSea:
     
    257257          if EffectiveTransport > 4 then
    258258            EffectiveTransport := 4; // rarely used more
    259           Quality := 100 + trunc(100 * (ln(EffectiveTransport) +
    260             ln(mi.Speed / 150) + ln(mi.Defense) - ln(mi.Cost)));
     259          Quality := 100 + Trunc(100 * (Ln(EffectiveTransport) +
     260            Ln(mi.Speed / 150) + Ln(mi.Defense) - Ln(mi.Cost)));
    261261          if mi.Cap and (1 shl (mcNav - mcFirstNonCap)) <> 0 then
    262             Inc(Quality, trunc(100 * ln(1.5)));
     262            Inc(Quality, Trunc(100 * Ln(1.5)));
    263263          if mi.Cap and (1 shl (mcAirDef - mcFirstNonCap)) <> 0 then
    264             Inc(Quality, trunc(100 * ln(1.3)));
     264            Inc(Quality, Trunc(100 * Ln(1.3)));
    265265        end;
    266266      end
     
    272272        else
    273273        begin
    274           Quality := trunc(100 * (ln(mi.Attack) + ln(mi.Defense) * 0.6 - ln(mi.Cost)));
     274          Quality := Trunc(100 * (Ln(mi.Attack) + Ln(mi.Defense) * 0.6 - Ln(mi.Cost)));
    275275          if mi.Cap and (1 shl (mcNav - mcFirstNonCap)) <> 0 then
    276             Inc(Quality, trunc(100 * ln(1.4)));
     276            Inc(Quality, Trunc(100 * Ln(1.4)));
    277277          if mi.Cap and (1 shl (mcAirDef - mcFirstNonCap)) <> 0 then
    278             Inc(Quality, trunc(100 * ln(1.3)));
     278            Inc(Quality, Trunc(100 * Ln(1.3)));
    279279          if mi.Cap and (1 shl (mcLongRange - mcFirstNonCap)) <> 0 then
    280             Inc(Quality, trunc(100 * ln(2.0)));
     280            Inc(Quality, Trunc(100 * Ln(2.0)));
    281281          if mi.Cap and (1 shl (mcRadar - mcFirstNonCap)) <> 0 then
    282             Inc(Quality, trunc(100 * ln(1.5)));
     282            Inc(Quality, Trunc(100 * Ln(1.5)));
    283283        end;
    284284      end;
  • trunk/AI/StdAI/ToolAI.pas

    r531 r548  
    197197      X := Loc - Y * G.lx;
    198198      Inc(sy, Y);
    199       A := 2 * pi * X / G.lx;
    200       su := su + cos(A);
    201       sv := sv + sin(A);
     199      A := 2 * Pi * X / G.lx;
     200      su := su + Cos(A);
     201      sv := sv + Sin(A);
    202202      Inc(N);
    203203    end;
    204204  end;
    205   A := arctan2(sv, su);
    206   X := round(G.lx * A / (2 * pi));
     205  A := ArcTan2(sv, su);
     206  X := Round(G.lx * A / (2 * Pi));
    207207  while X >= G.lx do
    208208    Dec(X, G.lx);
Note: See TracChangeset for help on using the changeset viewer.