Sample output (highlighted text indicates user input): Welcome to the game of HorseDiceCipher! Please enter in your name player one: Scooby Please enter a seed value: 86578 Please enter the sides of...


Sample output (highlighted text indicates user input): Welcome to the game of HorseDiceCipher! Please enter in your name player one: Scooby Please enter a seed value: 86578 Please enter the sides of the dice to use: 3x3x3 Please enter a word to use for the game: tacocat Please enter a key to use for the game: dogZ ---------------------------------------------------- The game of HorseDiceCiper is beginning now! Round 1 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 7 Scooby has rolled all three dice... their sum is 4 Computer has rolled all three dice... their sum is 7 Scooby's word is currently t Computer's word is currently Round 2 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 3 Scooby has rolled all three dice... their sum is 6 Computer has rolled all three dice... their sum is 6 Scooby's word is currently Computer's word is currently Round 3 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 8 Scooby has rolled all three dice... their sum is 8 Computer has rolled all three dice... their sum is 7 Scooby's word is currently Computer's word is currently t Round 4 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 7 Scooby has rolled all three dice... their sum is 6 Computer has rolled all three dice... their sum is 6 Scooby's word is currently Computer's word is currently t Round 5 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 7 Scooby has rolled all three dice... their sum is 6 Computer has rolled all three dice... their sum is 4 Scooby's word is currently Computer's word is currently ta Round 6 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 7 Scooby has rolled all three dice... their sum is 5 Computer has rolled all three dice... their sum is 7 Scooby's word is currently t Computer's word is currently ta Round 7 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 6 Scooby has rolled all three dice... their sum is 8 Computer has rolled all three dice... their sum is 5 Scooby's word is currently Computer's word is currently tac Round 8 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 5 Scooby has rolled all three dice... their sum is 5 Computer has rolled all three dice... their sum is 6 Scooby's word is currently t Computer's word is currently ta Round 9 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 5 Scooby has rolled all three dice... their sum is 5 Computer has rolled all three dice... their sum is 6 Scooby's word is currently ta Computer's word is currently t Round 10 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 5 Scooby has rolled all three dice... their sum is 5 Computer has rolled all three dice... their sum is 7 Scooby's word is currently tac Computer's word is currently Round 11 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 8 Scooby has rolled all three dice... their sum is 5 Computer has rolled all three dice... their sum is 7 Scooby's word is currently taco Computer's word is currently Round 12 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 3 Scooby has rolled all three dice... their sum is 5 Computer has rolled all three dice... their sum is 7 Scooby's word is currently taco Computer's word is currently Round 13 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 5 Scooby has rolled all three dice... their sum is 7 Computer has rolled all three dice... their sum is 9 Scooby's word is currently taco Computer's word is currently Round 14 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 9 Scooby has rolled all three dice... their sum is 8 Computer has rolled all three dice... their sum is 5 Scooby's word is currently taco Computer's word is currently t Round 15 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 8 Scooby has rolled all three dice... their sum is 5 Computer has rolled all three dice... their sum is 6 Scooby's word is currently tacoc Computer's word is currently t Round 16 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 5 Scooby has rolled all three dice... their sum is 6 Computer has rolled all three dice... their sum is 8 Scooby's word is currently tacoc Computer's word is currently Round 17 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 6 Scooby has rolled all three dice... their sum is 4 Computer has rolled all three dice... their sum is 6 Scooby's word is currently tacoca Computer's word is currently Round 18 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 6 Scooby has rolled all three dice... their sum is 9 Computer has rolled all three dice... their sum is 7 Scooby's word is currently tacoc Computer's word is currently Round 19 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 5 Scooby has rolled all three dice... their sum is 7 Computer has rolled all three dice... their sum is 8 Scooby's word is currently tacoc Computer's word is currently Round 20 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 8 Scooby has rolled all three dice... their sum is 5 Computer has rolled all three dice... their sum is 8 Scooby's word is currently tacoca Computer's word is currently Round 21 of dice rolls is starting now! Mediator has rolled all three dice... their sum is 9 Scooby has rolled all three dice... their sum is 5 Computer has rolled all three dice... their sum is 6 Scooby's word is currently tacocat Computer's word is currently Scooby has lost the game...their word will now be ciphered! New key is being created to match the length of the word... Updated key is now dogZdog Scooby's original word was tacocat Scooby's encrypted word is now woimfoz Overview: In this project, you will write a C program that reinforces programming fundamentals such as control flow, functions, expressions, and random number generation utilizing rand(…)/srand(…). The rand() function is a random number generator in C that returns a value in a specified range from [0, max] where the value returned is based off a seed value that is input into srand() which determines the pseudo-random numbers generated. Restrictions: You may only import stdio.h, stdlib.h and string.h You may not use any global variables. Premise: On your latest visit to the local library, you checked out a book titled “The Ancient History of the iCumulus people”. As you read through the book, you came across the chapter titled “HorseDiceCipher” which piqued your interest. As you read the chapter, you learned about the mysterious HorseDiceCipher game that the people of iCumulus played back in their time. Wanting to learn more about such a game, you visited the nearby history museum and spoke with the museum curator to inquire more about the history of the mysterious game that was played. Unfortunately, the curator did not know much, and asked you to implement a variant of the game that was played back in the day so that he could learn and research more about the HorseDiceCipher game and the iCumulus people. Summary of HorseDiceCipher: The game of HorseDiceCipher is played with three players where one player acts as a mediator and the other two are participants of the game. A player choses a word and a key to use within the game and the number of sides to each of the three sided dice. After, the mediator rolls the three dice where then the two players each throw the three dice. Whichever players sum of their dice roll is less than the number rolled by the mediator, they accumulate a letter of the chosen word where they have the opportunity to not gain a character towards their word if they roll high enough. The game repeats until whichever player accumulates enough letters that equal the chosen word. Afterwards, the losing players word then gets ciphered and the game ends. HorseDiceCipher Rules: • HorseDiceCipher is a three player game where player one will be the human player (you), the second player being the computer (a naïve AI), and the third player being the mediator (also a naïve AI). • When the game first starts, a welcome message is displayed to all players where player one is asked to enter their name to be used within the game. o The name that the player enters must at least be two characters and no longer than 8 characters. The name must not contain any numerical characters. o If at least one of these conditions are not satisfied, then the player must be prompted again until their name satisfies the criteria specified. • Next, player one is asked to enter a seed value which determines the pseudo-random numbers generated. The seed entered must at least be 1 character and no longer than 6 characters long where the values of the seed range in between [1, 999999]. Additionally, the seed value must only contain numerical digits. o If at least one of these conditions are not satisfied, then the player must be prompted again to enter a valid seed until they do so. o Once a valid seed is entered, this seed value is passed to the srand() function only once. • Next, player one is asked to enter the sides of each of the three dice that will be used. o A valid input for this prompt follow the format ##x##x## where the user can enter two digits or a single digit for each of the sides of three dice where the values entered must range in between [1, 11]. ▪ If either of the sides of the dices specified are not within the valid range, then user must be prompted again until they enter in a valid prompt. o Valid sample inputs for the three sides of the dice are as follows: “6x6x6”, “3x6x5”, “10x5x5”, “10 x 3 x 4”, “1 0x9x6” ▪ There may be any number of whitespace in between the characters which you need to handle accordingly when determining the sides of each of three dice • Next, player one is asked to choose a word to use within the game that they will play towards. o The word entered in must be at most 7 characters and must only contain alphabetical characters. If this condition is not satisfied, then the player must be prompted again until the word chosen satisfies the criteria specified. • Next, player one is asked to enter a key to be used within the game at the end once a losing player is determined. o The key entered in must be at least 1 character long, must not be longer than the length of the word chosen earlier and must only contain alphabetical characters. o If either condition is not satisfied, then the player must be prompted again until the key chosen satisfies the criteria specified. • Afterwards, the game begins where the mediator rolls the three dice with the specified sides chosen earlier. o The sum of the three dice rolls by the mediator serves as the number that player one and two have to get closest to with each of their dice rolls. o After the mediator rolls, player one starts off by rolling the dice, and then player two rolls the dice. ▪ Whichever players sum of their dice rolls is less than the other players, then that player gains a character of the chosen word towards their total word count. ▪ If either players sum of their rolls is greater than the rolls of the mediator, then that player has a character of the word removed from their total word count if they have any characters to their total. o The game repeats until a loser is chosen where the loser is decided when their accumulated characters (i.e. their word) equals the chosen word. o On each round: ▪ Display the current round starting from round 1 ▪ Display the sum of dice rolls of the mediator, player one and player two. ▪ Display the accumulated word for each player at the end of each round ▪ Once a losing player is chosen, display which player lost and then subsequently display their ciphered word using a cipher involving the chosen key. • The game ends afterwards. Required functions (in addition to main): Choose the appropriate parameters for each of the following functions: void cipher(…) A Vigenère Cipher is used by this function to encrypt the losing players word, working as follows: A modified alphabet is utilized which contains lowercase characters from a-z and the whitespace character at the end (27 characters total in the modified alphabet) alphabet a b c d e f g h i j k l m n o p q r s t u v w x y z index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Before any ciphering can be done, the key that will be utilized must be the same length as the losing players word. This must be done by calling update_key(…). Once the key has been updated (if it needs to be), for each character within the losing players word, the shift amount is determined by using each character at each index of the updated key and at each index of the losing players word to the index within the alphabet and then performing an addition between the two indices to determine the shift amount for the character in the losing players word. In some instances, the shift amount may be larger than or equal the length of the alphabet. In such instances, you need to wrap the shift amount around to be within the bounds of the alphabet (i.e. rotating the shift around by the length of the alphabet) For example, assume the losing players word is tacocat and the key is dogZ with the updated key being dogZdog. The following table displays the logic that the cipher follows: word t a c o c a t key d o g Z d o g word index 19 0 2 14 2 0 19 key index 3 14 6 25 3 14 6 shift amount 22 14 8 39 5 14 25 out of bounds? no no no yes no no no actual shift 22 14 8 12 5 14 25 encrypted word w o i m f o z The word and/or the key may contain uppercase alphabetical characters, thus you will need to handle such cases where you convert the uppercase character to its lowercase equivalent to find out the appropriate index within the alphabet to then be able to determine the correct shift amount. void update_key(…) This function is used by the cipher(…) function. This function creates a new key to use for ciphering if the length of the chosen key does not equal to the length of the chosen word. For example, if the chosen word is tacocat (length 7) and the chosen key is dogz (length 3) then the key will be updated to now be dogzdog (length 7) where the updated key concatenates itself with the chosen key until it’s length matches the chosen word. int is_valid_seed(…) This function checks the input seed and validates it meets the specified criteria of being at least be 1 character, and no longer than 6 characters long where the values of the seed range in between [1, 999999] where the seed value must only contain numerical digits. If the seed is valid, then this function returns a 1 otherwise it returns a 0. int roll_dice(…) This function returns a dice roll that is generated at random within a specified range from [1, dice side] int validate_dice_sides(…) This function parses and validates that the dice sides input are within the range of [1, 11]. If the dice sides are correct, then the function returns a 1 otherwise it returns a 0. void game_logic(…) This function implements the game logic as indicated by the HorseDiceCipher rules above.

Mar 14, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here