In the game of craps1 the player (“shooter”) throws two six-sided dice. If the total is 2, 3 or 12, then the shooter loses. If the total is 7 or 11, then she wins. If the total is any other score, then that score becomes the new target, known as the “point”. Use the utility function two_6d() below to generate one single craps score and store it in the object score.

Write code that generates a craps score and assigns the following values to the objects game_status and point:

score game_status point
2, 3, 12 FALSE NA
7, 11 TRUE NA
4-6 or 8-10 NA Same as score

 

Hint: your code will probably span multiple lines but should use one control structure.

(from: Cotton, 2013, Learning R, O’Reilly)