![]() |
|
#1
|
|||
|
|||
Text-Based Roulette GameSorry for how long this is, but this describes in detail what I want to accomplish, followed my my code. Thanks in advance for reading all of this. I've been working on this code for days!
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. CPP / C++ / C Code:
Last edited by LuciWiz : 29-Nov-2006 at 04:11.
Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
|
|||
|
#2
|
|||
|
|||
Re: Text-Based Roulette GameQuote:
Is there a question in there somewhere? Regards, Dave "Question? What's the question?" --- Larry King on 'Larry King Live' |
|
#3
|
|||
|
|||
Re: Text-Based Roulette GameSorry...a good question to help me might be can someone advise me on how I can get my program to flow. I sorta built it already, but I don't know how to flow my program. The biggest problem is I'm more comfortable with very few variables. Transitions and algorithm help with some mathematical logic would do be a lot of good. I'm trying to research on how to get this thing to flow, but I took out the loops, because I made it worse. My code is like this so someone can have an easier time with it. Believe me it was much worse when I tried to insert loops.
|
|
#4
|
|||
|
|||
Re: Text-Based Roulette GameQuote:
I would suggest visualizing the flow first. You have already written a pretty good discription. Now picture yourself actually entering a real live casino. You approach the cashier's cage to establish an account, then head off for the roulette wheel.... Even though this is a computer game, not a real live casino, isn't the idea to make the user of the programmer feel, somewhat, the casino experience? (Too bad there's no buffet and too bad there aren't hostesses circulating with free drinks for all of us, but you can't have everything, right?) At least you can try to learn to lose with grace and aplomb, right? Then write the sequence in pseudo-code (a non-computer-language narrative that gives the flow in words). As you write the pseudo code, it may become obvious how to actually structure the program. That is, certain tasks that are similar in nature could be implemented in a function that is called from different places in the main program. You might also realize that the specification of the program might need to be refined or corrected in order to get something that is actually implementable. Well, don't worry about such details until you actually have something to work with. There are no formal rules for writing pseudo-code, and after a while you might find yourself actually writing stuff that looks more like C than English. That's OK, but the idea is to express what you think the program should do before you actually start writing the program iteslf. I think it's very important to have the program structure and definition in writing before you start actually writing code. For example starting at the top: Code:
How much of this has to do with playing the game and how much with handling user input? How many loops? Sometimes the program specification is enough to let you start writing code without actually writing a detailed pseudo-code sequence, especially after you have done this a few times (or a few hundred times). But for now, I would suggest that you not try to write the whole program at one time. I can't tell you how frustrating it is to see that someone has written hundreds (thousands?) of lines of code without ever compiling any part of it and then asking, "Why am I getting all of these nasty messages from the compiler?" I suggest that you do a little at a time. Compile it as you add each little piece. Test it. Yes, Run the program with a very limited amount of code and make absolutely sure that you are handling everything correctly before going on to the next piece. This is especially true of the pieces with user input (whether the programmer has lots and lots of experience or not so much). So: I suggest that you do steps 1. and 2. in a program all by themselves. You can paste the useful parts of the code that you have already entered, but make a brand new project file for your main() function. If you are going to deal only with whole numbers (integer numbers of dollars or euros or whatever), then your program variables might be ints. (If you are going to play 21 ---sometimes known as Blackjack--- note that some payoffs are 1.5 to 1, so even if user inputs are always whole numbers, fractional numbers might be encountered unless you store all values internally as cents and not dollars.) Make a main() function. Create an int variable, say, amount_in_account (or whatever kind of notation that you like to use --- maybe amountInAccount). The point is, don't call it "n" or "x" or some such silly thing. Make the name meaningful. Trust me: it will make a difference some day. Printing the greeting is trivial, but it has to be done (these things just don't do themselves, you know). Put it there. Compile the program. Execute it. Make sure your compiler is working and that you can run the program. I don't mean to be condescending, and I know that you have already done some programs, but for a new project, do something extremely simple to make sure everything is set up correctly. Now make the loop to get user input. You are going to insist that the user enter a positive integer, and won't accept anything else. (As you encounter this type of problem a number of times in your program, you might consider making this a function, but for now, don't worry about it. Just do it.) Now, Stop! Don't even think about doing anything else until you have made sure that this little piece of code works as you think it should. Run the program and give it good input. (A positive integer.) Run it again with bad input: input zero; input a negative integer; input a non-numeric value; enter a fractional number. Get it right and test, test, test. You can't prove a program works by testing, but you should test with everything that you can think of. Not just with good data; that's trivial. Try to think of all of the bad things that you can give the program. Make sure that the program can detect it and handle it. Looking at your program, you are going to do this a number of times. If you test it right now, you can have some confidence that you won't have to worry about its correctness later. Then, and only then, go to the next step. Regards, Dave |
|
#5
|
|||
|
|||
Re: Text-Based Roulette GameThis procedure although involving a great deal more time I think this is exactly what I need until I am more comfortable with writing code off the bat. Unfortunately, I have military duty this weekend and it totally left my mind that I have another program to write for class. I'll try using that method for that program and keep this program on hold until I have enough time to finish it. Thanks so much for taking the time to break it down for me. I think the Deitel Deitel book I bought is a little advanced for me. When I get back to my program which should be in a week or so I'll post something if I have further questions.
|
|
#6
|
|||
|
|||
Re: Text-Based Roulette GameQuote:
Good luck and, as we old sailors always say, "Keep your powder dry." Regards, Dave |
Recent GIDBlog
Compress Your Web Site by gidnetwork
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help with displaying text in game! | seabreeze | C++ Forum | 1 | 11-Jul-2006 02:02 |
| Text Based RPG Web Hosting | AddeloBlack | Free Web Hosting | 3 | 19-Mar-2006 15:51 |
| CD burner wont burn!! | robertli55 | Computer Hardware Forum | 1 | 18-Jun-2004 10:53 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 11:28 |
Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The