Python Forum
Yet another Tic-Tac-Toe (with AI, using tkinter)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Yet another Tic-Tac-Toe (with AI, using tkinter)
#6
(May-22-2020, 04:31 PM)GOTO10 Wrote: My number one goal here was to have an AI that can't be defeated, so please let me know if you find a sequence that wins! The AI was done through brute force by starting out with a few obvious checks and then adding new ones as I found new ways to win a game, so it is somewhat haphazardly cobbled together.

The more "proper" way to do this is to implement the minimax algorithm, which models the game as a search tree. Finding the best move is done by assuming that the opponent plays optimally (i.e. chooses the best move each time) and finding the best result you can get given that. It's actually a relatively straightforward algorithm to implement. When performance becomes an issue (which certainly occurs in games like chess, because the search tree is so large), alpha-beta pruning is what you look at - it produces the same result as minimax, but is more efficient because it avoids searching parts of the tree that won't make any difference to the outcome.
Reply


Messages In This Thread
RE: Yet another Tic-Tac-Toe (with AI, using tkinter) - by ndc85430 - May-25-2020, 02:16 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020