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

19 Likes

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

Here it is:

7 Likes

Hah, love the unicode usage. ^.^

2 Likes

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.

2 Likes

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

4 Likes

Just to compare black and white backgrounds in terminal:

1 Like

Added support for PGN loading.

To extract move list, Binbo takes into account various cases specific to PGN such as comments in braces , recursive annotation variations (RAVs) and numeric annotation glyphs (NAGs).

Nice :slight_smile:

But I see You use regex to parse PGN.

FWIW I have written a PGN parser in leex/yecc.

You are talking about parser, I’m talking about loading :slight_smile:
So, the problem is to extract moves and make them one by one

Well, once You have extracted all the moves, You can do whatever with :slight_smile:

I am using it to load PGN, extracts and validates moves. The parser is just a part of a bigger package…

1 Like

Okay, whatever :slight_smile:
But PGN is just a feature. I started this project not only to create a chess representation, but also to make it as performant as possible (thanks to Bitboards) since its mission to be running on game servers.

BTW, ChesLogic doesn’t recognize a draw by insufficient material, but Binbo does :slight_smile:

I will never let this situation happen… If we should solve this issue in front of a chess board, then either You or me, will resign before :slight_smile:

There are so many people who never resign, trust me :slight_smile:
Especially when playing bullet

BTW When I wrote this, i found that parsing with leex/yecc was more elegant than regex :slight_smile:

You needed a parser, You got that :slight_smile:
I don’t need a parser, I need to cut everything off except moves, I got that! :slight_smile:

Besides re module is much faster since it’s using C-lib (PCRE)

So we both got what we wanted. But the challenge is accepted. See You one day on Lichess :slight_smile:

See You later… Yeah! :slight_smile:
Lichess is great! :+1: