Saw
Saw
def main():
# The main function
introduction = intro()
board = create_grid()
pretty = printPretty(board)
symbol_1, symbol_2 = sym()
full = isFull(board, symbol_1, symbol_2) # The function that starts the game is
also in here.
def intro():
# This function introduces the rules of the game Tic Tac Toe
print("Hello! Welcome to Pam's Tic Tac Toe game!")
print("\n")
print("Rules: Player 1 and player 2, represented by X and O, take turns "
"marking the spaces in a 3*3 grid. The player who succeeds in placing "
"three of their marks in a horizontal, vertical, or diagonal row wins.")
print("\n")
input("Press enter to continue.")
print("\n")
def create_grid():
# This function creates a blank playboard
print("Here is the playboard: ")
board = [[" ", " ", " "],
[" ", " ", " "],
[" ", " ", " "]]
return board
def sym():
# This function decides the players' symbols
symbol_1 = input("Player 1, do you want to be X or O? ")
if symbol_1 == "X":
symbol_2 = "O"
print("Player 2, you are O. ")
else:
symbol_2 = "X"
print("Player 2, you are X. ")
input("Press enter to continue.")
print("\n")
return (symbol_1, symbol_2)
else:
board[row][column] = symbol_2
return (board)
if count == 9:
print("The board is full. Game over.")
if winner == True:
print("There is a tie. ")
def printPretty(board):
# This function prints the board nice!
rows = len(board)
cols = len(board)
print("---+---+---")
for r in range(rows):
print(board[r][0], " |", board[r][1], "|", board[r][2])
print("---+---+---")
return board
return winner
# Call Main
main()