In a race, I try to find the percentage probabilities of the competitors to move forward, backward and stay still.but I'm making a mistake.(I have to prevent the competitors from going off the track.)
def move(a): x = random.randint(1, 10)
if x == 1:
if a > 2:
return a - 2
else:
return 0
if x == 1:
return a + 2
else:
return a
if 1<=x<=3:
if a > 1:
return a - 1
else:
return 0
if 1<=x<=3:
return a + 1
else :
return a
if 3<=x<=5:
return a + 1
else:
return a
Aucun commentaire:
Enregistrer un commentaire