i think it is working

This commit is contained in:
2023-01-23 11:28:12 +01:00
parent 3a421ceb34
commit 89dc8ed54a
22 changed files with 540 additions and 28 deletions

View File

@@ -1,12 +1,12 @@
from base_agent import BaseAgent
from .base_agent import BaseAgent
class AutoProductionAgent(BaseAgent):
"""
Automaticaly produces commodity if in business inventory
"""
def __init__(self,business) -> None:
super().__init__()
def __init__(self,sim,business) -> None:
super().__init__(sim)
self.business=business
self.prod=business.production
@@ -14,7 +14,7 @@ class AutoProductionAgent(BaseAgent):
def can_produce(self):
# If can produce item
for k,cost in self.prod.items():
for k,cost in self.prod["craft"].items():
if cost > self.business.inventory[k]:
return False
return True
@@ -23,7 +23,7 @@ class AutoProductionAgent(BaseAgent):
if not self.can_produce():
return
# remove cost from inventory
for k,cost in self.prod.items():
for k,cost in self.prod["craft"].items():
self.business.inventory[k]-=cost
# add commodity
self.business.inventory[self.prod['name']]+=self.prod["amount"]