for HCC classes taught by Rylan Schubkegel
In part 1 of this project, you created the functions necessary to print a game board; in this part you will add the game state and player input 🕹️
Your program must follow these specifications:
board
variable that represents an empty 3x3 game boardboard
variable with 'X'
or 'O'
value depending on the player’s movePrevious projects have been simple enough to keep everything in a single file. Since this project is bigger, we are going to split it into multiple files!
tic_tac_toe_board.py
tic_tac_toe.py
print_board
function, like so:
from tic_tac_toe_board import print_board
Now, you can use the imported function to print the board
variable each time through your loop!
The current “state” of the game is stored in the board
variable. Each board is a “table” that includes 3 rows, each with 3 columns. A single “cell” of the table represents what piece has been placed on the board. At the beginning of the game, no move have been made, so the board is empty. You can initialize the empty board like this:
board = [
[None, None, None],
[None, None, None],
[None, None, None],
]
As the game progresses, each player will add pieces to the board (represented by 'X'
or 'O'
) so that a complete game board might have a value like this:
[
['X', None, 'O'],
['X', 'O', None],
['X', None, None],
]
When your program meets the requirements, download and submit tic_tac_toe.py
(which is just part 2 of the project).