public void OnlyOnePlayerCanClaimEachSquare() { var naughts = new TurnByTurnPlayerStub(); var crosses = new TurnByTurnPlayerStub(); var game = new TicTacToeGame(naughts, crosses); naughts.Next(1, 1); game.PlayTurn(); crosses.Next(1, 1); game.PlayTurn(); Assert.That(game.PlayerOnSquare(1, 1), Is.EqualTo(naughts)); }
public void PlayersMustMoveWithinTheTopLeftBoundsOfTheBoard() { var naughts = new TurnByTurnPlayerStub(); var game = new TicTacToeGame(naughts, null); naughts.Next(0, 0); Assert.Throws<InvalidMoveException>(() => game.PlayTurn()); }
public void NaughtsStartsTheGame() { var naughts = new TurnByTurnPlayerStub(); var game = new TicTacToeGame(naughts, null); naughts.Next(1, 1); game.PlayTurn(); Assert.That(game.PlayerOnSquare(1, 1), Is.EqualTo(naughts)); }
public void PlayersAlternateTurns() { var naughts = new TurnByTurnPlayerStub(); var crosses = new TurnByTurnPlayerStub(); var game = new TicTacToeGame(naughts, crosses); naughts.Next(1, 1); game.PlayTurn(); Assert.That(game.CurrentPlayer, Is.EqualTo(crosses)); }
public void PlayersTurnIsNotOverUntilTheyMakeAValidMove() { var naughts = new TurnByTurnPlayerStub(); var crosses = new TurnByTurnPlayerStub(); var game = new TicTacToeGame(naughts, crosses); naughts.Next(1, 1); game.PlayTurn(); crosses.Next(1, 1); game.PlayTurn(); Assert.That(game.CurrentPlayer, Is.EqualTo(crosses)); }
public static void Main(string[] args) { var naughts = new ConsolePlayer(new ConsoleInput()); var crosses = new MiniMaxPlayer(naughts); var game = new TicTacToeGame(naughts, crosses); var printer = new GameBoardPrinter(game); Console.WriteLine("Welcome to Helen's TicTacToe game!"); Console.WriteLine(printer.Board()); while (!game.IsFinished) { Console.WriteLine("It's " + printer.NameForPlayer(game.CurrentPlayer) + "'s turn!"); game.PlayTurn(); Console.WriteLine(printer.Board()); } Console.WriteLine("Game over!"); Console.WriteLine(printer.WinnerMessage()); Console.ReadLine(); }