Tic Tac Toe
About
A simple Tic-Tac-Toe game created with python and the pygame library.
About Tic-Tac-Toe

Tic-Tac-Toe is played on a 3x3 grid and is played with two players. Each player is given a different symbol, in this case player 1 uses 'X' and player 2 uses 'O'. Each player takes turns, placing their symbol into one empty grid space. The player that gets a three of a row first wins the game.
A three in a row is defined as:
- three of the same symbol in a row
- three of the same symbol in a column
- three of the same symbol in a diagonal, going from the top left to bottom right or from top right to bottom left
My Version
I created my version of Tic-Tac-Toe using the pygame library. To make a move, double click on the box you want to insert into. Player 1 always goes first and has the 'X' symbol. Press esc to go back to the home screen.
The logic for running the game is stored in the TTT_Board
class.
The TTT_Board
class has two functions, move(row, col)
and check_win()
.
The move(row, col)
takes two arguments, row
and col
, values between 0 and 2 inclusive,
and inserts the current player's symbol into the corresponding grid space.
The check_win()
function, checks the conditions for a win, listed above,
and returns a string and a list. The string contains the name of the winning player or is empty
if there is no winner. The returned list is empty if there is no winner.
Otherwise it contains the indexes of the grid spaces that make up the three in a row.