You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Start with this board position.
board = [
[1, 1, -1],
[ -1, 1, 0],
[ -1, 0, 0],
]
Choose X or O
Chosen: O
First to start?[y/n]: n
Computer turn [X]
---------------
| X || X || O |
---------------
| O || X || |
---------------
| O || || |
---------------
Human turn [O]
---------------
| X || X || O |
---------------
| O || X || X | <--------- Wrong move by computer
---------------
| O || || |
---------------
Use numpad (1..9):
The text was updated successfully, but these errors were encountered:
X starts with a winning board state. Any move by X will result in win. The algorithm just marks the first available position (6 in this case) instead of the positions that will bring the quickest win.
To solve this problem we can say that if computer is winning in the current move then computer will not check further and it should consider this move as the best move . If there are many move in which computer can win in current move then computer can select any one of them.
To do this , In Minimax function when we are iterating over all empty cells we should check if this move will lead to immediate victory, if yes then this move is optimal otherwise check further.
In C++ :
Start with this board position.
board = [
[1, 1, -1],
[ -1, 1, 0],
[ -1, 0, 0],
]
The text was updated successfully, but these errors were encountered: