Changeset 549 for trunk/AI/StdAI/AI.pas


Ignore:
Timestamp:
Apr 21, 2024, 8:55:53 PM (7 months ago)
Author:
chronos
Message:
  • Modified: Optimize code with earlier break from for cycle evaluating boolean result.
  • Modified: Code cleanup.
File:
1 edited

Legend:

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

    r548 r549  
    17881788  DistrictNeed, DistrictNeed0: array[0..maxCOD - 1] of Integer;
    17891789  ModelOrder: array[0..nMmax - 1] of Integer;
    1790   complete, Fortified: Boolean;
     1790  Complete, Fortified: Boolean;
    17911791
    17921792  function IsBombarded(cix: Integer): Boolean;
     
    19531953            end;
    19541954
    1955       complete := Loop >= FirstSurplusLoop[Cat];
     1955      Complete := Loop >= FirstSurplusLoop[Cat];
    19561956      for I := nModelOrder - 1 downto 0 do
    19571957      begin
     
    19671967                  Dec(DistrictNeed[District[Loc]]);
    19681968                Destination[uix] := Loc;
    1969                 complete := False;
     1969                Complete := False;
    19701970              end;
    19711971
     
    19801980                FindDestination(uix);
    19811981                if Destination[uix] >= 0 then
    1982                   complete := False;
     1982                  Complete := False;
    19831983              end;
    19841984      end;
    19851985      Inc(Loop)
    1986     until complete;
     1986    until Complete;
    19871987  end;
    19881988
     
    20052005    DistrictNeed0 := DistrictNeed;
    20062006
    2007     complete := True;
     2007    Complete := True;
    20082008    for uix := 0 to RO.nUn - 1 do
    20092009      with MyUnit[uix] do
     
    20152015            begin
    20162016              if DistrictNeed0[District[Loc]] > 0 then
    2017                 complete := False;
     2017                Complete := False;
    20182018            end
    20192019            else
     
    20212021              FindDestination(uix);
    20222022              //          if (Destination[uix]<0) and (RO.Territory[Loc]=me) then
    2023               //            complete:=false; // causes hangup when unit can't move due to zoc
     2023              //            Complete:=false; // causes hangup when unit can't move due to zoc
    20242024            end;
    2025   until complete;
     2025  until Complete;
    20262026
    20272027  for uix := 0 to RO.nUn - 1 do
     
    20442044        case ModelCat[mix] of
    20452045          mctGroundDefender, mctGroundAttacker:
    2046             Dec(UnitLack[District[Loc], ModelCat[mix]])
     2046            Dec(UnitLack[District[Loc], ModelCat[mix]]);
    20472047        end;
    20482048end;
     
    23512351            F := Formation[AdjacentLoc];
    23522352            if (F >= 0) and (F < maxCOD) and (OceanPresence[F] and
    2353               not (1 shl Me) <> 0) then
    2354               Result := True;
     2353              not (1 shl Me) <> 0) then begin
     2354                Result := True;
     2355                Exit;
     2356              end;
    23552357          end;
    23562358        end;
Note: See TracChangeset for help on using the changeset viewer.