Version 2 of my spacetraders.io bot
Go to file
Richard Bronkhorst 537615e582 Update base.py
2023-07-12 22:36:29 +02:00
nullptr Update base.py 2023-07-12 22:36:29 +02:00
.dockerignore Initial setup 2023-06-05 22:16:29 +02:00
.gitignore Initial setup 2023-06-05 22:16:29 +02:00
Dockerfile New store setup 2023-07-10 19:25:01 +02:00
main.py . 2023-07-10 21:10:49 +02:00
Readme.md Add Readme.md 2023-07-02 14:33:19 +02:00
requirements.txt Update commander.py, Dockerfile and twenty-five other files 2023-06-11 20:51:03 +02:00
store.md New store setup 2023-07-10 19:25:01 +02:00

0ptr script for spacetraders.io

This is my script for running spacetraders.io. It has been completely written and operated from an iphone.

Because i'm using a less-than-optimal development platform, some 'best-practice' code standards have been thrown out of the window. For instance, some variables have obscure names just to keep them short.

The script offers a command-line interface allowing you to do most ST operations by hand. More importantly, it offers the functionality to assign missions to ships and execute them automatically.

Getting started

I'm using the pythonista app to develop and test the script. Just open main.py and hit run.

To keep the script running for longer periods of time, I'm using a VPS with docker. Start the script like so:

docker run -v 0ptr:/data -ti 0ptr

The script will ask for an agent name. Make sure you choose a unique one. After hitting enter, you will be presented with the prompt: >

Now you'll want to register. You need to provide your faction:

> register cosmic

If all goes well, you should have an account now.

Next is building up our view of the universe: the atlas.

> universe

This command will iterate over all systems and obtain all waypoint information. this will take several hours. However, if you are impatient, you can stop the process after a couple of minutes by hitting enter. It should at least have indexed your local system to continue.

Now, let's see what ships we own.

> ships refresh

This will populate our internal cache of present ships and their state. After this, the state is updated continually by each command that alters it. You should be able to omit the 'refresh' after this.

We should also populate the cache of contracts:

> contracts refresh

Same here: you can omit the 'refresh' from now on and view your contracts with the bare contracts command without sending a http request.

You are now ready to begin operations.

Operations

To get a ship to do something, you first have to select it:

> ship 1
KILO-1 DOCKED [1035/1200] X1-YU85-03282C
KILO-1> 

This prints the current state of the ship. Notice that the prompt now includes the name of the ship. Any command you now give will be executed by that ship.

A quick, non-complete list of commands:

  • go: intra-system travel to another waypoint
  • orbit
  • dock
  • market: show local market data
  • shipyard: show local shipyard data
  • jumps: show local jumpgate data
  • mission: set ships mission type
    • mine: mine and deliver a resource
    • probe: find resource prices in nearby markets
    • survey: generate surveys in a loop
    • travel: travel to any waypoint in the universe using jumpgates (assuming a route is found)
    • haul: buy goods at a site and bring them to a destination
  • mset: set a mission parameter
  • purchase: purchase a ship at a shipyard
  • buy: buy a resource at the local market
  • sell: sell a resource at the local market
  • jump: jump to a remote system using the local jumpgate
  • cmine: configures a mining mission for the current contract
  • chaul configures a hauling mission for the current contract
  • cprobe: configures a probing mission for the current contract
  • query: lists nearest markets and buy prices (if known) of a resource

Look in commander.py for more available commands.

Data storage

The script stores each object in a separate json file in the data directory. The default location for this directory is in your workingdir. The docker image places the data dir in '/data'

If you want to re-register an agent, or there is a sever reset, just delete all data in that directory.