Deal or No Deal / Even More Fun with Random(-ish)!

Greetings gentlefolk,

I was recently invited by Kip to take part in a rite of passage, of sorts, to build a new prototype inspired by Ian’s random-like function. This function has already been artistically implemented in Kip’s Magic 8-Ball example, as well; and I follow a very similar approach here.

My example is based on the game show Deal or No Deal. Heard of it? If you’re unfamiliar, don’t fret–I’ll save you a step and link you to this Wikipedia article! Here’s a description of the rules, in brief:

The game consists of 26 briefcases (I use 9 in my lite version), each one containing in it a randomly assigned dollar amount ranging from a mere $.01 to a whopping $1,000,000. To begin the game, the first matter of business is for you as the player to select one of the briefcases to keep as your own. Each subsequent round, you select another briefcase to eliminate from play, one at a time. After each round, you are presented with a cash offer which you can either accept or decline. If you decline, the game continues until you reach the last two briefcases; at which point, you are asked to either accept the final cash offer (deal!) or decline the offer and take what’s in your own briefcase (no deal!).

[b]Check out the prototype![/b]

To start, the random-like function is implemented in the OnPageLoad Event, so the dollar amounts are already randomly assigned to the briefcases when you start playing. In the screenshot below, you’ll see I’ve created multiple Event Cases, each one simulating a different configuration of dollar assignments to the nine briefcases. So, based on the number generated from the random function, the corresponding dollar assignment will be loaded. Here’s a screenshot of a subset of the OnPageLoad Cases:

The briefcases in play are simple Shape Widgets converted to Dynamic Panels; State1 of the DP is the briefcase number and State2 will contain the dollar amount which will be revealed. For each briefcase DP, the OnClick Event performs the following: it increments the CasesLeftVar variable by -1 and TurnNumberVar by +1, it reveals the dollar amount in the selected suitcase by setting it to DP State2, and it hides the corresponding item on the scoreboard based on whether the numbers match between the scoreboard Widget and the selected briefcase:

Once the corresponding scoreboard item is hidden, the OnHide Event for each one does the following: it updates the Sum variable by subtracting the selected dollar amount, and it sets the value of TheOffer variable and displays it on the Widget named “TheOfferBoard”:

And a couple extra details:

In the screenshot directly above, you’ll see I used the “toFixed” JavaScript method to fix the number of decimal places to 2, for the value of TheOffer variable; here’s how it looks: [[TheOffer.toFixed(2)]]. Using that simulates a more realistic cash offer.

Further, I found an equation online that approximates the algorithm for calculating the cash offer, which looks like this:

banker’s offer = average value * turn number / 10

I implemented an adapted version of that equation in the OnHide Event when TheOffer variable is set; I did this using Global Variables, like so:

[[Sum / CasesLeftVar * TurnNumberVar /15]]

And that’s it! I admit, my version of Deal or No Deal might be boiled down a bit and might not carry the suspense that Howie Mandel brings; but if anyone has further suggestions or ideas to add, feel free to share–they’re more than welcome!