Python Forum
Problem with a minimax algorith in Tic,Tac,Toe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with a minimax algorith in Tic,Tac,Toe
#2
About why the first move takes a long time.

There are 255,168 possible combinations in a tic-tac-toe board, 3198 combinations after two selections are made, 108 combinations after 4 selections are made, 6 combinations after 6 selections are made, and only 1 combination after 8 selections are made. Calls to minimax are more than twice that: 549,945 times for the first robot choice, 6811 times for the second robot choice, 257 times for the third robot choice, 15 times for the fourth robot choice, and 1 time for the last open spot on the board.

It takes a while to do something 549,945 times, so speeding up minimax will do a lot to reduce how long it takes the robot to make the first move. Maybe you could keep a count of how many choices have been made and use that instead of using the checkDraw() function. Maybe you could use the fact that the most recent marker will always be a part of the winning row/column/diagonal to speed up the whichmarkwon() function. If the robot just placed a marker there is no reason to check if the player won.
Reply


Messages In This Thread
RE: Problem with a minimax algorith in Tic,Tac,Toe - by deanhystad - Jan-23-2022, 05:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tic tac toe python minimax alpha beta FSNWRMH 6 1,256 Dec-19-2023, 06:40 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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