its starting to be more stable
This commit is contained in:
+1
-1
@@ -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
@@ -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.
@@ -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 = {}
|
||||
|
||||
|
||||
Binary file not shown.
+11
-1
@@ -66,13 +66,21 @@ 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):
|
||||
"""
|
||||
Executes a tick of the simulation
|
||||
@@ -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
|
||||
|
||||
@@ -28,28 +28,35 @@ 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()
|
||||
for i in range(NUM_SEED_BUS):
|
||||
sim.create_bussiness(1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
log.writeEXData()
|
||||
log.writeBusinessData()
|
||||
log.writePerformanceData()
|
||||
|
||||
Reference in New Issue
Block a user