Skip to content

Spebby/CMPM123-TicTacToe

 
 

Repository files navigation

Negamax!

My TicTacToe AI is implemented w/ Negamax & Alpha-Beta pruning. I wanted to make sure that the player could enable AI for either player at any point in the game, so my implementation is a little more general to allow for this. Many implementations of Negamax commonly use color and -color for representing the active player, but in order to keep consistent with how the game states are represented as strings, and how a lot of the other logic in the game is handled, sticking with (1, 2) seemed like a good choice, which is why you'll see 3 - playerColor here and there. The individual implementation of Negamax is very by the book, and simply implements Alpha Beta pruning (for fun!). The EvaluateBoard funciton simply calls a modified version of CheckForWinner, and returns a point value of the result based on the current player. The UpdateAI function is where the "magic happens". For every open bit, we'll simulate placing a mark there, and then running Negamax. We'll simulate the opponent's response to this move in order to determine our score. We'll do this for every currently open bit, and determine which has the best value, and play there.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 91.6%
  • C 8.3%
  • CMake 0.1%