My home baked Othello Bot. It is decent.

Overview

Othellotron

PRs Welcome

My home baked Othello Bot. It is decent.

Table of Contents

Setup

First step is to download Cargo.

Second step is to clone the GitHub repository:

git clone https://github.com/L0ad1n6/Othellotron

Last step is to compile and run

cd Othellotron

cargo run --release

NOTE: If you are on MacOS or Linux you can use the binary in the latest release. Future releases will have more supported platforms.

How do I play?

    A   B   C   D   E   F   G   H
  +---+---+---+---+---+---+---+---+
8 |   |   |   |   |   |   |   |   |
  +---+---+---+---+---+---+---+---+
7 |   |   |   |   |   |   |   |   |
  +---+---+---+---+---+---+---+---+
6 |   |   |   |   | X |   |   |   |
  +---+---+---+---+---+---+---+---+
5 |   |   |   | W | B | X |   |   |
  +---+---+---+---+---+---+---+---+
4 |   |   | X | B | W |   |   |   |
  +---+---+---+---+---+---+---+---+
3 |   |   |   | X |   |   |   |   |
  +---+---+---+---+---+---+---+---+
2 |   |   |   |   |   |   |   |   |
  +---+---+---+---+---+---+---+---+
1 |   |   |   |   |   |   |   |   |
  +---+---+---+---+---+---+---+---+

Note the board above is not colored but printed board is.

W = White Pieces, B = Black Pieces, X = Valid moves for current player

To play enter the row when you are prompted with:

Enter Row (Number):

And enter the letter of the column when you are prompted with:

Enter Column (Letter):

If move is invalid, you will restart the process until you enter a valid move.

Unfortunately if you accidentally miss-type something, the program will panic and the game will be lost. This will not be an issue in future versions (Hopefully).

Example of panicking move:

Enter Row (Number): 2a

How does it play?

The observant player might wonder, but how does a computer even play othello.

The computer uses a variety of techniques to search and find good moves.

  1. The bot generates all moves for the current board state
  2. The bot iterates over the array of moves:
    • playing the move
    • generating all moves for new state
    • un-playing the move
  3. Step 2 continues until a certain depth is reached
  4. All states at the base of the game tree are evaluated
  5. The value of the states is propagated back to the root
  6. The moves are sorted by the best state that they can lead to
  7. The best move is chosen and played on the board

This is a simple overview of what the bot does every round. Some of the techniques that have been used to execute and optimize this process are listed down below.

Minimax

Defined as the smallest set of maximum possible losses, minimax is what was used to find moves that minimize the damage that the opponent can do.

Alpha-Beta Pruning

Alpha-Beta pruning is an optimization for Minimax, if a node presents itself to be better for the opponent than what we have already searched then the branch can be pruned as it is no longer an option.

Iterative Deepening - Coming Soon

Iterative deepening is a good solution to the problem of finding what depth to search to. Instead of searching to a fixed depth, the process of iterative deepening incrementally increases the depth. When time runs out you can take the results from the last completed search. Typically iterative deepening is faster then searching to a depth of "N" as you can use the results of each previous search to order the moves that are searched to increase the number of moves that are pruned.

Project Structure

Name Description
Cargo.toml Has all crate dependencies and crate information
Cargo.lock File generated from Cargo.toml
LICENSE Holds license for crate
.gitignore Standard gitignore file to prevent unwanted files form being committed
src/main.rs Entry point to crate
src/human.rs Contains code for all human related operations
src/game Contains code to run the game of othello
src/bot Contains code for all bot actions
src/bot/moves Contains the code for move related operations

Future Ideas

This project is far from perfect. There is lots of room for improvement as its play style is decent at best. In the future I hope to implement these optimizations to improve the performance of the bot:

  • Iterative Deepening
  • Pruned position search while generating moves
  • Transposition table for looking up board states that have been evaluated during search
  • Cache for slow functions: generate moves, evaluate (Transposition Table)
  • Improve UI/UX. Possible solutions:
    • writing custom user input function with standard library,
    • Making a webpage *that hosts on local host to play the game more interactively
  • Trying Monte-Carlo Tree Search
  • Optimize constants and factors in evaluation function
  • Potentially switch board data structure to bitmaps
  • Multi Threading!

License

Licensed under the MIT License

Copyright (c) 2022 Altan Mehmet Ünver (L0ad1n6)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You might also like...
Just a bot for Neovim's Matrix room(s)

