Help: Text-Based Roulette Game

This is a discussion on Help: Text-Based Roulette Game within the C++ Programming forums, part of the General Programming Boards category; First of all, I would like to thank anyone that takes the time to read and respond to my thread. ...

Help: Text-Based Roulette Game

First of all, I would like to thank anyone that takes the time to read and respond to my thread. I am still currently in my first semester of programming and taking a small c++ class in college. To get a better understanding of what a single line of code could possibly represent I'm starting my first project with an interest I have. The program I want to create is not necessarily a game, but could be converted as such. What I aim to accomplish is to make a game related program that tests probabilty and other statistics.

The biggest difficulty for me is I have written simple programs that consist of asking for a series of numbers and it would calculate the sum, difference, average, etc. The algorithms required for the program I want is a little more advanced then anything we have done in class thus far. To me the difficulty makes the project more fun, and I don't think that it is out of my abilities completely. I would like some guidance from anyone interested in giving me advice and/or algorithm help on designing a basic program.

This next portion says in so many words what I want to get out of my program. In advance I am sorry for how long this is, but I wanted to try and be clear on what I want my program to do. If there are holes in the way I am thinking of setting this up let me know.

I want it to just show text saying "Welcome! How much would you like to deposit into our casino? Only use numerical values! <= 1" Else, the message repeats until you give an accepted answer. Then, output $ "X Dollars". For example, for 1000 would output "You have deposited $1000 good luck!"

Next, it asks "What wheel would you like to place your bets on?" "American" and "European" are the only accepted answers. Else, repeat statement until accepted answer is typed. Exception for the wrong answers in the future is "Floor". This will bring the player back to this question at any time. "What wheel would you like to place your bets on?"

Next, it asks "Would you like to bet using a loop? Yes or No?" Typing Y, N, Yes, and No, would be the only accepted answers. Else, it would repeat the statement until you gave the right choice.

Next, if "Yes" is choosen it asks "How many spins would you like the roulette wheel to make?" Only whole numbers are to be accepted in this portion of the program. Else, repeat question. If "No" is choosen less questions should be asked. "How much would you like to bet?", "Where would you like to place your bets?", and "Would you like the croupier to spin?" options should follow.

Next, it asks "How much money would you like to bet for the requested amount of spins?" Only whole numbers should be accepted here as well to make it easier for calculations and testing <= 1. The feedback to the answer should be "Would you like your $ "X Dollars" disbursed?" For example, 1000 should respond with "Would you like your $ 1000 disbursed?"

"No" implies that only one bet is going to be placed and "Yes" implies that $"X Dollars" will be divided among the number of bets you place. Same same thing should apply for eaither a looped bet or single bet. The reason is to show the results of a consistent bet. The acceptable yes or no answers apply here too.

Next, I would like the croupier (program) to ask "How many bets would you like to place?" Whole numbers should only be accepted here as well <= 1.

Next, "What is your starting bet?" Whole numbers only allowed.

Next, "What is your maximum bet?" Whole numbers only allowed.

Next, "Would you like to increase your bets as you win or lose?"

"Yes" asks would you like your bets to increase as you win or lose?" "Win" and "Lose" are the only options.

Next, "How would you like to increase your betting? Only whole numbers and 'N' or 'n' is allowed to increase the betting by the number of spins." I would like this part of the program to even process equations involving powers. For example, I would like to be able to put "(1^n + 10)". If the starting bet is $10 and you lost three times in a row the third bet would be (1^3 + 10) = (3 + 10) = 13. I know this is a dumb bet since you would not even break even. This is simply an example. My teacher never went into powers, but he did go into using '%'.

Next, it should ask Would you like to enable temporary betting? "Yes" and "No" applies with "Details" as an added option.

If "Details" is selected it should say "The temporary betting feature prevents a gambler from betting too high and losing all of his money on a high streak! When your current bet exceeds the maximum bet, temporary betting automatically works for that spin."

"Yes" asks "What would you like to set your temporary bet as?" Whole numbers only allowed.

Temporary betting is only enabled when the next spin would exceed the maximum bet. Also, it is disabled once a spin results in a win, or the loop is terminated. When a win occurs, the starting bet is applied before the next spin.

Display Table Now!

Before you place your bets it will now show a table of what bets you can place, the payout, and what numbers would win. For example, a "Five-Number Bet" and "Odd Bet" would display "The payoff on your Five-Number Bet is 6 to 1!" and "0, 00, 1, 2 or 3 wins!" and "The payoffon your Odd bet is 1 to 1!" and "All odd numbers win!" The Five-Number Bet is only an option on the "American Wheel" option and I have to have certain bets and values to spin on not available depending on what wheel is used.

Next, based on the number of bets you place it will ask "Where would you like to place your bets?" If you follow the betting options you proceed to the next question.

Next, it needs to calculate the amount of money you wished to bet per spin divided by the number of bets placed.

Next, it needs to summarize the options choosen for the bets.

Next, it needs to ask if the bets placed are correct. Yes and no options are the same once again.

Next, it asks "Would you like the croupier to spin at this time?" Yes and no options are the same once again.

At this time results should be being generated. Program should stop at the end of the loop, after one spin if no loop is selected, or if there isn't enough money to cover the current bet for the loop. Once the betting stops it shows how much you earned.

Next, the program says "Are you ready to continue with the results?" Only "Yes" works unless once again if you type "Floor" to take you back to the casino floor. Else, repeat previous statement until a correct answer is typed.

