| |
BGonline.org Forums
Probability of hitting a checker from a long running start
Posted By: ah_clem In Response To: Probability of hitting a checker from a long running start (Jason Lee)
Date: Sunday, 6 July 2025, at 8:53 p.m.
It rained all day today, so I had nothing better to do than dust off some of my old programming skills and write a routine that implements the recursive approach above.
It converges to 0.39446366782006914 in a little over 300 recursive calculations of p(n), which is remarkably close to Bob's answer.
Here's the code in case anyone is interested:
# Online Python - IDE, Editor, Compiler, Interpreter
def prob(length):
hit = [0,11,12,14,15,15,17,6,6,5,3,2,3] #number of shots from n away
hit.extend([0,0,1,1,0,1,0,1,0,0,0,1])
short = [0,0,0,2,3,4,5,6,5,4,2,1,1] #number of ways to roll exactly n
short.extend([0,0,0,1,0,0,0,1,0,0,0,1])
p=[0] # p[n] is the probability of hitting from n pips away
for n in range(length +1):
if n == 0:
continue
if n <= 24: #possibly a shot this roll
p.append(hit[n]/36)
else:
p.append(0) #no possibility of a shot this roll
for i in range(n):
#add the probabilities of all the rolls that are short of the blot
if i == 0:
continue
if n-i > 0 and n-i < len(short):
p[n] = p[n] + short[n-i]*p[i]/36
for n in range(length +1):
print(f'{n} {p[n]}')
prob(1000)
There's probably a more elegant way to deal with the zero indexed lists that Python provides; I don't really care that I'm using magic numbers (24 & 36) here.
| |
BGonline.org Forums is maintained by Stick with WebBBS 5.12.