its starting to be more stable

This commit is contained in:
2023-07-05 16:34:06 +02:00
parent 7554071405
commit da598c4475
7 changed files with 31 additions and 14 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ spec:
max_world_price: 100
- name: "Food"
max_world_price: 10
max_world_price: 30
- name: "Grain"
max_world_price: 5
+2 -2
View File
@@ -2,7 +2,7 @@ kind: production
spec:
- name: Grain
amount: 200
amount: 20
prod:
Raw_Agriculture_Plot: 1
- name: Fruit
@@ -24,7 +24,7 @@ spec:
prod:
# Fuel: 1
# Fruit: 1
Grain: 1
Grain: 2
Binary file not shown.
+1 -1
View File
@@ -14,7 +14,7 @@ class Price_Believe_Business(Business):
self.expense_per_prod=-1
self.income_per_unit = -1
self.distribute = Price_Believe_Distribiute_Agent(
simulation, self, production["name"], exchange, 0.2,production["amount"], 20)
simulation, self, production["name"], exchange, 0.2,production["amount"]*2, 20)
self.craft = AutoProductionAgent(simulation, self)
self.aquire = {}
+11 -1
View File
@@ -66,12 +66,20 @@ class Simulation():
tasks=[]
for k in keys:
fun=self.tick_funcs[k]
#row=[fun,self.tick_count,self.episode_count]
#tasks.append(row)
#self.taskpool.submit(self._execute_tick,row)
fun(self.tick_count,self.episode_count)
self.taskpool.map(self._execute_tick,tasks)
def _execute_tick(args):
def _execute_tick(self,args):
fun=args[0]
fun(args[1],args[2])
return True
def tick(self,episode_length):
"""
@@ -188,6 +196,8 @@ class Simulation():
for b in self.businesses:
id=b.production["id"]
if len(b.balance_history)<2:
continue
diff=b.balance-b.balance_history[-2]
if id not in profit:
profit[id]=0
+16 -9
View File
@@ -28,25 +28,32 @@ cxs=[cx]
# Create Demand
#cx.submit_order(w,"Wood",0,1000,Side.BUY)
#cx.submit_order(2,"Gem",1,10,Side.SELL)
EPISODE_LEN=100
NUM_EPISODES=100
NUM_SEED_BUS=5
sim=Simulation()
sim.seed(42)
sim.seed(43)
sim.set_cells(cells)
sim.reset()
for i in range(100):
sim.tick(100)
for i in range(EPISODE_LEN):
sim.tick(EPISODE_LEN)
sim.reset()
# create info
while len(sim.get_underutelized_prods(1))>0:
sim.create_bussiness(1)
while len(sim.get_underutelized_prods(2))>0:
sim.create_bussiness(2)
#sim.reset()
for a in tqdm(range(100)):
for i in range(100):
sim.tick(100)
for a in tqdm(range(NUM_EPISODES)):
for i in range(EPISODE_LEN):
sim.tick(EPISODE_LEN)
print(f"|Stats| Num of Businesses: {len(sim.businesses)} Num Tickfunk: {len(sim.tick_funcs)} Time Agent Tick: {sim.timings['dsa']} Time Logging {sim.timings['dbl']}")
sim.reset()
sim.create_bussiness(1)
for i in range(NUM_SEED_BUS):
sim.create_bussiness(1)