From da598c44751ca3be525b8f4335b421d571fdff95 Mon Sep 17 00:00:00 2001 From: Manuel Plonski Date: Wed, 5 Jul 2023 16:34:06 +0200 Subject: [PATCH] its starting to be more stable --- db/commoditys.yml | 2 +- db/production.yml | 4 +-- econ/__pycache__/simulation.cpython-310.pyc | Bin 8510 -> 8548 bytes econ/business/Price_Believe_Business.py | 2 +- .../Price_Believe_Business.cpython-310.pyc | Bin 4280 -> 4284 bytes econ/simulation.py | 12 ++++++++- main.py | 25 +++++++++++------- 7 files changed, 31 insertions(+), 14 deletions(-) diff --git a/db/commoditys.yml b/db/commoditys.yml index 2d6886e..fb40154 100644 --- a/db/commoditys.yml +++ b/db/commoditys.yml @@ -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 diff --git a/db/production.yml b/db/production.yml index f89e429..2834f04 100644 --- a/db/production.yml +++ b/db/production.yml @@ -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 diff --git a/econ/__pycache__/simulation.cpython-310.pyc b/econ/__pycache__/simulation.cpython-310.pyc index 8ecbbd57bee42e8aa2ba39c08f2e04229a00eafe..8414d0720eff6666fb516077565166110dd30bc4 100644 GIT binary patch delta 500 zcmXAlKWJ1z5XSf0xBG5Ab9eH{nR~{&hzTZXECf;HAb8q|Ni?ZM2`|2=mp^yh-YF`( zq)4L}t1SXnrVu+tUnwXyc4-x~O%YK7Ru&O-)-23#znNKvZ}xp-yHRWx3VBB7vVDHw&pCkFdypIu|o+V6DbVGtd1i>FxW|}K^my=$z-8wn9a6fx}V4h<(i~4?Ybh5w2 z31B^&IP{8RBioHG0B_x?{;R8xXhM@&7`DhRvKyn`?Bc%dpyze4M%I^@?(ay-gs=D| zD$EKK7~F#%Nriz4>a?B-B%?LO85XcQ>&R4EnT9qrcrG{n{J!hl=BzTIQ8e?sDJg2^ ztn8dNl71xTc=-y~bvIo;aw60NWKQ4mXb`TI=9A^5b#r0vPP5x<>j(N0Ro#>FRP=#F z_c%d_JkO&Dp6!(PfNySl;4^->ca<%C$sWg_fZc3*unO#Dt)o@&5bkO9BT8&fO|6}kd z{!bw4EAjLd+S3PPIZSG`Yhavbd2W37Z?YOja|1HTUL}jKo zBc<3g3Y&JDz!aKxL^7N<{oXmlnh7Vy5qHg0?{|iu%w^vM;#WQT=;iiD>aW=gVFe~( zp%gI1R`6bgLy^rKDyKZZevKf^qkO^&LwB{S~C6Em1$BU-&%T3^g6LreP8{s{ATf8t+`&8 zoBCVwMf@jK?*EDND2tkS>IU(Tj%NPisXongv1<;qCx~aJl`9}#n9unFvRlxm@Ecvd eQ9MAQ)1^K1bf@^JW>?IsEtThbHOh7hg zCIgVfs)oIWC4~j3ldYDshI0XL4Mz&wWL+j{ mM$^fjOg;id%s`u7iU5gQECogRDVvuvRWdS4ZI)-5$pZlFvm-tL delta 91 zcmdm^xI>XQpO=@50SLkvm!uePlMnPx# diff --git a/econ/simulation.py b/econ/simulation.py index dc3785e..12b66cc 100644 --- a/econ/simulation.py +++ b/econ/simulation.py @@ -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 diff --git a/main.py b/main.py index 9f9c607..9b74720 100644 --- a/main.py +++ b/main.py @@ -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) + +