AI makes a move.
()
| 100 | |
| 101 | |
| 102 | def 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 --- |
no test coverage detected