III. Craps

There are a few main components used to program this game. Loops are utilized heavily throughout, with conditional statements embedded to sort out the route determined by the dice rolls. These conditions are used to decide whether the player won, lost, or needs to roll again. The whole program is also a loop itself, allowing the user to play multiple rounds if desired. The user makes decisions throughout the game that satisfy conditions and lead the program through another path. There are also conditional statements set in to keep the game fair. If a bet placed is not within legal bounds, the user is prompted to change their bet to a valid value.

There are also a few components used to create the dice rolls. The “randi” function in Matlab is utilized to determine a roll’s value from a range of 2-12. To present figures to show the dice after each roll, a custom script file (“Dice.mat”) is downloaded and saved to Matlab to be called upon in the Craps program. Using the command “imshow”, figures appear after each roll that show the dice.