2016-03-19 22:14:29 +01:00
|
|
|
# Simulations of Hanabi strategies
|
|
|
|
|
2016-03-30 07:24:29 +02:00
|
|
|
Hanabi is a cooperative card game of incomplete information.
|
|
|
|
Despite relatively [simple rules](https://boardgamegeek.com/article/10670613#10670613),
|
|
|
|
the space of Hanabi strategies is quite interesting.
|
2016-03-19 22:14:29 +01:00
|
|
|
|
2016-03-30 07:24:29 +02:00
|
|
|
This repository provides a framework for implementing Hanabi strategies.
|
|
|
|
It also explores some implementations, based on ideas from
|
|
|
|
[this paper](https://d0474d97-a-62cb3a1a-s-sites.googlegroups.com/site/rmgpgrwc/research-papers/Hanabi_final.pdf).
|
2016-03-19 22:14:29 +01:00
|
|
|
|
2016-03-30 07:24:29 +02:00
|
|
|
In particular, it contains a variant of their "information strategy", with some improvements.
|
2016-03-30 19:24:21 +02:00
|
|
|
This strategy achieves the best results I am aware of for n > 2 (see below).
|
2016-03-30 07:24:29 +02:00
|
|
|
|
|
|
|
Please contact me if:
|
|
|
|
- You know of other interesting/good strategy ideas!
|
2016-03-31 19:17:22 +02:00
|
|
|
- Have questions about the framework or existing strategies
|
2016-03-19 22:14:29 +01:00
|
|
|
|
2016-03-30 07:24:29 +02:00
|
|
|
Some similar projects I am aware of:
|
2016-03-19 22:14:29 +01:00
|
|
|
- https://github.com/rjtobin/HanSim (written for the paper mentioned above)
|
|
|
|
- https://github.com/Quuxplusone/Hanabi
|
|
|
|
|
|
|
|
## Setup
|
|
|
|
|
2016-04-01 11:08:46 +02:00
|
|
|
Install rust/rustc and cargo. Then,
|
2016-03-19 22:14:29 +01:00
|
|
|
|
|
|
|
`cargo run -- -h`
|
|
|
|
|
|
|
|
```
|
|
|
|
Usage: target/debug/rust_hanabi [options]
|
|
|
|
|
|
|
|
Options:
|
|
|
|
-l, --loglevel LOGLEVEL
|
2016-03-31 19:17:22 +02:00
|
|
|
Log level, one of 'trace', 'debug', 'info', 'warn',
|
|
|
|
and 'error'
|
2016-03-19 22:14:29 +01:00
|
|
|
-n, --ntrials NTRIALS
|
2016-03-31 19:17:22 +02:00
|
|
|
Number of games to simulate (default 1)
|
2016-03-19 22:14:29 +01:00
|
|
|
-t, --nthreads NTHREADS
|
2016-03-31 19:17:22 +02:00
|
|
|
Number of threads to use for simulation (default 1)
|
|
|
|
-s, --seed SEED Seed for PRNG (default random)
|
2016-03-19 22:14:29 +01:00
|
|
|
-p, --nplayers NPLAYERS
|
|
|
|
Number of players
|
2016-03-31 19:17:22 +02:00
|
|
|
-g, --strategy STRATEGY
|
|
|
|
Which strategy to use. One of 'random', 'cheat', and
|
|
|
|
'info'
|
2016-03-19 22:14:29 +01:00
|
|
|
-h, --help Print this help menu
|
|
|
|
```
|
|
|
|
|
|
|
|
For example,
|
|
|
|
|
2016-03-31 19:17:22 +02:00
|
|
|
```
|
2016-04-01 11:08:46 +02:00
|
|
|
cargo run -- -n 10000 -s 0 -p 5 -g cheat
|
2016-03-31 19:17:22 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
Or, if the simulation is slow (as the info strategy is),
|
|
|
|
|
|
|
|
```
|
2016-04-01 11:08:46 +02:00
|
|
|
time cargo run --release -- -n 10000 -o 1000 -s 0 -t 4 -p 5 -g info
|
|
|
|
```
|
|
|
|
|
|
|
|
Or, to see a transcript of a single game:
|
|
|
|
```
|
|
|
|
cargo run -- -s 2222 -p 5 -g info -l debug | less
|
2016-03-31 19:17:22 +02:00
|
|
|
```
|
2016-03-19 22:14:29 +01:00
|
|
|
|
2016-03-31 09:02:09 +02:00
|
|
|
## Results
|
2016-03-19 22:14:29 +01:00
|
|
|
|
2016-04-01 11:08:46 +02:00
|
|
|
On seeds 0-9999, we have:
|
|
|
|
|
|
|
|
| 2p | 3p | 4p | 5p |
|
|
|
|
----------|---------|---------|---------|---------|
|
|
|
|
cheating | 24.8600 | 24.9781 | 24.9715 | 24.9583 |
|
|
|
|
info | 18.5909 | 24.1655 | 24.7922 | 24.8784 |
|
2016-03-19 22:14:29 +01:00
|
|
|
|
|
|
|
|
2016-04-01 09:14:13 +02:00
|
|
|
To reproduce:
|
|
|
|
```
|
2016-04-01 11:08:46 +02:00
|
|
|
n=10000 # number of rounds to simulate
|
|
|
|
t=4 # number of threads
|
2016-04-01 09:14:13 +02:00
|
|
|
for strategy in info cheat; do
|
|
|
|
for p in $(seq 2 5); do
|
2016-04-01 11:08:46 +02:00
|
|
|
time cargo run --release -- -n $n -s 0 -t $t -p $p -g $strategy;
|
2016-04-01 09:14:13 +02:00
|
|
|
done
|
|
|
|
done
|
|
|
|
```
|