Trying to build the tic tac toe game for me has been much harder than everything else I’ve done on this site because I can’t wrap my head around the whole minimax algorithm and AI in general despite looking at examples after examples. It got me curious as to how much a web developer would be required to build computer AI like this. I’m not so much interested in building games so much as websites so would it be something you would work on a lot? I’m asking because I’m wondering if I should take all the time and effort to really start learning it or if it’s not so important. Any thoughts?
I’d call it game logic more than AI, and I’d say being able to think your way through that algorithm is very important. Not for static sites, but for any complex application.
It’s not the game, it’s learning algorithms.
I’ll have to look into this minimax algorithm. I’d never heard of it when I wrote my tic-tac-toe app, but mine works great and didn’t take too many lines of code to pull off.
EDIT: I just went and looked it up. It’s not necessary, though I did something similar in my first version of my game, before discarding it. My first version was also unbeatable, but it wasn’t as much fun as the current version, which incorporates some randomization in order to be more human-like. It’s still very tough, but not impossible.
I finished the Tic Tac Toe also without the Minimax algorithm. Basically my computer player would play in this order:
If they could win this turn, win.
If the human could win next turn, block them.
Otherwise, basically play randomly.
That was the logic I started with and then worked in specific rules based on certain game configuration to guarantee the human couldn’t win.