Tic Tac Toe perfect AI algorithm: deeper in “create fork” step

前端 未结 1 1399
面向向阳花
面向向阳花 2021-01-31 20:53

I\'ve already read many Tic Tac Toe topics on StackOverflow. And I found the strategy on Wikipedia is suitable for my presentation project:

A player can p

相关标签:
1条回答
  • 2021-01-31 21:06

    I am not sure that it is the most elegant way to do it, but here is a two step way of looking at forks.

    If the computer cannot win next turn, and it is not the first or second turn, a fork might be possible (this does not deal with creating the setup for a fork, just finding a fork).

    For each of the cells that are empty, fill it, then run your step 1 function (sees if there are two in a row). If it finds two places, congrats, you have a fork. If not, you don't.

    0 讨论(0)
提交回复
热议问题