Last active
May 27, 2018 08:46
-
-
Save bwasti/b8fb53360d141e004651e1556a5c5c9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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