ich glaube ich habe es langsam gefixet
This commit is contained in:
@@ -4,7 +4,7 @@ spec:
|
||||
max_world_price: 100
|
||||
|
||||
- name: "Food"
|
||||
max_world_price: 5
|
||||
max_world_price: 10
|
||||
|
||||
- name: "Grain"
|
||||
max_world_price: 5
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -23,6 +23,7 @@ class Base_Distribution_Agent(BaseAgent,ABC):
|
||||
self.tqty=0
|
||||
self.income_offset=0
|
||||
self.qty_offset=0
|
||||
self.trade_curser=0
|
||||
super().__init__(simulation)
|
||||
|
||||
def set_target(self,target: int):
|
||||
@@ -125,9 +126,13 @@ class Base_Distribution_Agent(BaseAgent,ABC):
|
||||
self.income_offset-=income_to_confirm
|
||||
self.qty_offset-=dis_qty
|
||||
self.income_offset=round(self.income_offset,2)
|
||||
self.trade_curser=len(self.trades)-1
|
||||
|
||||
def reset(self, episode):
|
||||
self.qty_offset=0
|
||||
self.tqty=0
|
||||
self.income_offset=0
|
||||
self.tincome=0
|
||||
self.trade_curser=0
|
||||
self.trades=[]
|
||||
return super().reset(episode)
|
||||
@@ -24,7 +24,7 @@ class Price_Believe_Distribiute_Agent(Base_Distribution_Agent):
|
||||
# aquire based on current price belive
|
||||
cx_id = self.select_best_cx()
|
||||
|
||||
price = round(self.price_believe[cx_id])
|
||||
price = round(self.price_believe[cx_id],2)
|
||||
if price < self.min_price:
|
||||
price = self.min_price
|
||||
order = self.distribute_resource(
|
||||
@@ -136,6 +136,7 @@ class Price_Believe_Distribiute_Agent(Base_Distribution_Agent):
|
||||
|
||||
def reset(self, episode):
|
||||
# Clean shop for today
|
||||
self.update_trades()
|
||||
for cx_id in range(len(self.exchanges)):
|
||||
cx = self.exchanges[cx_id]
|
||||
cx_orders = self.open_orders[cx_id]
|
||||
@@ -144,7 +145,7 @@ class Price_Believe_Distribiute_Agent(Base_Distribution_Agent):
|
||||
self.collect_balance_from_cxs()
|
||||
self.collect_resource_from_cxs(self.resource)
|
||||
# book keeping
|
||||
self.update_trades()
|
||||
|
||||
self.open_orders = {i: [] for i in range(len(self.exchanges))}
|
||||
self.orders = {i: {} for i in range(len(self.exchanges))}
|
||||
return super().reset(episode)
|
||||
|
||||
@@ -13,13 +13,13 @@ class Price_Believe_Business(Business):
|
||||
self.expense_per_unit = -1
|
||||
self.income_per_unit = -1
|
||||
self.distribute = Price_Believe_Distribiute_Agent(
|
||||
simulation, self, production["name"], exchange, 0.2, 20)
|
||||
simulation, self, production["name"], exchange, 0.2, 30)
|
||||
self.craft = AutoProductionAgent(simulation, self)
|
||||
self.aquire = {}
|
||||
|
||||
for k, v in production["prod"].items():
|
||||
a = Price_Believe_Aquire_Agent(
|
||||
simulation, self, k, exchange, 0.2, 10)
|
||||
simulation, self, k, exchange, 0.2, 5)
|
||||
a.set_target(v*2)
|
||||
a.set_price_max(10)
|
||||
self.aquire[k] = a
|
||||
@@ -47,8 +47,8 @@ class Price_Believe_Business(Business):
|
||||
ie = 0
|
||||
if ie > 1:
|
||||
ie = 1
|
||||
#retain=((self.max_storage-ie*self.max_storage)*amount)-amount
|
||||
retain=0
|
||||
retain=((self.max_storage-ie*self.max_storage)*amount)-amount
|
||||
#retain=0
|
||||
|
||||
|
||||
# set target for aquire
|
||||
@@ -124,6 +124,7 @@ class Price_Believe_Business(Business):
|
||||
return
|
||||
self.income_per_unit = qty_sold/income
|
||||
self.distribute.confirm_distribution(qty_sold, step)
|
||||
a=self.distribute.trade_curser
|
||||
|
||||
def close_business(self):
|
||||
for k, a in self.aquire.items():
|
||||
|
||||
Binary file not shown.
@@ -130,7 +130,7 @@ class Exchange():
|
||||
if amount<1:
|
||||
# invalid order
|
||||
return None
|
||||
full_price=round(price*amount)
|
||||
full_price=round(price*amount,2)
|
||||
|
||||
|
||||
# Move resources into escrow
|
||||
|
||||
2
main.py
2
main.py
@@ -41,7 +41,7 @@ sim.reset()
|
||||
while len(sim.get_underutelized_prods(1))>0:
|
||||
sim.create_bussiness(1)
|
||||
#sim.reset()
|
||||
for a in tqdm(range(50)):
|
||||
for a in tqdm(range(100)):
|
||||
for i in range(100):
|
||||
sim.tick(100)
|
||||
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']}")
|
||||
|
||||
Reference in New Issue
Block a user