static void SinglePlayer() { var matrix = Reset(); IPlayer human = new Human() { Symbol = 2 }; IPlayer ai = new AI() { Symbol = 1 }; Coordinates c = new Coordinates(); IPlayer CurrentPlayer = human; board.displayboard(matrix); do { c = CurrentPlayer.play(matrix); if (CurrentPlayer == human) { board.UpdateBoard(matrix, c, 2); board.displayboard(matrix); CurrentPlayer = ai; } else { board.UpdateBoard(matrix, c, 1); board.displayboard(matrix); CurrentPlayer = human; } } //play the game while (GameStatus.IsGameOver(matrix) == 0); var ret = GameStatus.IsGameOver(matrix); if (ret == 1) { Console.WriteLine(" :( You Lose!"); } else if (ret == 2) { Console.Write("Congratulations!! You Win!! :D"); } else if (ret == 3) { Console.WriteLine("Draw"); } }
static void Multiplayer() { var matrix = Reset(); IPlayer Player1 = new Human(); IPlayer Player2 = new Human(); Coordinates c = new Coordinates(); IPlayer CurrentPlayer = Player2; board.displayboard(matrix); do { c = CurrentPlayer.play(matrix); if (CurrentPlayer == Player2) { board.UpdateBoard(matrix, c, 2); board.displayboard(matrix); CurrentPlayer = Player1; } else { board.UpdateBoard(matrix, c, 1); board.displayboard(matrix); CurrentPlayer = Player2; } } //play the game while (GameStatus.IsGameOver(matrix) == 0); var ret = GameStatus.IsGameOver(matrix); if (ret == 1) { Console.WriteLine("Player 1 wins!!"); } else if (ret == 2) { Console.Write("Player 2 wins!!"); } else if (ret == 3) { Console.WriteLine("Draw"); } }