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

Function ai_move

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

AI makes a move.

()

Source from the content-addressed store, hash-verified

100
101
102def ai_move() -> None:
103 """AI makes a move."""
104 move = best_move(board)
105 if move is None:
106 return
107 r, c = move
108 board[r][c] = "O"
109 buttons[r][c].configure(text="O")
110 if check_winner(board, "O"):
111 messagebox.showinfo("Tic-Tac-Toe", "AI wins!")
112 root.quit()
113 elif is_board_full(board):
114 messagebox.showinfo("Tic-Tac-Toe", "Draw!")
115 root.quit()
116
117
118# --- Initialize GUI ---

Callers 1

make_moveFunction · 0.85

Calls 3

best_moveFunction · 0.85
check_winnerFunction · 0.70
is_board_fullFunction · 0.70

Tested by

no test coverage detected