public void StrangeWeakCase() { List <Point> playerMoves = new List <Point> { Point.Make(0, 2), Point.Make(2, 0), Point.Make(2, 2), Point.Make(1, 2) }; var gameState = new Gameplay.GameState(Gameplay.Player.X); foreach (var point in playerMoves) { var move = new Gameplay.Move(point); if (gameState.PossibleMoves.Contains(move)) { gameState = gameState.PickAMove(move); } else { gameState = gameState.PickAMove(gameState.PossibleMoves[0]); } if (gameState.IsEndState) { break; } var aiMove = m_ai.NextMove(gameState); gameState = gameState.PickAMove(aiMove); } Assert.AreEqual(Gameplay.Player.O, gameState.VictoryState.Winner); }
public void AiVsAiDraw() { var gameState = new Gameplay.GameState(Gameplay.Player.X); while (!gameState.IsEndState) { var move = m_ai.NextMove(gameState); gameState = gameState.PickAMove(move); } bool draw = gameState.PossibleMoves.Count == 0 && gameState.VictoryState.Winner.Equals(Gameplay.Player.None); Assert.That(draw, "Move Count: " + gameState.PossibleMoves.Count + " Winner: " + gameState.VictoryState.Winner); }
public AiCase(IList <Point> moves, IEnumerable <Point> nextMoves, Gameplay.Player player) { State = new Gameplay.GameState(player); foreach (var point in moves) { State = State.PickAMove(new Gameplay.Move(point)); } NextMoves = new List <Gameplay.Move>(); foreach (var point in nextMoves) { NextMoves.Add(new Gameplay.Move(point)); } }
private void SwitchState(GameState state) { _state = state; StateChanged?.Invoke(state); }