News Ticker

Menu

Game of Craps in C programming Source Code

Project Description:

For this project, you will be creating a program to play a simplified version of "Craps," a well-known dice game. In the game, two dice are thrown, and the players bet on the outcome of the roll (the sum of the upturned faces).

The basic rules of Craps are as follows:



  • The player makes a bet for the game by either betting for himself ("Pass Line") or against himself ("Don't Pass Line")
  • If the player bets on the Pass Line:
    • If the first roll of the dice results in a 7 or 11, then the player immediately wins the amount of the bet;
    • If the first roll of the dice results in a 2, 3 or 12, then the player immediately loses the amount of the bet;
    • If the first roll is a number other than 2, 3, 7, 11 or 12, the number that is rolled is called the player's "point." In addition, the player may increase ("press") the amount of his/her bet at this point.  For purposes of this game, the player should be allowed to double the amount of the bet. 
    • At this point, the player's goal is to roll the same "point" again *before* rolling a 7 (called "sevening out").


  • If the player bets on the Don't Pass Line, the result is basically a mirror image of the above. Here are the rules:
    • If the first roll of the dice results in a 2, 3 or 12, then the player immediately wins the amount of the bet;
    • If the first roll of the dice results in a 7 or 11, then the player immediately *loses* the amount of the bet;
    • If the first roll is a number other than 2, 3, 7, 11 or 12, then the player who bets against him/herself is betting that s/he will roll a 7 *before* rolling the "point" a second time.  If the 7 is rolled, the player wins;  if the point is rolled first, the player loses. As when betting for him/herself, the player should be allowed to double the amount of the bet if he/she wishes.
  • When the player has either "sevened out" or "made the point," the game is completed, and a new game begins.  If the player won, s/he must decide whether to pick up his/her chips and quit or to play another game.

Your program should give the player an initial bankroll of $100.00.  The minimum bet is $5.00. For purposes of this game, there is no maximum bet, other than the amount of money available.

Specifications:

At the start of the program, you will give an introductory message and then prompt the player to enter a random number seed.

You will need to design and implement several functions in order to complete this game.

You will need to decide on appropriate variables in which to store the player's bankroll (in order to keep track of how much money the player has) and how much s/he won or lost in the most recent game. This bankroll should be kept up to date on the player's current status, which means that wins should be added and losses should be subtracted from the bankroll as the user plays the game. After each game, the program must report the result of the game, the amount of money won or lost, and the current value of the bankroll. After each game, the program should allow the player to continue playing until s/he chooses to quit, or until the player runs out of money. This central program control may be done within main().

"Rolling" the dice:

A separate function will be used to "roll" the dice. This function will contain two die variables. For a roll, you will set each variable separately using a random number generator. The possible values are one through six, corresponding to the six sides of a regular die. The function will print the value of each die after it is rolled (but not the total). This function will return the sum of the two variables.

"Playing" the game:

A second function will be used to play a single game of craps until the player either wins or loses a bet, based upon the rules given above. This function should be passed the current $ amount of the player's bankroll and should return the amount of money won or lost for that particular game.

  • Within the function, the player is asked how much s/he would like to bet. The player must then choose whether to bet "for" or "against" him/herself (see game rules above).
  • The player then "rolls the dice" (simulated by a call to the dice-rolling function). This should be done interactively (via a key press from the player), rather than simply having the program continuously roll the dice until the game is over.
  • After each roll, this function should report the total value of the dice (after receiving this value from the dice-rolling function).
  • If, after the first roll, the game is not over, a point is established and the player should be asked whether s/he would like to double the amount of the bet (this option is given only after the first roll).
  • When a roll causes the end of a game, the player is notified whether s/he won or lost money in that game overall and the amount won or lost. In all other cases, the player is notified that s/he needs to roll again.
  • At the completion of a winning game (but before the function returns), you will allow the player to "let it ride" (leave the  current bet+winnings on the table as the bet for the next game). If the player chooses to let it ride, start a new game with the current bet and winnings and using the previous Pass or Don't Pass Line as the type of bet. Otherwise, exit the function, at which point the program will return the winnings to the player's bankroll and ask if the player would like to play again.

The amount returned should be used to update the player's bankroll.
Additional functions may be necessary and/or appropriate, depending upon the final overall design of your program.

Order "Game of Craps" in C programming only for $10


Share This:

Post Tags:

Hassnain

I'm Hassnain. A full time Java Developer. I enjoy to make modern projects. I love to create JavaFX, Java Swing GUI and write about Java Programming, OOP. Now I'm working with CS2IT. You can buy our projects from here.

No Comment to " Game of Craps in C programming Source Code "

  • To add an Emoticons Show Icons
  • To add code Use [pre]code here[/pre]
  • To add an Image Use [img]IMAGE-URL-HERE[/img]
  • To add Youtube video just paste a video link like http://www.youtube.com/watch?v=0x_gnfpL3RM