Inspiration
I always wanted to work with the pygames library but had never gotten around to it. Likewise, I had always wanted to experiment with AI, but hadn't gotten around to that either. So I figured why not kill two birds with one stone?
What it does
This game utilizes the pygames library to build a Connect Four gameboard. There is the option to play with 2 players, but that's not all. There is also a computer to play against, with 3 different difficulty levels.
How we built it
I built this using Python and the pygames library. I used an array (list) to represent the gameboard, and created many functions to manage the game. For the AI, I changed the difficulty by changing how many moves ahead it could look. The AI would look at every one of your possible moves after every one of it's possible moves to determine what was the best. On the hardest difficulty, it looks 4 possible moves ahead and is extremely difficult to beat. The game is a constant loop that stops when someone wins, or the board is filled.
Challenges we ran into
I had challenges with the AI aspect of this problem. Having never taken any courses on AI before, I self-taught the basics, which was difficult on its own. Then I initially tried just creating functions independent of any class to effectively perform the job of looking ahead at possible moves. Eventually, I discovered it was far simpler to just create an AI class, and contain all of the necessary AI functions within that class.
Accomplishments that we're proud of
I'm proud of not only making the game work but making it look relatively nice as well. I am also proud that I was able to not just get introduced to two new topics, but turn them into a fleshed-out project.
What we learned
I learned a lot about AI, specifically the thought process that goes behind creating something that is supposed to emulate a human mind. Furthermore, to put it simply I learned that the pygames library is awesome. It contains so many helpful features that are specific to creating a game (obviously). Given that this was the first time I have made a game like this, I am glad to know these libraries are available to me.
What's next for AI Connect Four
I would very much like to make this even more fully fleshed out. I think the next step is making this game into an IOS app. Making an IOS app is something else that I have wanted to do, and now I feel I have the perfect code to test it on.
Log in or sign up for Devpost to join the conversation.