snakes_histogram


snakes_and_ladders_simulation, a Python code which simulates a one-player game of Snakes and Ladders, to produce histograms of the count, PDF and CDF estimates for the length of a one-player game.

Snakes and Ladders is a children's game played on a 10x10 numbered board. A player's turn consists of rolling a single die, and moving the indicated number of squares. If the final square is the foot of a ladder, the player moves up to a higher numbered square. If the final square is the mouth of a snake, the player moves downward.

For the one-player version of the game, it is interesting to pose the question of the probability that a particular game will take a certain number of moves.

By adding a square 0, where the player begins, the game board can be modeled as a vector of length 101, and the transitions from one square to another can be modeled by a transition matrix. Most commonly, the entries in row I will be zero except that columns I+1 through I+6 will have the value 1/6. However, rows which correspond to a snake or ladder, and rows for which I+6 is greater than 100, must be handled specially.

This program allows the user to specify the number N of games to simulate. It then creates histograms showing the count, PDF and CDF based on the observed data.

Licensing:

The computer code and data files made available on this web page are distributed under the MIT license

Languages:

snakes_and_ladders_simulation is available in a MATLAB version and an Octave version and a Python version.

Related Data and Programs:

python_simulation, a Python code which uses simulation to study card games, contests, and other processes which have a random element. Usually, the purpose is to try to predict the average behavior of the system over many trials.

Reference:

  1. Steve Althoen, Larry King, Kenneth Schilling,
    How long is a game of Snakes and Ladders?,
    The Mathematical Gazette,
    Volume 77, Number 478, March 1993, pages 71-76.
  2. Nick Berry,
    A Mathematical Analysis of Snakes and Ladders,
    https://www.datagenetics.com/blog/november12011/index.html

Source Code:


Last modified on 05 December 2022.