Game AI works powerfully on one side and becomes dumb on the other in Tic-Tac-Toe

前端 未结 1 569
感动是毒
感动是毒 2021-01-29 10:30

I am trying to make a Tic-Tac-Toe game in Python using PyGame and the MiniMax algorithm. The AI plays really well when given the first chance (playing as \'X\'), but becomes dum

相关标签:
1条回答
  • 2021-01-29 11:07
    best_score = -float('inf')  # Least possible score
    

    you need to vary this according to the player for which you calculate the move. I think because of this the negative player is choosing random/first plausible move.

    I have implemented minimax and related heuristics like 2 times, and always found that using the "negamax" approach worked best, since you don't need to worry about when to apply max and when min based on the player.

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