def getPrize(num):
if num == 15:
return 5
elif num == 16:
return 10
elif num == 17:
return 20
elif num == 18:
return 25
elif num == 19:
return 30
elif num == 20:
return 40
else:
return 0
def getRoll(before):
if before > 20:
return ((), 0)
best_roll = ()
best_avg = getPrize(before)
for roll in (range(1,9), range(4,8)):
avg = 0.
for i in roll:
avg += getRoll(before + i)[1]
avg /= float(len(roll))
if avg > best_avg:
best_avg = avg
best_roll = roll
return (best_roll, best_avg)
for before in range(20):
roll=getRoll(before)
print("%d: %s(%f)" % (before, str(roll[0]), roll[1]))
Which leaves us with the following table of the best bets:
current sum: best choice option (average money won)
0: 4..7(24.459561)
1: 4..7(24.461427)
2: 4..7(23.844185)
3: 1..8(23.573145)
4: 1..8(23.723004)
5: 1..8(24.281559)
6: 4..7(24.718933)
7: 4..7(25.114746)
8: 4..7(23.730469)
9: 1..8(21.812592)
10: 1..8(22.166748)
11: 1..8(23.037109)
12: 1..8(24.921875)
13: 4..7(28.750000)
14: 4..7(23.750000)
15: 4..7(17.500000)
16: 1..8(14.375000)
17+: stop
Too bad the wages are too low to make it a viable source of income.
if num == 15:
return 5
elif num == 16:
return 10
elif num == 17:
return 20
elif num == 18:
return 25
elif num == 19:
return 30
elif num == 20:
return 40
else:
return 0
def getRoll(before):
if before > 20:
return ((), 0)
best_roll = ()
best_avg = getPrize(before)
for roll in (range(1,9), range(4,8)):
avg = 0.
for i in roll:
avg += getRoll(before + i)[1]
avg /= float(len(roll))
if avg > best_avg:
best_avg = avg
best_roll = roll
return (best_roll, best_avg)
for before in range(20):
roll=getRoll(before)
print("%d: %s(%f)" % (before, str(roll[0]), roll[1]))
Which leaves us with the following table of the best bets:
current sum: best choice option (average money won)
0: 4..7(24.459561)
1: 4..7(24.461427)
2: 4..7(23.844185)
3: 1..8(23.573145)
4: 1..8(23.723004)
5: 1..8(24.281559)
6: 4..7(24.718933)
7: 4..7(25.114746)
8: 4..7(23.730469)
9: 1..8(21.812592)
10: 1..8(22.166748)
11: 1..8(23.037109)
12: 1..8(24.921875)
13: 4..7(28.750000)
14: 4..7(23.750000)
15: 4..7(17.500000)
16: 1..8(14.375000)
17+: stop
Too bad the wages are too low to make it a viable source of income.
No comments:
Post a Comment