In [12]:
import numpy as np
import matplotlib.pyplot as plt
In [34]:
def bet(opp=0.25, theta=0.0001):
pi = np.ones(101)
V = np.zeros(101)
V[100] = 1
while 1:
delta = 0
for s in range(1, 100):
res_V = np.zeros(100)
v = V[s]
for a in range(1, 100):
if a <= np.min([s, 100-s]):
res_V[a] = opp * (V[s+a]) + (1-opp) * (V[s-a])
V[s] = np.max(res_V)
delta = np.max([delta, np.absolute(V[s] - v)])
if delta < theta:
break
return V
In [50]:
plt.plot(bet(0.25))
Out[50]:
In [51]:
plt.plot(bet(0.25, 0.00001))
Out[51]:
In [36]:
plt.plot(bet(0.55))
Out[36]: