In a simplified version of a child’s board game, players "race" around the board going from Start to Finish, moving their tokens based on the roll of a six sided die. The board has 101 spaces where the Start space represents "0" and the Finish space represents "100". An exact roll is not required to cross the finish line. To ensure that one child does not have an advantage, all the children roll the die separately, but move simultaneously.
Part I. With one child playing, how many turns (on average) will it take to have a winner?
With 2, 3, or 4 children playing, how many turns will it take (on average) to have a winner?
Part II. With 4 children playing, when one of the children crosses the finish line, how far along should the child in 2nd place, 3rd place, and 4th place be? (Again, looking for the statistical average position.)
Part III. What would be the solution to the previous questions if an exact roll is required to cross the Finish line? (If the roll is too high, the player loses a turn and does not move.)
Over the course of 266,899 trials, for some reason, it took on average 29.04 rolls to get over 100, rather than the 100/3.5 = 28.57 I had expected. Maybe it has to do with 29.04*3.5 = 101.64, while on average the final toss takes the total to 103.5.
The other statistics are:
avg # of tosses avg positions of
1playr 2playrs 3playrs 4playrs 2nd pl 3rd pl 4th pl trials
29.04 27.58 26.87 26.43 94.84 89.80 83.43 266899
If two players reached the finish in the same turn, 2nd place was considered to be in position 100 regardless of how much the roll was in excess of the number needed.
DECLARE FUNCTION min# (x#, y#)
RANDOMIZE TIMER
DEFDBL A-Z
CLS
DO
trial = trial + 1
REDIM p(4)
nOver = 0: turn = 0
DO
turn = turn + 1
FOR i = 1 TO 4
r(i) = INT(RND(1) * 6 + 1)
NEXT
FOR i = 1 TO 4
IF p(i) < 100 THEN
p(i) = p(i) + r(i)
IF p(i) >= 100 THEN
nOver = nOver + 1
over(nOver) = turn
overWho(nOver) = i
IF nOver = 1 THEN
REDIM pList(3): plp = 0
FOR j = 1 TO 4
IF j < i THEN
FOR k = 1 TO plp
IF pList(k) < p(j) THEN EXIT FOR
NEXT
FOR l = plp TO k STEP -1
pList(l + 1) = pList(l)
NEXT
pList(k) = p(j)
plp = plp + 1
ELSEIF j > i THEN
FOR k = 1 TO plp
IF pList(k) < min(100, p(j) + r(j)) THEN EXIT FOR
NEXT
FOR l = plp TO k STEP -1
pList(l + 1) = pList(l)
NEXT
pList(k) = min(100, p(j) + r(j))
plp = plp + 1
END IF
NEXT
END IF
END IF
END IF
NEXT
LOOP UNTIL p(1) >= 100 AND p(2) >= 100 AND p(3) >= 100 AND p(4) >= 100
REDIM pers(4)
FOR numb = 1 TO 4
FOR j = overWho(numb) TO 4
IF pers(j) = 0 THEN pers(j) = over(numb): tot(j) = tot(j) + over(numb)
NEXT
NEXT
FOR pl = 1 TO 3
totProg(pl + 1) = totProg(pl + 1) + pList(pl)
NEXT
'FOR i = 1 TO 4
' PRINT over(i); overWho(i)
'NEXT
PRINT USING "####.##"; tot(1) / trial; tot(2) / trial; tot(3) / trial; tot(4) / trial;
PRINT USING "####.##"; totProg(2) / trial; totProg(3) / trial; totProg(4) / trial;
PRINT trial
REM
LOOP
FUNCTION min (x, y)
IF x < y THEN min = x ELSE min = y
END FUNCTION
|
Posted by Charlie
on 2007-06-19 12:03:28 |