hanabi game box

Hanabi simulator

I finally had some time to create a simulator for the game Hanabi. If you are not familiar with it, Hanabi is a simple game where you try to cooperatively build “fireworks”. There are various colors and cards numbered 1 through 5. The objective is to place the cards of the same color in ascending order. The twist is that you get to see everyone’s cards but your own. Each player, on their turn, can either discard, play or give information. The game involves a lot of deductive reasoning. You can play it for free online here or here.

When playing with friends (or strangers online), debates frequently happen about why a certain card was played or a clue was given. So I put my skills to good use and built a framework that allows for easy implementations of various strategies (like here or here) to see which ends up being the most successful.

Looking around on Github, there was not much in the way of a simulator that I liked. I found a gist that someone had done, and that became the baseline for my Hanabi simulator implementation. Though at this point I’m sure even the original author would have difficulty recognizing it.

The main focus is on player_*.cpp. Your algorithm goes in there, and all you have to do is edit the Makefile so that your binaries get compiled and you can run it.

You implement your algorithm in the turn() function. You can save state in other class variables. The info() callback is provided in the event that another player gives you a clue. Sometimes that may be a clue as to when a certain piece of information is given.

Take a look at the simulator that I wrote. Let me know what I should do differently. Implement your own algorithm. Send me a pull request!

Liked it? Take a second to support me on Patreon!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.