Solutions for a Dice Game

Mate Pocs
The Startup
Published in
16 min readFeb 6, 2020

--

Photo by Riho Kroll on Unsplash

Introduction

I love board games, and I love thinking about board games in mathematical frameworks. There, I said it. The distributions of random events, suboptimal steps, the relative strength of player vs engine as the game progresses in different co-operative games, etc, I could talk about these for hours. One of the most common mathematical features in tabletop games is the outcome of dice rolls. There are tons of games out there with random number generators of varying complexity that all run on your everyday, humble, 6-sided dice.

In this post we are going to formulate a problem around a simple dice game, and we are going to solve it in increasingly (over)complicated ways. I have heard about job interviews where this question came up, so we will start with a non-technical way of approaching the problem, briefly describe how it can be solved with a recursive function, and then dive into the world of reinforcement learning.

If you are familiar with the basic probability and programming aspects, or worked out this example before, I recommend that you skip Solutions 1 and 2, an head straight to Solution 3, where the reinforcement learning magic happens.

Please refer to my GitHub repository for the calculations and code, done in Python, organised in Jupyter Notebooks.

The Problem and the…

--

--