Inspiration

We wanted to create some kind of artificial intelligence.  After playing around with several ideas, we decided we wanted to do some kind of fun game that could be won by logical constructs.  After thinking through a few examples, we landed on connect-four! It's a fun project we would both be interested in.

What it does

When you run main.py, it will ask you how many players are playing and their names.  To make them AI, name them 'AI 1', 'AI 2', etc.  Then it goes turn by turn filling in pieces like in the real game until someone wins! See if that will be you!

How we built it

Lindsay focused mostly on the underlying logic of the AI while Greg made the front-end and graphics! We talked about what choosing the best column to put a piece into would depend on and what we wanted it to look like, then got to work! Running into problems and integration we conferred to find the best solution.  We researched things we didn't know how to do and broke problems into small pieces to be checked individually.  

Challenges we ran into

At first, we had our 2-D arrays organized in different ways, so for one (0,0) was in the top left and for the other in the bottom left.  After talking about what would be the smoothest end option, we decided to just do bottom left and go column then row.  Along the way we would realize different optimizations or returns that would make the code run much better and then have to go back and change those things.  In addition, the AI had to check for adding pieces to both the left and the right and see if this had the potential to lead to a win.  The edge cases led to some complications, though all ended up getting resolved.  In addition, the AI had to check to see if when it placed a piece in a column it would go into the row it wanted it in.  This was resolved, but will likely lead to complications in a multi turn strategy.

Accomplishments that we're proud of

The graphics look awesome, and it's a functional game against a strategic AI and any other player! The AI checks which lengths of pieces already exist and if a line of four can be created. Everything is color-coded and smooth. In addition, you can play local internet multiplayer! Play with friends from different computers.

What we learned

We learned how to work together, and got more practice working efficiently under a time limit.  We had great communication and got practice with python graphics.

What's next for connect-four

Right now the AI finds the best place to put a piece one move at a time.  However, it can't see past one move, so in helping itself get a longer line it may set the other player up for a win.  Multi turn strategy implementation is next.  We are also hoping to create a website for the local internet multiplayer to be integrated onto.  These things are very doable, and we're excited for the future

Built With

Share this project:

Updates