def __init__(self): self.random = MyRand(123) self.round = 0 self.players_money = [0] * get_players() self.sumof_bit_bellow_values = 0 # sum of all bit_below_values that won self.behaviours = { 1: [ 0, self.allin ], # first value is the winning counter of this behaviour in the specific auction. 0.5: [0, self.halfin], "not specific value": [0, self.bit_below], 0: [0, self.zero] }
class NoTieBot: def __init__(self): self.players_money = [0] * get_players() self.random = MyRand(123) def play_round(self, winner, win_amount): self.players_money = [d + get_dollars() for d in self.players_money] if winner == -10: self.players_money[self.random.randint(1, get_players() - 1)] -= win_amount elif winner != -1: self.players_money[winner] -= win_amount if self.players_money[0] in self.players_money[1:]: return self.players_money[0] - self.random.randint(1, 10) return self.players_money[0]
class BitBelowBot: def __init__(self): self.dollar = 0 self.random = MyRand(123) def play_round(self, winner, win_amount): self.dollar += get_dollars() if winner == 0: self.dollar -= win_amount return self.dollar - self.random.randint(0, min(20, get_dollars()))
class RandomBot: def __init__(self): self.dollar = 0 self.random = MyRand(1) def play_round(self, winner, win_amount): self.dollar += get_dollars() if winner == 0: self.dollar -= win_amount return self.random.randint(0, self.dollar)
def __init__(self): self.dollar = 0 self.random = MyRand(123)
class SelectiveBot: # 1 means all in,0.5 means half in, 0 means biding 0 and all the other situations are "not specific value". keys = [1, 0.5, "not specific value", 0] # keys represent the value win_amount/winner_player_money def allin(self): return self.players_money[0] def halfin(self): return self.players_money[0] / 2 def bit_below(self): average_bit_bellow = self.sumof_bit_bellow_values / self.behaviours[ "not specific value"][0] total_biding = self.players_money[0] - average_bit_bellow if total_biding >= 0: return total_biding return self.allin( ) #all in if the budget is lower than average_bit_bellow def zero(self): return 0 def __init__(self): self.random = MyRand(123) self.round = 0 self.players_money = [0] * get_players() self.sumof_bit_bellow_values = 0 # sum of all bit_below_values that won self.behaviours = { 1: [ 0, self.allin ], # first value is the winning counter of this behaviour in the specific auction. 0.5: [0, self.halfin], "not specific value": [0, self.bit_below], 0: [0, self.zero] } def play_round(self, winner, win_amount): self.round += 1 self.players_money = [d + get_dollars() for d in self.players_money] if winner == -10: print("I don't know what I am doing") elif winner != -1: self.winning_behaviour_inturn = win_amount / ( self.players_money[winner] - get_dollars() ) # the behaviour of the recent winner if self.winning_behaviour_inturn != 1 and self.winning_behaviour_inturn != 0.5 and self.winning_behaviour_inturn != 0: self.winning_behaviour_inturn = "not specific value" self.sumof_bit_bellow_values += ( self.players_money[winner] - get_dollars() ) - win_amount # the needed bit bellow value to win self.players_money[winner] -= win_amount self.behaviours[self.winning_behaviour_inturn][ 0] += 1 # adding 1 to the winning behaviour of this turn if self.round == get_rounds(): return self.players_money[ 0] # default all in acting if it is the final round. max_wins = max([ self.behaviours[key][0] for key in self.keys ]) # the max_wins that have been with 1 or more behaviours winnable_behaviours = [ ] # saves all the behaviours that won max_wins times. for key in self.keys: if self.behaviours[key][0] == max_wins: winnable_behaviours.append(key) # ideally it's only one the winnable behaviour but if it isn't the chosen behaviour will be randomly. chosen_behaviour = winnable_behaviours[self.random.randint( 0, len(winnable_behaviours) - 1)] return self.behaviours[chosen_behaviour][1]()
def __init__(self): self.players_money = [0] * get_players() self.random = MyRand(123)