Building an Unbeatable Tic-Tac-Toe AI with the Minimax Algorithm

https://hackernoon.imgix.net/images/tfXhKw2dEvPIJKSGSyn8w7wzPSU2-1n03f2e.jpeg

I wanted to build something using AI. And it uses AI. I was thinking, what is the best thing to make? And it came to my mind: a game that everyone knows and plays and is easy to play. Tic-tac-toe.

But training an AI to play tic-tac-toe will take time. So it hit me: why not use minimax?

What is minimax?

The minimax algorithm is a decision-making algorithm that is basically used in two-player games like chess or tic-tac-toe.

  • The AI lists every legal move it can make.
  • For each move, it imagines the opponent's best possible response.

Not just that:

  • It assumes the opponent always makes the best move.
  • It evaluates every possible continuation before choosing.

But why choose tic-tac-toe?

Tic-tac-toe is small enough that it can be searched completely, while other games like chess need more because they have many more possibilities.

But the idea is not to...

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE

Read more

https://tii.imgix.net/production/articles/17592/32572c7e-2961-40f3-b2dc-6fddc11c357a.jpg?fm=jpeg&auto=compress&w=610

Sources: Nvidia agrees to invest $2B in Lancium, the power infrastructure developer of the Stargate campus in Texas, plus $1B more if it hits certain thresholds

More: The Guardian, BBC, Wall Street Journal, Washington Post, First Judicial District Court of New Mexico, TechCrunch, The Verge, The Information, nmdoj.gov, Courthouse News Service, Fox News, CNBC, New York Times, Quartz, Fox Business, Amnesty International USA, Associated Press, Breitbart, Reuters, Raw Story, Engadget, Reclaim The Net, TheGrio, Deseret