62 lines
1.4 KiB
Python
62 lines
1.4 KiB
Python
from lightmatchingengine.lightmatchingengine import LightMatchingEngine,Side,Trade,Order
|
|
from econ.exchange import Exchange
|
|
from econ.simulation import Simulation
|
|
from econ.business.Price_Believe_Business import Price_Believe_Business
|
|
from econ.commoditys import commoditys
|
|
from econ.cells import db, cell
|
|
import log
|
|
from tqdm import tqdm
|
|
import uuid
|
|
db.load_world("db/world.json")
|
|
|
|
commoditys.search_yaml_files()
|
|
|
|
cell_realm=[]
|
|
|
|
for c in db.world["cells"]["cells"]:
|
|
if c["province"]==187:
|
|
cell_realm.append(c)
|
|
|
|
cells=cell.create_cells_from_world_cells(cell_realm)
|
|
|
|
|
|
w="world"
|
|
cx=Exchange()
|
|
cxs=[cx]
|
|
# Init World
|
|
|
|
# Create Demand
|
|
#cx.submit_order(w,"Wood",0,1000,Side.BUY)
|
|
#cx.submit_order(2,"Gem",1,10,Side.SELL)
|
|
EPISODE_LEN=20
|
|
NUM_EPISODES=20
|
|
NUM_SEED_BUS=10
|
|
|
|
|
|
|
|
sim=Simulation()
|
|
sim.seed(43)
|
|
sim.set_cells(cells)
|
|
sim.reset()
|
|
for i in range(EPISODE_LEN):
|
|
sim.tick(EPISODE_LEN)
|
|
sim.reset()
|
|
# create info
|
|
while len(sim.get_underutelized_prods(2))>0:
|
|
sim.create_bussiness(2)
|
|
#sim.reset()
|
|
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()
|
|
|
|
print("help") |