C. Program Description for Developers

a)

The development of the code to run Mastermind was separated into multiple sections to create a complete program. First, variables were created to store the values of each different colored peg and pin that would be displayed on the user interface. Following this, the correct sequence of pegs was created with the random integer function to base all user inputs off of and the input function was used to allow the player to select their sequence of pegs. Both of these variables stored array values in order to demonstrate a sequence. The correct sequence was compared to 12 potential user inputs which was done by using if statements. The player sequence was displayed with an if statement and the display function. If a player selected a value that corresponded with the color of that value, then it was displayed on the board of the user interface in the order that was chosen. 

For each turn, if statements were used to determine when to display a black peg. Each index of the array of the correct sequence and the array of the user sequence were compared and if any of the indices matched, then the value of the variable used to store the black pegs was added to by 1 .

In order to calculate the amount of white pegs a nested for loop was needed along with an if statement. These ran through the correct sequence and the player sequence to check if any index value matched any other index value. If there was a match, the value of the variable for white pegs was added to by 1, but those particular indices of each sequence were reset to the value of 1. This ensured that similar colors between sequence would only be accounted for once. 

To complete the game, if statements were used to display the pegs on the user interface. The amount of black and white pegs displayed depended on the variable used to store the black peg count and the variable used to store the white peg count. Whatever the value was, that was how many of each colored pin was displayed for each turn.

The end of the game was determined by either the success of the player prior to the limit of turns or by the failure of the player to select the correct sequence before the limit of turns. If statements were used to determine this. If after any guesses the player sequence matched the correct sequence, “Player wins.” would be printed in the command window using the fprintf function whereas if the player exceeded the amount of turns given, “Player loses.” would be printed in the command window using the fprintf function.

 

b)

my_scene – Creates the beginning scene that mastermind is played on.

 

empty_sprite – Holds the sprite that creates an empty box on the user interface.

 

white_peg_sprite – Stored the data that was used to display a white pin on the board of the user interface.

 

black_peg_sprite – Stored the data that was used to display a black pin on the board of the user interface.

 

blue_sprite – Stored the data that was used to display a blue peg on the board of the user interface.

 

green_sprite – Stored the data that was used to display a green peg on the board of the user interface.

 

orange_sprite – Stored the data that was used to display an orange peg on the board of the user interface.

 

pink_sprite – Stored the data that was used to display a pink peg on the board of the user interface.

 

purple_sprite – Stored the data that was used to display a purple peg on the board of the user interface.

 

red_sprite – Stored the data that was used to display a red peg on the board of the user interface.

 

turquoise_sprite – Stored the data that was used to display a turquoise peg on the board of the user interface.

 

yellow_sprite – Stored the data that was used to display a yellow peg on the board of the user interface.

 

separator_sprite – Data that is used to create a white column separating the pegs and the pins on the game board.

 

pegs – Variable used to store each color of peg as an integer.

 

answer – The array that stores the correct sequence of pegs that is compared to each player sequence.

 

player_seq1 – Variable that contains the the players peg guess on the first position of the board.

 

player_seq2 – Variable that contains the the players peg guess on the second position of the board.

 

player_seq3 – Variable that contains the the players peg guess on the third position of the board.

 

player_seq4 – Variable that contains the the players peg guess on the third position of the board.

 

black – Variable that stores how many pegs in the same position from both the player sequence and the correct sequence match. 

 

white – Variable that stores how many pegs from both the player sequence and the correct sequence match. 

 

c)

my_scene – Creates the beginning scene that Mastermind is played on.

 

board_display –  A matrix of numbers that correlate to the different sprites.

 

drawScene – Updates the scene after each guess.

 

e)

Box, https://osu.app.box.com/s/3l9u97bhp673lh3e1coyx8t6tjjxlp9y.

Box, https://osu.app.box.com/s/758htgbd1uuruzhjdp4emn3clkcqobe0.

“Mastermind.docx: Powered By Box.” Mastermind.docx | Powered By Box, https://app.box.com/embed/s/aogpr9yuvu85zb88fmht4i7tc551s94c?view=list&sortColumn=name&sortDirection=ASC&showItemFeedActions=true&showParentPath=true.