Skip to content

Commit

Permalink
fix issue with "extract and sell"
Browse files Browse the repository at this point in the history
  • Loading branch information
Ctri-The-Third committed Jan 22, 2024
1 parent cd03e06 commit 682b188
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions behaviours/explore_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ def find_unexplored_jumpgate(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 "5A"
ship_number = sys.argv[2] if len(sys.argv) > 2 else "1"
ship = f"{agent}-{ship_number}"
behaviour_params = None
behaviour_params = {"priority": 3.5, "target_sys": "X1-BC28"} # X1-TF72 X1-YF83
behaviour_params = {"priority": 3.5, "target_sys": "X1-DZ36"} # X1-TF72 X1-YF83
bhvr = ExploreSystem(agent, ship, behaviour_params or {})

lock_ship(ship, "MANUAL", duration=120)
Expand Down
2 changes: 1 addition & 1 deletion behaviours/extract_and_sell.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def run(self):
self._run()
self.end()

def run(self):
def _run(self):
# all threads should have this.

starting_credts = self.agent.credits
Expand Down
8 changes: 4 additions & 4 deletions blog/version 2.1.4 (week 27&28).md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

Database instability continues to be our woe - and we're now back to "idle in transaction" issues causing the database to be locked.

The first transaction to lock itself was one on node U - ship CTRI--4
`select total_seconds, expiration from ship_cooldown where ship_symbol = 'CTRI-U--4'`

Intestingly, the thread appears to have moved beyond the database (perhaps because it got a bad response from a timeout) and is now stuck waiting for the request consumer, which has jammed. Attempts to pause it and inspect are failing, which is fascinating.
* We've finally solved this with a mixture of restoring our old settings and properly applying them to the DB, and also implimenting connection pooling.
* Putting "Maintain supply chain" haulers onto the fab_mats and advanced_circuitry markets had a huge impact on the speed of construction.

## ramp up improvements - "Trade best"

Expand All @@ -27,6 +25,8 @@ Evolution and managing of markets ar actually super seperate, so before we start
* Difficulty! Because the local exchanges have TVs of 180, it takes a _while_ to push them into states where they're profitable to inflate their matching imports to ABUNDANT. So far we've seen liquid nitrogent frequently get up to HIGH and bump to 81TV. The exchange price for liquid nitrogen is around 32, and the the optimum sell price is something like 28. As such, I've increased the number of siphoners, since we're definitely extracting less than we need.

* Through this we've learned that a STRONG market generates/consumes 2*TV an hour, which is long enough to let a market slide ABUNDANT to HIGH. This is an opportunity for the task system, but leaves ships idle once the optimal state is achieved. Presently we've been saying "go and enhance the next market" but I think we might want might want to install traders with a singleton trade coordinator that guarantees collision avoidance. That way when finished doing an EVOLVE or MAINTAIN CHAIN they can do the nearest best trade instead, returning if necessary.
* Further conversation with a dev clarified why evolution doesn't occur immediately. the WEAK, GROWING, and STRONG values on the Activity enum are not reflections of 3 different states, instead much supply they map to a more granular variable that reflects the amount of a good that's consumed per hour. at STRONG this is 2*TV, at WEAK it's 1*TV (with some margin on either side.). RESTRICTED overrides this.
We were given a hint that MODERATE is enough to make this variable increase - once the variable is high enough (e.g. we're STRONG) we should tip the imports the rest of the way to trigger growth.

## Command and control

Expand Down
19 changes: 15 additions & 4 deletions dispatcherWK25.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def unlock_ship(self, ship_symbol, lock_id):
try_execute_upsert(sql, (ship_symbol, lock_id), self.connection)

def query(self, sql, args: list):
return try_execute_select(sql, args)
return try_execute_select(self.connection, sql, args)

def run(self):
print(f"----- DISPATCHER [{self.lock_id}] ACTIVATED ------")
Expand Down Expand Up @@ -299,7 +299,7 @@ def claim_task(self, task_hash, ship_symbol):
UPDATE public.ship_tasks
SET claimed_by= %s
WHERE task_hash = %s;"""
try_execute_upsert(sql, (ship_symbol, task_hash))
try_execute_upsert(self.connection, sql, (ship_symbol, task_hash))
pass

def get_task_for_ships(self, client: SpaceTraders, ship_symbol):
Expand Down Expand Up @@ -447,7 +447,17 @@ def maybe_scan_all_systems(self):


def get_fun_name():
prefixes = ["shadow", "crimson", "midnight", "dark", "mercury", "crimson", "black"]
prefixes = [
"shadow",
"crimson",
"midnight",
"dark",
"mercury",
"crimson",
"black",
"delta",
"gamma",
]
mid_parts = [
"fall",
"epsilon",
Expand All @@ -467,8 +477,9 @@ def get_fun_name():
"sky",
"titan",
"helios",
"nightmare",
]
suffixes = ["five", "seven", "nine", "prime"]
suffixes = ["five", "seven", "nine", "prime", "green"]
prefix_index = random.randint(0, len(mid_parts) - 1)
mid_index = random.randint(0, len(mid_parts) - 1)
suffix_index = random.randint(0, len(mid_parts) - 1)
Expand Down

0 comments on commit 682b188

Please sign in to comment.