GAF logic nerds, assemble!
I come to you bearing a problem that has my brain frizzled.
I'm creating an adaption of the
Deal or No Deal gameshow. I have most of the design working, but am having trouble with a specific part.
Background:
The show's gameplay involves a series of briefcases, each of which contains a different prize value. The user chooses their own briefcase, and then opens up the remaining briefcases. Every time a briefcase is open, the value which was inside that briefcase gets eliminated from the board. At certian stages throughout the game the user is offered a 'deal', whereby they can choose to accept a monetary offer (based on a mean of the remaining case values), or continue opening briefcases.
What I have so far:
- System to randomise the prize values going into each case
- System to recognise which briefcase the user wants to open
- System to read the prize value of an opened briefcase and to eliminate that value from the board
What I'm stuck on:
- I need a way of calculating the bank's offers at certain points throughout the game. The bank offer needs to be related to (although not necessary exactly) the mean of the remaining case values.
Details:
I have 24 prize values, ranging from 1 to 500. Full list of prize values is included below...
Code:
PrizeID Value
=================
A 1
B 2
C 3
D 4
E 5
F 6
G 7
H 8
I 9
J 10
K 20
L 30
M 40
N 50
O 60
P 70
Q 80
R 90
S 100
T 150
U 200
V 300
W 400
X 500
There are 8 instances when I need to calculate the average of the remaining/un-opened case values. Details of each instance is given below.
Code:
Cases opened Cases remaining
since last
offer
================================
6 18
5 13
4 9
3 6
2 4
1 3
1 2
1 1
So yeah. For the first bank offer, I need a system which can estimate the average of 18 case values, where the cases potentially add up to a total of 2124.
What I've come up with so far...
There appears to be two main ways of going about this:
Method 1) Find the sum of the remaining cases and then divide by the number of cases remaining.
For example, I have a bank offer when there are six cases remaining (case values: 6, 50, 80, 90, 200, 500)
Sum of remaining cases = 926
Remaining cases / number of cases = 926 / 6 = 154.3
Method 2) Find out how much each case is worth as part of the offer (value/number of cases), and then find the sum of these values.
(Opposite way around to Method 1)
For example, I have a bank offer when there are six cases remaining (case values: 6, 50, 80, 90, 200, 500)
Value for each case: 6/6=1, 50/6=8.3, 80/6=13.3, 90/6=15, 200/6=33.3, 500/6=83.3
Sum of values = 1 + 8.3 + 13.3 + 15 + 33.3 + 83.3 = 154.3
My latest attempt used the second method. Rather than performing division operations in-game, I precalculated how much each case value would be worth if it were part of an offer.
Code:
PrizeID Value (v) v/18 v/13 v/9 v/6 v/4 v/3 v/2 v/1
======================================================================================
A 1 | 0 0 0 0 0 0 0 1
B 2 | 0 0 0 0 0 0 1 2
C 3 | 0 0 0 0 0 1 1 3
D 4 | 0 0 0 0 1 1 2 4
E 5 | 0 0 0 0 1 1 2 5
F 6 | 0 0 0 1 1 2 3 6
G 7 | 0 0 0 1 1 2 3 7
H 8 | 0 0 0 1 2 2 4 8
I 9 | 0 0 1 1 2 4 4 9
J 10 | 0 0 1 1 3 3 5 10
K 20 | 1 1 2 2 6 6 10 20
L 30 | 1 2 2 6 6 10 16 30
M 40 | 2 2 5 5 10 12 20 40
N 50 | 3 3 5 8 13 15 25 50
O 60 | 3 5 5 10 15 20 30 60
P 70 | 3 5 8 10 20 23 35 70
Q 80 | 5 5 8 15 20 25 40 80
R 90 | 5 5 10 15 20 30 45 90
S 100 | 5 7 10 15 25 35 50 100
T 150 | 8 10 15 25 35 50 75 150
U 200 | 10 15 20 30 50 60 100 200
V 300 | 15 25 35 50 75 100 150 300
W 400 | 20 30 45 65 100 135 200 400
X 500 | 25 35 55 85 125 165 250 500
Going back to the example before, I would need to find the sum of the v/6 values of each of my cases.
Actual case values: 6, 50, 80, 90, 200, 500
v/6 values from table: 1, 8, 15, 15, 30, 85
Sum of v/6 values = 154
Using this method, the task simply becomes a matter of finding the sum of pre-calculated values
With this in mind, I design the following system in my level.
Each column represents a different case value. There are 8 rows of dissolveable blocks -- one row of blocks for each bank offer. The dissolveable blocks contain magnetic keys, which include information about the v/18, v/13, v/9, etc values. At the very bottom is a series of magnetic switches which reads the value of the dissolving block immediately above it.
The bottom row of dissolveable blocks contains the v/18 values. Once the v/18 values have been used to calculate the first bank offer, the bottom row of blocks is dissolved and the v/13 blocks fall onto the detector. Once the v/13 values have been used for the second bank offer, they too are dissolved and the v/9 blocks fall onto the detector.
The white base which holds the detector is also made of dissolving material. Each time a case is opened, the base holding the detector for that specific case disappears. The detector falls away and is unable to read values from the v/18, v/13, etc blocks, so it assumes a value of 0.
Example of apparatus using the same example as before:
Even though all v/6 values are present in the apparatus, there are no detectors underneath the eighteen already-opened cases. The only values detected by the apparatus would be 1, 8, 15, 15, 30 and 85. The sum of these values would be my average for the unopened cases (154).
What I need to do now is find a way of quickly and reliably adding those numbers together. Any suggestions? Or any other completely different approaches which would be better?