MIPS PROGRAMMING
This homework requires students to create a MIPs program to simulate playing multiple games of "Craps" (a popular casino game) to determine an approximate winning percentage. : To simulate throwing two independent dice, you need to get two random numbers in the range of 1 to 6 and add them together. Do not get a single random number in the range of 2 to 12, as each value will not reflect the odds of rolling a particular numbe
PROBLEM STATEMENT: Using the rules of craps, for a given amount of simulated games, determine the probability of a player winning an individual game.
ASSUMPTIONS: (a) Two dice that can be randomly “thrown”, each producing a value from 1 to 6. (b) Rules for playing one game of craps: First roll (“Come Out”): If combined value of dice is 7 or 11, the player wins and game is over If combined value of dice is 2, 3 or 12 the player loses and the game is over If not a win or loss, the value of the dice becomes the “point” value. Keep rolling the pair of dice until their combined value matches the “point” (win; game over) or a 7 (loss, game over)
INPUT: The number of games to be played to be entered (must be >= 1)
OUTPUT: Average percentage (whole number) that the player wins an individual games of craps
TEST PLAN (Inputs, expected results)
NOTE: Consider trying these values for a single game and assign come-out value to defined values without random numbers to test your program.
1. Test 1.1 7 or 11 (player wins)
2. Test 1.2 2, 3, or 12 (player loses)
3. Test 1.3 4, 5, 6, 8, 9, or 10 (player neither wins or loses – continue rolling) Test 1.3a rolls a 7 (player loses) Test 1.3b roll matches come-out roll (“point” value)
ALGORITHM (Pseudo-code)
1. Prompt and get the number of games to simulate (error if <=0)
2. Set total number of wins to 0.
3. Repeat the following for the number of games to simulate
a. Calculate roll of two dice (store as point-value)
b. IF roll is 7 or 11 THEN Increment number of wins; end this game ELSE IF 4, 5, 6, 8, 9, or 10 THEN Repeat until player wins or loses this game Calculate new roll of two dice IF roll = point-value THEN increment number of wins; end this game ELSE IF roll=7 THEN player loses; end this game
4. Calculate and output the percentage of wins (wins / games played)