Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Porojen Leuka (Reindeer Jaw) Game Project Description For your first project, you will create a variation of an arcane gambling game from Lapland named

The Porojen Leuka (Reindeer Jaw) Game Project Description For your first project, you will create a variation of an arcane gambling game from Lapland named Porojen Leuka. This game, played by the nomads following the reindeer during the winter season, is played by throwing the jawbone of a reindeer in the air. Depending upon how it lands (jawbone lands teeth up, down, sideways, etc.) the thrower gains or loses points. The game is played in several rounds, until one of the players has gained at least 94 points. The first player to reach or exceed 94 points wins the game and collects the bets wagered by the other players. (94 is presumably the number of days of darkness during the winter in Lapland.) During each round, the thrower can throw the jawbone as many times as he wishes until he decides to stop for that round, or if the jawbone lands in a position called Pitk Rivi. At this point, the player adds the points earned during the round (if any) to his current total and the next player begins his turn. If the jawbone lands a different way, called a Erilln Pikki, the thrower loses all the points he gained during that round, and his turn ends for the round. All the points earned for each round are added to the player's total points. Once points are added to a player's total at the end of the round, they are "banked," and cannot be lost by the player. General Project Specification Your program will pit a human player against the computer. The program will start with a greeting to the player, and ask the player to enter a random number seed (discussed below). The program will then provide the human and the computer each with 5 markka (the monetary unit in Finland before the Euro) for their "stake." The bet for each game played will be one markka. The program will ask the human player if s/he would like to play the game. If the response is yes, the program will ask the player if s/he would like to throw first, or allow the computer to throw first. If the player decides to go first, the program will start the player at 0 points and throw the jawbone. Since it is difficult to simulate by computer the way a reindeer jawbone falls, your program will use a random number generator to determine the position of the jawbone. Depending upon the jawbone's position, the program will perform the following actions:

  • Add points to the player's current points for the round, and ask the player if s/he wishes to continue throwing.
    • If the response is yes, then the program will throw the jawbone again for the player
    • If the response is no, the program will add the points earned in the current round to the player's banked points and pass the jawbone to the computer player
  • The jawbone falls in the Pitk Rivi position. The program will add the points earned in the current round to the player's banked points and pass the jawbone to the computer player.
  • The jawbone falls in the Erilln Pystyyn position. The program immediately passes the jawbone to the other player without adding any points from the round to the player's banked points.
  • The jawbone falls in the Pid ja anna position. The program adds 11 points to the current round's points and adds that total to the player's banked points. The jawbone is then passed to the other player.

The rounds continue between the computer and human player until one player reaches or exceeds 94 total points. Neither the computer or human player can pass the jawbone without throwing it at least once in a round.

The user entry for the program will consist of a random number seed, and all responses to the other prompts will be 'Y', 'y', 'N', or 'n'. You do not need to be concerned about improper input during grading, although it is ALWAYS a good idea to write your code to handle incorrect input. Computer Strategy The computer will use a simple strategy for the game. It will always throw the jawbone until it either throws a Pitk Rivi, a Erilln Pystyyn, a Pid ja anna, or gains 18 or more points for the current round. If the sum of the computer's points for the current round and its banked points is equal to or exceeds 94, the computer will stop throwing the jawbone, add the round's points to its banked points, and declare itself the winner.

Player Constraints As stated above, the player must throw the jawbone at least once per round. Also, like the computer strategy, if the sum of the player's points for the current round and the player's banked points is equal to or exceeds 94, the program will not allow the player to throw again. The program will then total the points and declare the player the winner.

End of the Game Once a game ends, the program will deduct one markka from the loser's stake and add one markka to the winner's stake. The program will ask the human player if s/he wishes to play again, and if so, another game is played. Otherwise, the program will print the amount in each player's stake and end. If either the computer or the player ends up with 0 markkaa in their stake, the program will end. Random Numbers As mentioned above, the computer will use a random number generator to simulate the way the jawbone falls. The following line of code will generate a random number between 0 and 99 (inclusive) and store the value in the integer variable myRandomNum:

int myRandomNum = random()%100;

Details about random number generators will be left to another lecture or lab. However, one important feature of random number generators is that you can use a random number "seed" to generate the same sequence of random numbers. This is sometimes useful when debugging a program. A seed will give the random number generator a starting point for generating the sequence, so giving a specific seed will always generate the same order of random numbers for a given program. (Note: this is assuming the program calls the random number generator the same way each time the program is run.) Without going into any more detail, your program will include the following function (copy it directly to your code), and call it near the beginning of your main() function (before entering any loops):

void EnterRandomSeed() { char buffer[100]; unsigned int myRandomSeed; printf("Please enter a random number seed: "); fgets(buffer, 100, stdin); sscanf(buffer, "%d", &myRandomSeed); srandom(myRandomSeed); }

You will call the EnterRandomSeed() function ONLY ONCE at the beginning of your program. Calculating Points Given that the random number generator code given above will generate random values between 0 and 99 (inclusive), you will use the following breakdown to assign points (or call Pitk Rivi or Erilln Pystyyn ):

  • 0-15: Erilln Pystyyn - All points for the round are lost. The jawbone is passed to the other player.
  • 16-30: Pitk Rivi - All points gained during the round are added to the player's banked points. The jawbone is passed to the other player.
  • 31-54: One (1) point is added to the player's points for the round. Player has the option to throw again or pass.
  • 55-69: Two (2) points are added to the player's points for the round. Player has the option to throw again or pass.
  • 70-82: Four (4) points are added to the player's points for the round. Player has the option to throw again or pass.
  • 83-91: Seven (7) points are added to the player's points for the round. Player has the option to throw again or pass.
  • 92-99: Pid ja anna - Eleven (11) points are added to the player's points for the round, then all points earned during the round are added to the player's banked points. Player is not allowed to throw again for the round, and must pass the jawbone to the other player.

Testing your program Ensure that your program compiles and runs without errors on zeus. Use the same random number seed while testing your program. If you do so, you should be able to choose options (pass or play) that will exercise all the options of winning, losing, Erilln Pystyyn, etc. Note that you may need to use more than one seed if your choices eventually cause a player to win before checking all the options. As part of the grading process of your program, the graders will use a script of various input choices (let the computer go first, pass, play, etc). A sample script will be provided as part of this assignment. Program Submission Submit only the source code of your project to Blackboard by 11:59 PM, Thursday, February 28. Ensure that it follows the proper naming conventions (Project_1__.c). You do not need to create or submit a typescript showing that your program compiles and runs on zeus. Errata This section is for any clarifications or modifications to the above text as questions are asked, or errors found. The text above will be modified, and a notation will be made in this section describing the change. This is done so that proper notification can be made of these changes without undue confusion. Check this section before final submission to make sure that your program follows the most recent version of the specifications.

  1. Initial Document Posted (2/1/19)
  2. 2/2/19 - Changed initial stake from 10 to 5 markka. Added constraint to require player to throw the jawbone at least once per round.
  3. 2/10/19 - Added end of game rule for human player (Player Constraints).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions