The purpose of this lab is to integrate the core language constructs of C++ learned in CISC1600.
The assignment is to write a program to play the game of Tic Tac Toe. The game should allow for two players to play each other. You can choose whether player X or player O begins. The players continue to take turns until the first player gets three in a row or until there is a stalemate where no one can win.
The program should begin with a welcome message indicating the purpose of the program. To begin the game, the program should display the initial (empty) board. It should then prompt each player to enter the space they would like to move to. If the space is free, the move should be accepted else, the move should be rejected and they should be prompted to enter another space. The program should display the updated board with each accepted move. When appropriate, the program should check the board for a winner. If the program finds three in a row it should congratulate the winner and exit (or see bonus).
In summary the program should:
Following is an example run:
Welcome to ...
+--+--+--+
|__|__|__|
+--+--+--+
|__|__|__|
+--+--+--+
|__|__|__|
+--+--+--+
Player O Enter your move: 1,1
+--+--+--+
|O_|__|__|
+--+--+--+
|__|__|__|
+--+--+--+
|__|__|__|
+--+--+--+
Player X Enter your move: 2,2
+--+--+--+
|O_|__|__|
+--+--+--+
|__|X_|__|
+--+--+--+
|__|__|__|
+--+--+--+
Player O Enter your Move: 1,2
+--+--+--+
|O_|O_|__|
+--+--+--+
|__|X_|__|
+--+--+--+
|__|__|__|
+--+--+--+
Player X Enter your move: 1,2
No No Player X that spot is occupied!
Player X Enter your move:5,2
Oh c'mon really? At least choose a move on the board!
Player X Enter your move:1,3
+--+--+--+
|O_|O_|X_|
+--+--+--+
|__|X_|__|
+--+--+--+
|__|__|__|
+--+--+--+
Etc...
NOTE: Alternatively, you can make your program friendlier by numbering each empty square and allowing the user to name the square using that number instead of entering of the row number and col number of the square. The following is a nice naming scheme:
+--+--+--+
|1_|2_|3_|
+--+--+--+
|4_|5_|6_|
+--+--+--+
|7_|8_|9_|
+--+--+--+
Bonus: At the end of each game have the program prompt (the players) if they want to play another game. If they enter in the affirmative i.e. (y/Y)es the program should continue and play another game of tic tac toe, else the program should politely exit. Keep track of the number of times that each player wins and print out summary results when they no longer want to play the game.