Skip to content

Commit

Permalink
added galaxy probe tracking to conductor
Browse files Browse the repository at this point in the history
  • Loading branch information
Ctri-The-Third committed Feb 4, 2024
1 parent 3f10aaa commit f81d708
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 12 deletions.
22 changes: 11 additions & 11 deletions behaviours/explore_jumpgate_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,17 @@ def _run(self):
starting_gate, next_gate = self.find_uncharted_waypoints([current_gate.symbol])
starting_gate_sys = self.st.systems_view_one(waypoint_slicer(starting_gate))

arrived = self.ship_extrasolar_jump(starting_gate_sys.symbol)
if not arrived:
self.logger.error(f"Failed to jump to {starting_gate_sys.symbol}")
st.sleep(SAFETY_PADDING)
return
arrived = self.ship_intrasolar(starting_gate)
if not arrived:
self.logger.error(f"Failed to navigate to {starting_gate}")
st.sleep(SAFETY_PADDING)
return
if ship.nav.waypoint_symbol != starting_gate:
arrived = self.ship_extrasolar_jump(starting_gate_sys.symbol)
if not arrived:
self.logger.error(f"Failed to jump to {starting_gate_sys.symbol}")
st.sleep(SAFETY_PADDING)
return
arrived = self.ship_intrasolar(starting_gate)
if not arrived:
self.logger.error(f"Failed to navigate to {starting_gate}")
st.sleep(SAFETY_PADDING)
return
self.st.ship_jump(ship, next_gate)
self.st.ship_create_chart(ship)
self.pathfinder.validate_and_refresh_jump_graph(starting_gate_sys, next_gate)
Expand All @@ -114,7 +115,6 @@ def find_uncharted_waypoints(
destination_wayp = self.st.waypoints_view_one(connected_jumpgate)
# skip gates being built, we can't go there
if destination_wayp.under_construction:

checked_symbols.append(connected_jumpgate)
continue
destination = self.st.system_jumpgate(destination_wayp)
Expand Down
2 changes: 1 addition & 1 deletion behaviours/generic_behaviour.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ def sleep_until_arrived(self):

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 "D"
ship_number = sys.argv[2] if len(sys.argv) > 2 else "1"
ship = f"{agent}-{ship_number}"
bhvr = Behaviour(agent, ship, {})
bhvr.ship = bhvr.st.ships_view_one(ship, True)
Expand Down
36 changes: 36 additions & 0 deletions conductorWK25.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def __init__(
self.safety_margin = 0

self.managed_systems: list[ConductorSystem] = []
self.galaxy_probes = 0

# * progress missions
hq = self.st.view_my_self().headquarters
Expand Down Expand Up @@ -230,7 +231,40 @@ def system_daily_update(self, system: "ConductorSystem"):
def global_hourly_update(self):
"""Set ship behaviours and tasks"""
self._refresh_game_plan(self.game_plan_path)
# for each probe that's not in a managed system, set it to explore the galaxy
ships = list(self.st.ships_view().values())
behaviour_sql = """
select s.ship_symbol, behaviour_id from ships s left join ship_behaviours sb on s.ship_symbol = sb.ship_symbol
where s.agent_name = 'CTRI-U-'
"""
results = try_execute_select(behaviour_sql, ())
behaviours = {r[0]: r[1] for r in results}

probes = [ship for ship in ships if ship.role == "SATELLITE"]
global_probes = []
for probe in probes:
probe: Ship
if not behaviours.get(probe.name):
global_probes.append(probe)
elif probe.nav.system_symbol not in [
s.system_symbol for s in self.managed_systems
]:
global_probes.append(probe)

if len(global_probes) < self.galaxy_probes:
ship = maybe_buy_ship_sys2(
self.st,
self.managed_systems[0],
"SHIP_PROBE",
self.safety_margin,
)
if ship:
global_probes.append(ship)

for probe in global_probes:
set_behaviour(
probe.name, bhvr.BHVR_EXPLORE_JUMP_GATE_NETWORK, {"priority": 5}
)
pass

def system_hourly_update(self, system: "ConductorSystem"):
Expand Down Expand Up @@ -623,6 +657,7 @@ def _generate_game_plan(self, filename="game_plan.json"):
# STARTING SYSTEM
#
systems_being_managed = [s.system_symbol for s in self.managed_systems]

start_system_s = waypoint_slicer(st.view_my_self().headquarters)
start_system_obj = st.systems_view_one(waypoint_slicer(start_system_s))

Expand Down Expand Up @@ -656,6 +691,7 @@ def _generate_game_plan(self, filename="game_plan.json"):
start_system.haulers_constructing_jump_gate = 1
start_system.commander_trades = True
else:
self.galaxy_probes = 30
start_system.commander_trades = False
# reset this so the commander can be used to seed the system.
for l_system in self.managed_systems:
Expand Down

0 comments on commit f81d708

Please sign in to comment.