nvim-matrix-bot Currently just supports replying to messages with :h some_doc or similar in them with a link to the docs on Neovim's website. Plan i

Music bot written in Rust

Akasuki What is Akasuki? Akasuki is a simple discord music bot written in rust. Highlights Select your music using discord's new select menu feature,

A Discord bot for sending GeoGuessr challenge links that uses the GeoGuessr API written in rust.

GeoGuessr-bot-rs This is a simple implementation of a discord bot that send GeoGuessr-challenge links on demand. Features: Slash-commands Lightning-fa

🦴🤖 // A Discord bot about collecting all the Borpa

🦴 🤖 Borpa Bot Borpa Bot is a Discord bot about collecting all the Borpa possible. If you dont know what a Borpa is you can find it here Crate Descri

A scriptable discord bot (WIP)

Status This project is currently a VERY EARLY WORK IN PROGRESS. Contact me on discord for more details: Jonas747#0001 (105487308693757952) BotLoader (

🦜 A hassle-free, highly performant, host it yourself Discord music bot built with Serenity in Rust. Powered by youtube-dl and Genius.

🦜 A hassle-free, highly performant and fast evolving Discord music bot built with Serenity in Rust. Deployment Usage Just create a bot account, copy

The best discord bot to annoy @a3mat
The best discord bot to annoy @a3mat

A3mat v pomoyke The best discord bot to annoy @a3mat Usage: This command moves pinged users n times: move number [users...] This command moves ping

Telegram bot that zhuzh Twitter content
Telegram bot that zhuzh Twitter content

@twt_2_tg_bot Telegram bot that zhuzh shared Twitter content Text converter Some tweets may contain line breaks or even dialogs. Such tweets are barel

A Discord bot to send updates on queries in tori.fi

torimies-rs How the bot works? The bot works by making requests to the undocumented (and very bad) tori.fi api endpoint. The users can add and remove

Releases(v1.0.1)
Owner
Altan Mehmet Ünver
Backend developer experimenting with frontend.
Altan Mehmet Ünver
Rewrite of the Discord Bot used for Managing the Infinity Bot List Servers.

Arcadia Rewrite of the Discord Bot used for Managing the Infinity Bot List Servers. Contributing Always run fmt.sh before making a Pull Request! MacOS

InfinityBotList 3 Dec 15, 2022
A simple bot for discord.

Rusky Um simples bot para o discord! ?? Executando ⚠️ Antes de tudo você precisa do Rust Instalado você pode instalar clicando aqui Preparando Primeir

Rusky 3 Aug 12, 2022
A Simple, But amazing telegram bot, Made using the Rust language!

Telegram bot in Rust A fun Telegram bot made using Rust language.

Deep Alchemy 2 Dec 21, 2021
This is a Telegram bot I'm working on in my free time to learn Rust.

Maldness Bot This is a Telegram bot I'm working on in my free time to learn Rust. Building docker build -t . should be enough.

Sergey Kislyakov 10 May 13, 2022
Play Onitama in your browser, compete with friends or lose to a bot

Play Onitama in your browser, compete with friends or lose to a bot

Jack Adamson 52 Nov 12, 2022
A Discord bot for lichess and Rosen related things

liro Liro is a Discord bot that follows in the footsteps of Lichess-discord-bot, without necessarily aiming to replace it. The main pain point that th

Sebastian Lauwers 5 Feb 16, 2022
This is a simple Telegram bot with interface to Firefly III to process and store simple transactions.

Firefly Telegram Bot Fireflies are free, so beautiful. (Les lucioles sont libres, donc belles.) ― Charles de Leusse, Les Contes de la nuit This is a s

null 13 Dec 14, 2022
Hi I'm Sophy, a discord bot in devlopment, soon I'll be available to help everyone (❁´◡`❁)

Sophy Bot Hi I'm Sophy, a discord bot in devlopment, soon I'll be available to help everyone (❁´◡`❁) Contribution Do you like me and want to help me?

Far Dragi 0 May 30, 2022
Telegram Bot Template with Cloudflare Workers

cf-workers-telegram-bot-template Usage This template starts you off with a src/lib.rs file, acting as an entrypoint for requests hitting your Worker.

Lee Taehoon 2 Sep 23, 2021
Rust telegram bot library for many runtimes

Telbot Telbot provides telegram bot types and api wrappers. Specifically, telbot now supports: telbot-types: basic telegram types / requests / respons

kiwiyou 17 Dec 3, 2022