Binbo - chess representation written in Erlang using Bitboards

Hi all,

I found that there was no pure representation of Chess written in Erlang/OTP.

So, now I would like to announce my implementation… Binbo.

It’s available on Github:

Binbo is a Chess representation written in pure Erlang using Bitboards. It is basically aimed to be used on game servers where people play chess online.

It’s called Binbo because its ground is a binary board containing only zeros and ones (0 and 1) since this is the main meaning of Bitboards as an internal chessboard representation.

Binbo also uses the Magic Bitboards approach for a blazing fast move generation of sliding pieces (rook, bishop, and queen).

Note: it’s not a chess engine but it could be a good starting point for it. It can play the role of a core (regarding move generation and validation) for multiple chess engines running on distributed Erlang nodes, since Binbo is an OTP application itself.

Features:

  • Blazing fast move generation and validation.
  • No bottlenecks. Every game is an Erlang process (gen_server) with its own game state.
  • Ability to create as many concurrent games as many Erlang processes allowed in VM.
  • Unicode chess symbols support for the board visualization right in Erlang shell.
  • Ready for use on game servers.

Links.
Bitboards:
https://www.chessprogramming.org/Bitboards

Magic Bitboards:
https://www.chessprogramming.org/Magic_Bitboards

16 Likes

I forgot to add a sample image (how it looks like in Erlang shell).

Here it is:

6 Likes

Hah, love the unicode usage. ^.^

Nice job.

I tried it and couldn’t help but try en passant (since that is usually a rule people skip in their implementation), but you got that :+1: Castling is probably also implemented?

Binbo recognizes castling when:

  • White king moves from E1 to G1 ( O-O );
  • White king moves from E1 to C1 ( O-O-O );
  • Black king moves from E8 to G8 ( O-O );
  • Black king moves from E8 to C8 ( O-O-O ).

Binbo also checks whether castling allowed or not according to the chess rules.

Threefold repetition is the only event that Binbo does not detect yet.

All the other rules (including a draw due to insufficient material) are respected.

Threefold repetition is now detected.
So, all the chess rules are completely covered.

2 Likes

Just to compare black and white backgrounds in terminal: