import numpy as np
# Create a 3x3 board
board = np.array([[0, 0, 0],
[0, 0, 0],
[0, 0, 0]])
# Initialize variables
player = 1 # Player 1 starts first
game_over = False
# Main game loop
while not game_over:
# Print the board
print(board)
# Get player's move
if player == 1:
symbol = 'X'
else:
symbol = 'O'
row = int(input(f"Player {player}, enter row (0, 1, or 2): "))
col = int(input(f"Player {player}, enter column (0, 1, or 2): "))
# Check if cell is empty
if board[row, col] == 0:
board[row, col] = player
else:
print("That cell is occupied, try again")
continue
# Check for win or tie
if check_win(board) == 1:
print("Player 1 wins!")
game_over = True
elif check_win(board) == 2:
print("Player 2 wins!")
game_over = True
elif np.all(board != 0):
print("It's a tie")
game_over = True
# Switch player
if player == 1:
player = 2
else:
player = 1
# Print final board
print(board)