public void PlayTurn(IBoardState boardState) { LOGIC_START: foreach (Hex own in boardState.GetFieldsForPlayer(this._player)) { if (own.Dices == 1) { continue; } foreach ((Hex other, RelativeDirection direction) in boardState.GetNeighborsOfDifferentColor(this._player.Color, own)) { // 0.33 - 6.0 double diceRelation = ((double)own.Dices) / other.Dices; if ((this._random.NextDouble() * 0.5 + diceRelation > 1.2d || own.Dices == 8) && boardState.CanAttack(own, other, out _)) { bool won = boardState.PerformAttack(own, other).victory; if (won) { // Restart the logic to also process the freshly conquered fields goto LOGIC_START; } else { break; } } } } }
public void PlayTurn(IBoardState boardState) { Color lastAttackedBy = boardState.AttackHistory.LastOrDefault(x => x.defender.playerColor == this._player.Color).attacker.playerColor; LOGIC_START: foreach (Hex own in boardState.GetFieldsForPlayer(this._player)) { if (own.Dices == 1) { continue; } foreach ((Hex other, RelativeDirection direction) in boardState.GetNeighborsOfColor(lastAttackedBy, own)) { if (own.Dices >= other.Dices && boardState.CanAttack(own, other, out _)) { bool won = boardState.PerformAttack(own, other).victory; if (won) { // Restart the logic to also process the freshly conquered fields goto LOGIC_START; } else { break; } } } } }