# The Energy Game

This is a game that can be played in pairs to explore how the Boltzmann distribution arises naturally from playing with dice and some simple rules. This is played as an introductory exercise of the ‘Molecular Driving Forces’ class imparted by Dr. Ian Gould at Imperial College London.

Consider a planar array of 36 atoms arranged in a 6x6 square. Suppose that each atom may accept one quanta of energy . The quanta of energy are moved around randomly using dice throws, and are represented by counters.

## Rules of the game

This is a two-person game:

- Counters are first placed on the board in any way that the players wish. It is usually convenient to use the 36 counters and to start with one on each square.
- The first player throws the two dice. The second player takes a counter off the board from the site given by the coordinates indicated by the two dice. If there is no counter on this square, repeat step 2.
- The first player throws the dice again and the second player puts the counter on the square indicated by the dice.
- After 5 throws a player draws a distribution diagram, showing the number of squares with 0, 1, 2, 3, … counters on them.
- The game continues with distributions diagrams being drawn after 15, 25 and 50 throws.

The objective of the game is to discover the pattern of distribution diagram after many throws. What would we expect the result to be if much larger numbers were used?

An extension of the game is to calculate:

After 2, 5, 15, 25 and 50 throws. is the total number of squares. etc. are the number of squares with no counters, one counter, two counters, etc. is the number of ways of distributing the counters on the board all having the same distribution diagram (also known as multiplicity). It is readily obtained as the number of ways of dividing objects into groups of objects.

Since playing this game can take quite some time, here is an implementation in Python.

Notice that we have added an attribute `start`

to the `EnergyGame`

class, whereby we can explore what happens if we decide to initialize the
board in two different ways, either with the quanta of energy spread uniformly across the board, or all stacked up onto one of the squares.

Now that we have the game ready, let’s play!

The game can be played by instantiating an object of the `EnergyGame`

class and calling the `visualize`

method on it:

Let’s use a plotting function that shows how the final distribution changes with the number of throws:

Here’s what it looks like for a `uniform`

starting board:

An exponential distribution is arising, even after only a handful of throws! This is the Boltzmann distribution since the entropy is being maximised under constraints:

And we see the same behaviour from a `skewed`

initial pose. It just takes longer to achieve because many of our trials are unsuccesful,
specially at the beggining, where our dice will keep pointing us towards squares that are empty.

You can download the game to reproduce the images here