how to randomize the value to the 26 briefcase using array
formula for the offer of the banker
ty in advance!
This is a discussion on deal or no deal c code or Logic of how the banker offers within the C Programming forums, part of the General Programming Boards category; how to randomize the value to the 26 briefcase using array formula for the offer of the banker ty in ...
how to randomize the value to the 26 briefcase using array
formula for the offer of the banker
ty in advance!
Well there are several ways:
Keep a sorted array of the amounts, and randomly select one for each of the cases, ie:
Case 1:
Select 1-26 (rand()) from amounts
Remove the item from amounts (plugging the hole)
So on and so forth. There are however other methods, which could be better.
All of the above is correct. As far as the offer goes it's the total amount still available divided by the number of cases remaining plus a little bit for incentive.
Ex 1:
Lets say there are three cases left: .01, 200,000.00, and 1,000,000.00
The bankers offer would be about:
(.01 + 200,000.00 + 1,000,000.00) / 3 + incentive
400,000.00 + incentive
Ex 2:
Four cases: .01, 1.00, 100,000.00, 1,000,000.00
The offer: (.01 + 1.00 + 100,000.00 + 1,000,000.00) / 4
275,000.25 + incentive
Last edited by rmetcalf; 09-18-2008 at 08:33 AM.
I'd imagine the banker's offer is based around the average of all the unopened boxes (or just a little less, maybe you could set a rick factor to determine how much higher or lower than the average the offer is).
MSVC++ 6.0
I would use a more advanced function than what rmetcalf had suggested. That or stick with what he said and calculate the incentive based on probabilities. Lets start with a hypothetical:
You have 4 cases left: $1.00, $50.00, $1,000.00, and $1,000,000.00
The average of those numbers is $400,414.00, right? Should the banker offer you $400k? I wouldn't.
So what if instead you look at it as you have a 1 in 4 chance of getting a large prize (call anything over $10,000 a large prize... hell even $10,000 if that is large enough for you) and use those to make a coefficient for probability.
So lets call the coefficient 0.25 in my example, since you aren't exactly likely to get a mil. Which gives me an offer of $100,105. Which sounds better, right?
You can play with algorithms for calculating the probabilities. But I think that is the best route and likely the technique actually used for the show. Will your program include ascii babes?