Next, With a "Yes" list how many times in a row (streak) both your bet had won and lost in a row with five and more as the value of the streak. Also, if a streak of ten occurs it should not indicate that a streak of five occured twice and ten occured once. Then, it should indicate how many times the bet had to be reset to the starting bet due to a high streak, if requested to increase bets based on wins or losses until you can not cover the bet with the range selected. Also, if enabled how many spins was temporary betting used.

If this occurs the first thing that should happen is if a temporary bet is
selected, that amount should be used for future spins until the win or loss
option selected results in terminating the temporary bet. This is only used so
long streaks do not cause you to lose all of your money. If you can't cover
any bet it should automatically bet the original amount and continue to increase as it did before. However, if the current funds can not even cover the temporary
bet or starting bet, then the loop is terminated. As stated above!

After the report the program should ask. "Would you like to place anymore bets?" Yes and no answers apply.

"No" brings back to casino floor with new bankroll.
"Yes" asks "Would you like to repeat your bets? with or without the money you earned?" Only "With" and "Without" applies.

"With" uses new bankroll to place same bet.
"Without" gives away earnings and tests the betting again.

I think this was really detailed...maybe too detailed, but I hope it was a good outline of what I want to accomplish. Also, I hope what I typed can help anyone give me some guidance on writing my program. I figure I'm doing great if I can eventually make this program and understand it. Even if I get help from you fellow programmers along the way. Thanks in advance to those that assist me or read my post at least.

siavoshkc - "Try a top to down designation." What do you mean by that? I never covered that in class lol.

bumfluff - "file i/o to save the person's bank account" The only file i/o I ever used was iostream.h what kind of i/o stream(s) would you think I should use, and how do I determine which one I need?

"you need to use a lot of loops" Also, if the option to make a series of random spins is choosen, and even if temporary betting is enabled can't I still use one loop? I thought about using more then one loop, but since I wanted all of the spins to continue until the loop ended, shouldn't I use just one loop? What is your take on this?

I know people aren't going to write code for me, so I'm working on that at the moment. However, I've never done things such as involve powers and have the program ask for someone to put an equation for the program to calculate a different bet (possibly an increase in money after each spin before the next spin automatically occurs) for each spin as streaks increase.

I'll post some code as I come up with it, but I just need a little guidance that is all. Thanks for your help so far everyone.

I'm getting close to finishing up the code that I know how to do, but I think this maybe too complex for me. I'll submit my code today or tomorrow, but my biggest problem is I'm not sure how I can get my values to work with each other in the loop and how to organize it. Hopefully with my // comments people will be able to understand what I'm trying to accomplish.

Finally I have plenty code to show! I tried to put this game together in a loop, but I keep getting it all wrong. The way I setup the program this time wasn't how the code should look exactly, but as a personal starting point and a guide on how I wanted to put it together. I need some advice on how to put it together for the transitions and how to do various equations involved to get game results. Also, if you notice I only put together the American Roulette table and duplicated it for the European Roulette table. This was to save time and submit something. Hopefully people can read my code and it isn't so sloppy. I tried to organize it the best I could, so please keep in mind I'm a newbie programmer. If you see any other things I'm overlooking like necessary counters and variable to add let me know. I'll keep working on it, but I wanted to at least post something to show I'm working on it. Thanks so much in advance for at least looking at it everyone!

You need to learn about functions and classes. Please read about those before trying to code anything more complicated than adding two variables.

Get a good book from the books sticky thread or read several tutorials on the web. You are obviously too limited in your knowledge to try this type of program.

I'm not trying to discourage you. I'm trying to be realistic. Adopt another posture towards the learning process of a programming language. Try to learn about it first; what does it offer you, how to use what it offers. Then and only then should you try to apply that knowledge.

manutd - I just used 2 spaces for indenting and I set it up that way, so I can read options easer. Didn't want to back everything up to the right corner and have less room to work with. Thats why I limited indenting. The loops and brackets were throwing me off so bad that I had to resort to writing it like this for now till I revise some code.

Mario F. - I'll look into that, but I just wanted to post what I had so far. Thats why I needed to post my program I'm only comfortable with small programs involving a few veriables to get sums and averages and things. Mainly thats why I need help so much.

I'll try to look into all of this and get back with my code as I develop it. I'll check back for more comments later.

>manutd - I just used 2 spaces for indenting and I set it up that way, so I can read options >easer. Didn't want to back everything up to the right corner and have less room to work with.

Having good indentation in a program can greatly improve two things.

1 Program readability. It is very hard to read a large program that is all to one side or mixed
spaced at every indent. Dependant on the IDE your are using, set the indent margin to three
spaces, or manaually do it as you write the code. At every if statement, indent the code that
defines the condtion. A every function opening brace ( like main ) ijndent the entire section.

2 Debugging. When you create a big program, and have to debug it ( find errors ) it can also
be frustrating to debug with poor indentation. Epecially when one of the errors is a missing
brace. If they are not aligned in the first place, finding it can be time comsuming.

>You need to learn about functions and classes. Please read about those before trying to code >anything more complicated than adding two variables.

Mario is right. Did you check brains post a little further up? Your program will be much more
neater and layed out better if you did use clasees and functions. Look how he has implemented
his version and adapt the same procedure to yours.

These are not in anyway naggings, but it is vitally important to learn good program format
and claraity when you attempt a project as large as this