Shipped this project!
I created a simple Tic-Tac-Toe game with an AI
I know it seems simple, but in actuality, its quite beautifully complex.
The basis of the project is a Tic-Tac-Toe game with an AI (easy, medium, and hard), and a resizable board (3x3 to 6x6).
The complexity of this project comes from the AI, which uses the minimax algorithm. Normally, on a 3x3 board, this wouldn’t be much of a hassle, however the complexity grows as the number of spaces grow exponentially.
While the minimax algorithm is quite fast, making it solve a 6x6 board allows for (6*6)! possibilities (approximately 3.7 followed by 40 zeros). As a result of this, I had to implement some limitations that allow for moves to happen in >1.5s, but the cost of intelligence (hence, no ‘impossible’ difficulty), until then, the ‘hard’ bot can fail to even see immediate losing moves.
-
Alpha-Beta Pruning. Basically, instead of solving every possibility, it stops whenever a possibility branch contains an un-optimal position (losing position), perfering optimal routes.
-
General Tendency of the center. I mean, ig that’s where most of the stuff happen for boards >3x3.
-
A time limit. Kinda self-explanatory, really bad for ‘smartness’.
Overall, I think I really understood a lot about how different game AIs work. One thing I really found interesting while making this project is the calculus, which I found quite elegant for its purpose.