othello

Project image

CLI implementation of the board game Othello

About the project:

Othello is a command line implementation of the popular board game Othello (also known as Reversi).

Othello has a lot of cool features, as it can be played with one or two players via the command line. In addition, players can customize colors and names to make the game more personal.

However, the coolest part of othello is the AI. There are four AI players of increasing difficulty: Euclid, Lovelace, Dijkstra, and Turing. The smartest of the four AI players, Turing, utilizes game theory techniques to calculate the most optimal move at any given point.


Technology used:

Python

View on GitHub

Demo

othello is a command line implementation of the popular game Othello, which is also known as Reversi.

Simple game, complex theory

Othello's premise is very simple: take turns adding pieces to the board, and if your piece 'wraps' an enemy's piece, flip it to your color. However, the game's theory is quite complex, because often the winner of the game is only decided in the last few moves.

othello can be played with either two players versus each other or one versus the AI player.

A case study in game theory

othello's AI adversaries (Euclid, Lovelace, Dijkstra, and Turing), which are named after famous computer scientists, use knowledge of the game's theory to try to win the game. The most challenge of the AI players, Turing, uses concepts like mobility to dominate most players.

Playing the game

Start a new game with:

$ python3 othello.py

Which will draw a board on the terminal:

Welcome to Othello!
Player 1 vs. Player 2

1 2 3 4 5 6 7 8
A - - - - - - - -
B - - - - - - - -
C - - - - - - - -
D - - - * * - - -
E - - - * * - - -
F - - - - - - - -
G - - - - - - - -
H - - - - - - - -
Player 1, where do you want to move?

The available commands in-game can be show by typing help:

====Command list====
B6 -> attempts to place new tile on location B6
show -> redraws the current board
where -> shows possible moves for the current player (you can also use 'hint' or 'where can I go?')
help -> shows this menu and list of commands (you can also use 'command' or 'commands')
clear -> clears the screen
score -> show how many tiles each player has (you can also use 'who's winning?')
color -> changes the current player's color
exit -> ends the game (you can also use 'done')

othello's coolest feature, its AI players, can be played by specifying them by name:

$ python3 othello.py --adversary Turing
So, you'd like to challenge Turing? (Y/N) y
What is your name? Will
Okay, so your name is Will? (Y/N) y
Okay, what is your color? You can pick from grey, red, green, yellow, blue, pink, teal, or white: red
Okay so your color is red? (Y/N) y

Welcome to Othello!
Will vs. Turing
Turing says: My bombes will win this game in no time!

1 2 3 4 5 6 7 8
A - - - - - - - -
B - - - - - - - -
C - - - - - - - -
D - - - * * - - -
E - - - * * - - -
F - - - - - - - -
G - - - - - - - -
H - - - - - - - -
Will, where do you want to move?

You can also watch a game between two AI players with the --spectate option.

$ python3 othello.py --spectate