After Deepmind released their "Player of Games", I decided it would be a good Christmas project to make an AI for a game I've always loved: Liar's Dice (or Dudo).
I realized there was a really simple way to implement Counter Factual Regret Minimization (CFR) with a value neural network trained from self play.
It starts learning from completely random play, but after about a million games the model is close to the Nash Equilibrium. The pytorch model is converted to ONNX runs entirely in the browser.
Hey Thomas, very cool project! Fellow Dane here :-) I actually attempted to build the same thing for fun some years ago, but I must admit I failed to implement the counter factual algorithm correctly and gave up. (I'm a little embarressed to admit that I remember finding a very nice tutorial and even source code for it, but still not grokking it). If youre like me, you probably just really wanted to improve odds vs your friends at the local pub ;-) Anyways, keep up the good work Jens
Hi Jens! I also worked on it a few years ago, trying to solve the smaller cases using Linear Programming: https://github.com/thomasahle/snyd . These are the most common "one on one" cases I've encountered, since usually at pubs there are more than two players when the number of dice is large! :)
I also found the CFR papers really confusing for a long time. The papers have a lot of strange notation. But I think I finally got it, and it's very simple! I can write more about it, if I end up writing a blog post about this project.
5 comments
[ 2.5 ms ] story [ 29.2 ms ] threadThe code is on https://github.com/thomasahle/liars-dice . I will try to write a blog post about how it works later.
It starts learning from completely random play, but after about a million games the model is close to the Nash Equilibrium. The pytorch model is converted to ONNX runs entirely in the browser.
https://i.postimg.cc/85TPBKgC/Screenshot-20211224-153956.png
EDIT: Also had a game with only 3 dice?
https://i.postimg.cc/PJMCT9sG/image.png
For the second part, if you win a game, you lose a die. The goal is to get to zero!
I also found the CFR papers really confusing for a long time. The papers have a lot of strange notation. But I think I finally got it, and it's very simple! I can write more about it, if I end up writing a blog post about this project.