public void ComputerVsComputer() { DateTime dt = DateTime.Now; ComputerPlayer cpu = new ComputerPlayer(); writer("How many times do you want the Computers to play?"); string numGames = readLine(); int num = int.Parse(numGames); game.newGame(); for (int i = 0; i < num; i++) { while (!game.gameIsOver()) { cpu.makeMove(game); } game.endGame(); game.newGame(); } TimeSpan ts = DateTime.Now - dt; writer(ts.ToString()); }
public void PlayerInput() { HumanPlayer player1 = new HumanPlayer(writer, readLine); ComputerPlayer computerPlayer = new ComputerPlayer(); game.newGame(); Random randgen = new Random(); int rand = randgen.Next(0, 2); bool isPlayerTurn = rand % 2 == 0; if (isPlayerTurn){ writer("Congradulations, you get to go first!"); }else{ writer("The computer goes first."); } while (!game.gameIsOver()) { if (isPlayerTurn) { player1.makeMove(game); } else { computerPlayer.makeMove(game); } isPlayerTurn = !isPlayerTurn; if (game.gameIsOver() && isPlayerTurn) { writer("You win!"); } else if (game.gameIsOver()) { writer("You lose"); } } game.endGame(); }