s20_tictactoe_hard - agarmstrong21/agarmstrong_swd_2019 GitHub Wiki
Functionality Requirements:
For this assignment, you must make a game of 3x3 Tic-Tac-Toe. Please see the following article for the rules of this game: https://en.wikipedia.org/wiki/Tic-tac-toe (Links to an external site.)
Your game must allow two players to play Tic-Tac-Toe against each other. Your program must support the following combinations of players:
- One human player and one computer player
- Two human players
- Two computer players
Your computer player can be as smart or “dumb” as you desire. After each move, the current board state must be displayed and the program must check for a winner. If there is a winner or all places in the board are full, the program must display a status and end.
Code Structure Requirements
The game must consist of the following classes:
- Board: Holds the current board configuration and ensures only valid moves are made.
- Player: Parent class for both the ComputerPlayer and HumanPlayer classes
- ComputerPlayer: Class representing a computer player. Inherits from the Player class.
- HumanPlayer: Class representing a human player. Inherits from the Player class.
You MUST use inheritance and polymorphism to structure your program. Your user interface MUST NOT contain any player-specific code except at the point where you instantiate your ComputerPlayer/HumanPlayer objects. ComputerPlayer and HumanPlayer CANNOT print to the screen except in HumanPlayer’s makeMove method which is allowed to prompt user for input and take in that input.
This is the simple game of TicTacToe. This game consists of either two human, one human one computer, or two computer players. The program will ask players where they would like to put their mark, while the computers automatically finds a random spot to put theirs. Who ever has a 3 in a row after the board is filled, wins.
TicTacToeDriver class the Board Class. This class creates two new Players and sets them to Computers at first until the user says it is either PVP, CVC, or PVC. Once the user tells the program how many players there are, then the game will start. The game will print out the board after each move, and will continue to play until the board is filled. Once the board is filled, the program will see who got 3-in-a-row and print out who wins. Computers will randomly generate a number and use the Abstract Player class to check if it is a valid move on the char[] board. If it is, it will play their mark on the board, if not, then it will try another number. Player class asks the user to input a number of 0-8 which signifies where the spot would be on the board. If their move is valid from the Player class, then it will place it.
The java documents are served from a local web server on this machine. To start the web server, navigate to the directory immediately above where the source code is checked out (i.e. ~/git ) and then use "python -m SimpleHTTPServer" in that directory.
cd ~/git python -m SimpleHTTPServer&
Note: if you are running python 3 (which you can check via opening a terminal and typing: python --version), then the command is:
python3 -m http.server