Changeset 265 for trunk/UClientAI.pas


Ignore:
Timestamp:
Jan 15, 2019, 1:03:40 AM (6 years ago)
Author:
chronos
Message:
  • Modified: Cell power is now internally represented as unit power (TUnit class).
  • Modified: Allow to have only one player in the game.
  • Added: New win objective None to just play freely without any win objective.
  • Added: New win objective to capture entire map.
  • Added: TGameSystem class to represent various game play systems of other existing games.
  • Fixed: Clear correctly defender player from unit moves if his cell is captured.
  • Fixed: Do not allow to remove too many players to have at least minimum players.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UClientAI.pas

    r231 r265  
    4444  TotalAttackPower: Integer;
    4545  CanAttack: Integer;
     46  TargetPower: Integer;
    4647  TargetCells: TPlayerCells;
    4748  Cell: TPlayerCell;
     
    8182
    8283      // Attack if target is weaker
    83       if TotalPower >= (MapCell.Power + AttackDiff) then begin
     84      if Assigned(MapCell.OneUnit) then TargetPower := MapCell.OneUnit.Power
     85        else TargetPower := 0;
     86      if TotalPower >= (TargetPower + AttackDiff) then begin
    8487        TotalAttackPower := 0;
    8588        for NeighborCell in Neighbors do
    8689        if NeighborCell.MapCell.Player = ControlPlayer then begin
    8790          // Use only necessary power
    88           AttackPower := MapCell.Power - TotalAttackPower + AttackDiff;
     91          AttackPower := TargetPower - TotalAttackPower + AttackDiff;
    8992          if NeighborCell.GetAvialPower < AttackPower then
    9093            AttackPower := NeighborCell.GetAvialPower;
     
    141144      end;
    142145      // Attack if target is weaker
    143       if Game.AttackProbability(TotalPower, TargetCell.MapCell.Power) >=
     146      if Game.AttackProbability(TotalPower, TargetCell.MapCell.OneUnit.Power) >=
    144147        ComputerAggroProbability[ControlPlayer.Agressivity] then begin
    145148        // Try to limit total attacking power to necessary minimum
    146         while Game.AttackProbability(TotalPower - 1, TargetCell.MapCell.Power) >=
     149        while Game.AttackProbability(TotalPower - 1, TargetCell.MapCell.OneUnit.Power) >=
    147150          ComputerAggroProbability[ControlPlayer.Agressivity] do
    148151          Dec(TotalPower);
     
    306309    for I := 0 to Neighbors.Count - 1 do
    307310    if (Neighbors[I].MapCell.Player <> ControlPlayer) and (Neighbors[I].MapCell.Player <> nil) then begin
    308       Inc(EnemyPower, Neighbors[I].MapCell.Power);
     311      Inc(EnemyPower, Neighbors[I].MapCell.OneUnit.Power);
    309312    end;
    310313    if EnemyPower > (GetAvialPower + GetAttackPower) then begin
Note: See TracChangeset for help on using the changeset viewer.