Inspiration

As we spent our week off, we recognized that we had nothing to do, and after an extensive survey, we recognized that there are a lot of people on discord who also had nothing to do. Unfortunately, due to these trying times, we were unable to meet up physically to pass the time and catch up. Therefore, we decided to create a bot that would allow us to face off in an exciting game of Connect 4, in order to have fun while observing social distancing measures, so that we could stay safe.

What it does

The Connect 4 discord bot allows players to play a game of Connect 4 entirely within a discord channel with either a computer AI or a friend.

How we built it

We created a base connect 4 board and then used discord.py to let the player do moves on the board and to print the board onto discord channels. We also used a minimax algorithm for the connect 4 AI and Google Cloud to keep the bot running 24/7.

Challenges we ran into

One of the main issues we ran into was letting multiple games run in one channel; at first, we saved each instance of the game in a dictionary using the channel-id as the key. Later on, we realized each message has an id of its own, so we saved the message-id as the key instead, which fixed the issue very quickly. We also ran into issues when creating the minimax algorithms, such as functions not giving the right value, but we were able to fix them on time.

Accomplishments that we're proud of

We were able to create a discord bot with a functional connect 4 game plus an ai in just under 2 days. Although many of us go little to no sleep, it felt good seeing the bot work.

What we learned

We learned how to create a simple AI that uses trees and depth-first search; this was also many of us' first time using discord.py, so we learned a lot about how to create our own discord bot.

What's next for Discord Connect 4

We plan to implement an MMR system so that ranked matchmaking may occur to find the best Connect 4 player on discord. We also plan to add a settings command to customize the board size, and an accept or decline command to not force people to go into a game against others.

Built With

+ 3 more
Share this project:

Updates