Fountain
A simple bot, picks the lowest number first and if any other bot chooses it too, it will increment the counter - the floor gets filled and the water flows down. When it reaches 11, it restarts to 1 - the water gets pumped back to the top.
class Fountain:
def __init__(self, index, target=7target=10):
# Set data
self.index = index
self.pick = 1
self.target = target+1
def select(self):
# Select the number
return self.pick
def update(self, choices: list):
# Remove self from the list
choices.pop(self.index) # I hope `choices[:]` is passed, not `choices`.
# While the selected number is occupied
while self.pick in choices:
# Pick next number
self.pick += 1
# If target was reached
if self.pick == self.target:
# Reset to 1
self.pick = 1