MCPcopy Create free account
hub / github.com/geekcomputers/Python / make_move

Function make_move

Tic-Tac-Toe Games/tic-tac-toe3.py:85–99  ·  view source on GitHub ↗

Human move and AI response.

(row: int, col: int)

Source from the content-addressed store, hash-verified

83
84
85def make_move(row: int, col: int) -> None:
86 """Human move and AI response."""
87 if board[row][col] != " ":
88 messagebox.showerror("Error", "Invalid move")
89 return
90 board[row][col] = "X"
91 buttons[row][col].configure(text="X")
92 if check_winner(board, "X"):
93 messagebox.showinfo("Tic-Tac-Toe", "You win!")
94 root.quit()
95 elif is_board_full(board):
96 messagebox.showinfo("Tic-Tac-Toe", "Draw!")
97 root.quit()
98 else:
99 ai_move()
100
101
102def ai_move() -> None:

Callers 1

tic-tac-toe3.pyFile · 0.70

Calls 3

ai_moveFunction · 0.85
check_winnerFunction · 0.70
is_board_fullFunction · 0.70

Tested by

no test coverage detected