Skip to content

Instantly share code, notes, and snippets.

@bwasti
Last active May 27, 2018 08:46
Show Gist options
  • Save bwasti/b8fb53360d141e004651e1556a5c5c9d to your computer and use it in GitHub Desktop.
Save bwasti/b8fb53360d141e004651e1556a5c5c9d to your computer and use it in GitHub Desktop.
class Agent(object):
def __init__(self, bank, init_policy=2.5):
self.policy = random.uniform(0, init_policy * 2)
self.bank = bank
def declared_price(self, intrinsic_cost):
self.cost = intrinsic_cost
self.price = max(self.policy * self.cost, 0)
return self.price
def pay(self, payment):
assert payment >= self.price
self.bank -= self.cost
self.bank += payment
def clone(self, mutation):
cloned = Agent(self.bank)
cloned.policy = self.policy + random.uniform(-mutation, mutation)
return cloned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment