Skip to content

Commit

Permalink
fixed issue with supply chain buying at sell point
Browse files Browse the repository at this point in the history
  • Loading branch information
Ctri-The-Third committed Jan 22, 2024
1 parent 8f82eca commit cd03e06
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
6 changes: 6 additions & 0 deletions behaviours/_empty_behaviour.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ def run(self):
self._run()
self.end()

def end(self):
self.st.logging_client.log_ending(
BEHAVIOUR_NAME, self.ship.name, self.st.view_my_self().credits
)
super().end()

def default_params_obj(self):
return_obj = super().default_params_obj()

Expand Down
6 changes: 6 additions & 0 deletions behaviours/buy_and_deliver_or_sell.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ def run(self):
self._run()
self.end()

def end(self):
self.st.logging_client.log_ending(
BEHAVIOUR_NAME, self.ship.name, self.st.view_my_self().credits
)
super().end()

def default_params_obj(self):
return_obj = super().default_params_obj()
return return_obj
Expand Down
13 changes: 13 additions & 0 deletions behaviours/buy_and_sell_dripfeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ def run(self):
self._run()
self.end()

def end(self, error=None):
super().end()
self.st.logging_client.log_ending(
BEHAVIOUR_NAME,
self.ship.name,
self.agent.credits,
{"end_reason": error} if error else None,
)
if error:
self.logger.error(error)
self.st.release_connection()
self.st.sleep(SAFETY_PADDING)

def default_params_obj(self):
return_obj = super().default_params_obj()
return return_obj
Expand Down
15 changes: 11 additions & 4 deletions behaviours/manage_supply_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ def run(self):
self._run()
self.end()

def end(self):
self.st.logging_client.log_ending(
BEHAVIOUR_NAME, self.ship.name, self.st.view_my_self().credits
)
super().end()

def _run(self):
st = self.st
ship = self.ship # = st.ships_view_one(self.ship_name, True)
Expand Down Expand Up @@ -115,9 +121,10 @@ def _run(self):
best_market = market
best_cost = tg.purchase_price
next_good = item
if not best_market:
self.logger.info("No unrestricted trades found")
if best_market.symbol == sell_market.symbol:
self.logger.info("No suitable source of %s found", next_good)
self.st.sleep(SAFETY_PADDING)
return
buy_wp_s = best_market.symbol
if not next_link:
# next_link = self.search_deeper_for_under_evolved_export(self.chain)
Expand Down Expand Up @@ -551,11 +558,11 @@ class TradeRoute:

set_logging(level=logging.DEBUG)
agent = sys.argv[1] if len(sys.argv) > 2 else "CTRI-U-"
ship_number = sys.argv[2] if len(sys.argv) > 2 else "11"
ship_number = sys.argv[2] if len(sys.argv) > 2 else "4A"
ship = f"{agent}-{ship_number}"
behaviour_params = {
"priority": 3,
"target_tradegood": "CLOTHING",
"target_tradegood": "ANTIMATTER",
}

while True:
Expand Down
6 changes: 3 additions & 3 deletions conductorWK25.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,9 @@ def set_hauler_tasks(self, system: "ConductorSystem") -> int:
+ system.haulers_chain_trading
+ system.haulers_doing_missions
+ system.haulers_evolving_markets
+ 1
+ (1
if system.construct_jump_gate
else 0
else 0)
)
# set up the haulers to go to the markets and buy stuff
# chain trade 3
Expand Down Expand Up @@ -650,7 +650,7 @@ def _generate_game_plan(self, filename="game_plan.json"):
if start_gate:
gate = start_gate[0]
gate: Waypoint
gate_complete = gate.under_construction
gate_complete = not gate.under_construction
if gate.under_construction:
start_system.construct_jump_gate = True
start_system.commander_trades = True
Expand Down

0 comments on commit cd03e06

Please sign in to comment.