craps_simulation, an Octave code which simulates the gambling game of craps, in which a player rolls two dice. On the first roll, the player wins immediately if a 7 or 11 is rolled, and loses immediately if a 2, 3 or 12 is rolled. Otherwise, the sum of the dice on this first roll is called the point. The player now continues to roll the dice, winning if the point is rolled again, and losing if a 7 is rolled.


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


craps_simulation is available in a MATLAB version and an Octave version and a Pythonn.

Related Data and codes:

octave_simulation, an Octave 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.


  1. Ian Stewart,
    The Lore and Lure of Dice,
    Scientific American,
    Volume 277, Number 5, November 1997, pages 110-113.

Source Code:

Last revised on 13 November 2022.