#Victory Plus Minus One
Victory Plus Minus One
Randomly picks one above or below the last victory number.
import random
class VictoryPM1(object):
def __init__(self, index):
self.index = index
self.victory = 0
def select(self):
if self.victory < 1 or self.victory > 10:
return 1
elif random.randint(0, 1):
if self.victory < 2:
return 2
else:
return self.victory - 1
else:
if self.victory > 9:
return 9
else:
return self.victory + 1
def update(self, choices):
a = [0] * 11
for b in choices:
a[b] += 1
for i in range(1, 10):
if a[i] == 1:
self.victory = i
return