F. Discussion

Upon seeing user interest in quick games involving gambling, we decided to create a simple dice game that allowed users to essentially wager on the roll of dice. While it does not involve money as some identified users suggested, it does involve the short gameplay mentioned in user interviews while still implementing the basic gambling premise of guessing on a chance outcome.

An initial struggle in developing the code for this game was to create two randomly rolling dice and add their values together. However, we were able to use MATLAB’s “randi” function to randomly “roll” two dice that would output integer values between 1 and 6. Adding these values together then simply involved using MATLAB’s “sum” function.

One of the main issues discovered when developing this game was that the game could only be played once. To solve this problem, the game’s initial construct of a basic if-elseif-else statement was incorporated into a while loop. The variable “i” was set equal to 1, and a while loop was created to run as long as i was greater than or equal to 1. The user guess, dice rolls, and sum of dice rolls were turned into arrays, with the values stored at the index value corresponding to the pass of the while loop. After each guess, the user is then asked whether they would like to play again. If the user inputs that they would like to play again, the index variable “i” is incremented by 1, and the while loop repeats from the beginning. If the user does not want to play again, the while loop is broken, and the game ends. This allowed for quick and easy replay of the game, allowing users to play many times in a row.