spacetraders-v2 · Apr 18–21, 2024 · v2.10–v2.11

Trading contracts, monitoring markets

trading contracts v2.10

With my hourly income going into the negatives due to bottoming out the price of ore, I’ve spent some time implementing a trading approach for the command ship so I can complete contracts that require trade goods. This required at least a lap of the markets in the system to probe the price details of each trade good. This recon went well until the final waypoint that appeared to have a market but no fuel - the ship promptly ran out of gas and I had to write code to drift to the closest waypoint with a fuel supply. After the recon was complete, contract trading appeared to work until the ship got stuck in a loop between waypoints.

On investigation it appeared the current contract required the ship to move through a distant waypoint that expended most of the fuel, and had no fuel supply. Drifting back to the nearest waypoint with fuel available executed correctly, but then the logic would push the ship back through the same distant waypoint and the cycle would repeat. I’ll need to update the navigation logic to be aware of fuel requirements and availability so the ship can buy extra fuel and store it in cargo should a route require it.

To help with this, I’ve added a Grafana panel that allows me to visualise the layout of waypoints in the system. I was unable to find a cartesian plane or similar visualisation in Grafana, so instead i’ve hacked the Geomap visualisation to achieve this. I’ve chosen an empty point in the ocean, zoomed in as far as it’ll go, and used that point as the origin. I’ve then plotted the waypoints of the system as offsets from this origin. Perhaps in the future I’ll add ship position to this panel.

waypoint layout

monitoring markets v2.11

Contracts have proved profitable enough to get me onto the leaderboard, though there’s still a few problems.

leaderboard
leaderboard

There were still a few routing issues that mean the ship was flying through areas with no fuel. I was able to pull the routing code from my earlier work for v1 and adapt it for v2 so the ship is now less likely to to navigate through areas without fuel. This still happens when there is no direct route however, and I still need to write code to buy fuel and store it in cargo to reduce the amount of legs the ship needs to drift

Additionally, there was at least one contract where the earnings were negative - for now I’ll just wear this cost but there could be opportunities to source the goods cheaper in other systems or via refining.

Now that contracting is working, I’ll need to start using the data collected from markets to increase profits by trading goods. I’ve built another Grafana dashboard to help monitor market goods and prices, and, I’ve implemented code to buy and navigate satellites to market waypoints to monitor prices.

market dashboard
market dashboard