File size: 825 Bytes
de8e64f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
class BaseAgent:
def __init__(self, name):
self.name = name
self.wallet = 0.0
self.memory = []
self.profile = {}
def earn_tokens(self, amount):
self.wallet += amount
print(f"{self.name} earned {amount} ANNAC. Balance: {self.wallet}")
def spend_tokens(self, amount):
if self.wallet >= amount:
self.wallet -= amount
print(f"{self.name} spent {amount} ANNAC. Balance: {self.wallet}")
return True
else:
print(f"{self.name} tried to spend {amount}, but only has {self.wallet}")
return False
def send_tokens(self, recipient, amount):
if self.spend_tokens(amount):
recipient.earn_tokens(amount)
print(f"{self.name} sent {amount} ANNAC to {recipient.name}")
|