##I Like Nines##
I Like Nines
This bot is bored, and doesn't like mind games. So they choose a random number every turn. However, they only have a d16 and don't want to disrupt the game to go find a d10 - so they choose 9 anytime they roll greater than 10!
EDIT: Just to be contrary, if own index is 9, the bot will instead prefer 6 when they roll greater than 10.
import random
class I_Like_Nines(object):
def __init__(self, index):
self.index = index
def select(self):
r = 0
# 4 bits are required to code 1-10 ([0-9] + 1, [0b0000 - 0b1001] + 1)
for i in range(0, 4):
# flip a coin. Puts a 1 in this bit place 50% of the time
if random.random() >= .50:
r += 2 ** i
# if your random bit assigning has produced a number outside the range 1-10, prefer 9
if not (0 < r < 11):
# when you are Bot #9, prefer 6
if self.index == 9:
r = 6
else:
r = 9
return r
def update(self, choices):
pass