Inspiration
Both of us are really interested in AI, and how it works in general, and recently, we heard about the use of the minimax algorithm to make an AI for simple games. So we were interested in making an AI for one of the main games of our childhood.
What it does
The minimax algorithm looks at every combination that the AI player and human player can do, and it assumes that each player is trying to maximize their score. A player's score increases if it gets four in a row, so the AI player will try to take a path down the tree structure that will not lead to the human player getting four in a row, and it also tries to take a path where its own score will increase.
How we built it
We built it using android studio and Java.
Challenges we ran into
At first, our algorithm was really slow, because we were going through every possible combination of moves that could happen in the future and analyzing the final outcome and how beneficial that situation was to the AI.
Accomplishments that we're proud of
What we learned
We learned how to use bit manipulation since we had to use that to work with the data in each game state. Using ints and bytes to work with all the data was taking up too much memory, as our algorithm is recursive.
What's next for Connect Four with MiniMax
We need to work on fine-tuning the AI as it does not always play the most optimal move. We also might need to fix our static evaluation method, which assigns a game board a certain value depending on who the board is favorable for. The gameboard will have a large negative number if the AI player already has a lot of pieces in a row.
Log in or sign up for Devpost to join the conversation.