Connect 4 Twitter Bot

- 3 mins

@BotConnectFour is a tool that emulates the board game Connect Four on Twitter.

I made it because I saw a screenshot of two people playing connect four with emojis, thought it would make a cute Twitter bot, and wanted to challenge myself to complete a project working with the Twitter API. Little did I know, I would learn to work with much more than the Twitter API in the process of completing this project, which I document here.


Overview


Bot Infrastructure

@BotConnectFour is written in Python, and makes use of the Tweepy, PyMongo, and Emoji libraries.

It is run from a Digital Ocean Ubuntu 16.04 droplet.

It stores game data in a Sandbox-tier MongoDB instance, hosted with mLab.

Visit @BotConnectFour’s Github repository to review the source code.


About Connect 4

Connect Four (also known as Captain’s Mistress, Four Up, Plot Four, Find Four, Four in a Row, Four in a Line and Gravitrips (in Soviet Union)) is a 20th century vertical strategy game. The earliest apparent version of the game, documented by Robbie Bell, is estimated to be Edwardian, produced c. 1901 - 1910, and is made out of Mahogany, with beech wooden game pieces.

The familiar, yellow plastic adaptation of the game was invented by Howard Wexler, and first sold under the trademark Connect Four in 1974. Currently the trademark is held by Hasbro, Inc.

The game consists of a 6 x 7 board design, with 2 sets of coloured tokens. On each turn, the active player places one token of their colour in one of the 7 vertical shoots. The objective of the game is to connect four tokens of your colour in a vertical, horizontal, or diagonal line before your opponent does.


How to Play

  1. START: mention @BotConnectFour in a new tweet, type the word “new” followed by a space, & then mention the user you want to play a game with.

  2. PLAY: on your turn (indicated by “UP!” beside your name), reply to the board with the number of the column you want to put your piece in.

  3. WIN: when you get 4 in a row!

Inactive games are deleted after 14 days.


Accessibility

@BotConnectFour accepts only Arabic numerals as player inputs.

Unfortunately, due to the highly visual game-play, @BotConnectFour is not accessible to Twitter users who rely on text-to-speech software.


Code of Conduct


License

@BotConnectFour’s software is licensed under the MIT License.

Cristyn Howard

Cristyn Howard

Software Developer. Dynamically-typed.

rss facebook twitter github gitlab youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora