CS计算机代考程序代写 W = [4,8,12]

W = [4,8,12]
prey = {4: 0.66, 8: 0.77, 12: 0.82}
caught = {4: 0.01, 8: 0.02, 12: 0.03}

food = 6

# include basal rate
def alpha(w,s):
return -0.125*w + 0.005*w*s + 0.4

# helper function for discretisation
def Vd(t,s):
p = s – int(s)
return p*V(t,int(s)+1)[0] + (1-p)*V(t,int(s))[0]

_V = {}
def V(t,s):
if s < 25: return (0, 'Starve') if s >= 80:
return (1, ‘Eggs’)
if t == 11:
return (0, ‘End’)

if (t,s) not in _V:
_V[t,s] = max(((1-caught[w])*(1-prey[w])*Vd(t+1,s-alpha(w,s)) +
(1-caught[w])*prey[w]*Vd(t+1,s-alpha(w,s)+food),w) for w in W)

return _V[t,s]