Changeset 222 for trunk/UClientAI.pas


Ignore:
Timestamp:
Jul 13, 2018, 11:13:12 PM (6 years ago)
Author:
chronos
Message:
  • Fixed: Computer was affecting player cells by its cell moves.
  • Added: Additional consistency checks.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UClientAI.pas

    r213 r222  
    6060      CanAttack := 0;
    6161      for NeighborCell in Neighbors do
    62       if NeighborCell.Player = Game.CurrentPlayer then begin
     62      if NeighborCell.Player = ControlPlayer then begin
    6363        Inc(CanAttack);
    6464      end;
     
    7777      TotalPower := 0;
    7878      for NeighborCell in Neighbors do
    79       if NeighborCell.Player = Game.CurrentPlayer then
     79      if NeighborCell.Player = ControlPlayer then
    8080        TotalPower := TotalPower + NeighborCell.GetAvialPower;
    8181
     
    8484        TotalAttackPower := 0;
    8585        for NeighborCell in Neighbors do
    86         if NeighborCell.Player = Game.CurrentPlayer then begin
     86        if NeighborCell.Player = ControlPlayer then begin
    8787          // Use only necessary power
    8888          AttackPower := Power - TotalAttackPower + AttackDiff;
     
    109109  NeighborCell: TCell;
    110110begin
    111   if ControlPlayer.Defensive then Exit;
     111if ControlPlayer.Defensive then Exit;
    112112
    113113  AllCells := Game.Map.Cells;
     
    188188  for C := 0 to AllCells.Count - 1 do
    189189  with AllCells[C] do begin
    190     if (Player <> Game.CurrentPlayer) and (Player <> nil) and (Terrain <> ttVoid) then begin
     190    if (Player <> ControlPlayer) and (Player <> nil) and (Terrain <> ttVoid) then begin
    191191      CanAttack := 0;
    192192      for I := 0 to Neighbors.Count - 1 do
    193       if ((Neighbors[I].Player = Game.CurrentPlayer) or
     193      if ((Neighbors[I].Player = ControlPlayer) or
    194194      (Neighbors[I].Player = nil)) and (Neighbors[I].Terrain <> ttVoid) then begin
    195195        Inc(CanAttack);
     
    218218      for I := 0 to Neighbors.Count - 1 do begin
    219219        if (Neighbors[I].Terrain <> ttVoid) and (not Neighbors[I].Mark) then begin
    220           if (TargetCells[C].Player = Game.CurrentPlayer) and
    221           (Neighbors[I].Player = Game.CurrentPlayer) then begin
     220          if (TargetCells[C].Player = ControlPlayer) and
     221          (Neighbors[I].Player = ControlPlayer) then begin
    222222            // Do not take units from front line
    223223            Cells2 := Neighbors[I].Neighbors;
    224224            CanAttack := 0;
    225225            for J := 0 to Cells2.Count - 1 do
    226             if ((Cells2[J].Player <> Game.CurrentPlayer) or (Cells2[J].Player = nil))
     226            if ((Cells2[J].Player <> ControlPlayer) or (Cells2[J].Player = nil))
    227227            and (Cells2[J].Terrain <> ttVoid) then begin
    228228              Inc(CanAttack);
     
    292292  for C := 0 to AllCells.Count - 1 do
    293293  with AllCells[C] do begin
    294     if (Terrain <> ttVoid) and (Player = Game.CurrentPlayer)  then begin
     294    if (Terrain <> ttVoid) and (Player = ControlPlayer)  then begin
    295295      if AttackersCount(AllCells[C]) > 0 then
    296296        BorderCells.Add(AllCells[C]);
     
    305305    EnemyPower := 0;
    306306    for I := 0 to Neighbors.Count - 1 do
    307     if (Neighbors[I].Player <> Game.CurrentPlayer) and (Neighbors[I].Player <> nil) then begin
     307    if (Neighbors[I].Player <> ControlPlayer) and (Neighbors[I].Player <> nil) then begin
    308308      Inc(EnemyPower, Neighbors[I].Power);
    309309    end;
     
    329329  Result := 0;
    330330  for I := 0 to Cell.Neighbors.Count - 1 do
    331   if (Cell.Neighbors[I].Player <> Game.CurrentPlayer) and
     331  if (Cell.Neighbors[I].Player <> ControlPlayer) and
    332332    (Cell.Neighbors[I].Player <> nil) then begin
    333333      Inc(Result);
Note: See TracChangeset for help on using the changeset viewer.