Autopilot for Oolite

General discussion for players of Oolite.

Moderators: winston, another_commander

User avatar
hiran
Theorethicist
Posts: 2266
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Autopilot for Oolite

Post by hiran »

I just stumbled across this article describing how to milk-run with automation:
http://www.jeffmcaffee.com/creating-a-simple-bot/

Impressive, the concept works by simply pushing keyboard events into Oolite. Plus the script looks at the screen to validate where it's going. Just like - ummm - me when flying here and there.

Would that be a base for an OXP or be more suitable for an external tool as it is now? Or should we pretend it does not exist? Or is this a job for the debug console?
Sunshine - Moonlight - Good Times - Oolite
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4777
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Autopilot for Oolite

Post by phkb »

hiran wrote: Tue May 14, 2024 8:07 pm
Would that be a base for an OXP or be more suitable for an external tool as it is now?
You could OXP the entire thing, if you wanted, without needing to use an external tool. If fact, you could do it better, because you could interrogate the game state in a far more exhaustive and accurate way.
hiran wrote: Tue May 14, 2024 8:07 pm
Plus the script looks at the screen to validate where it's going. Just like - ummm - me when flying here and there.
I'd challenge the idea that the script is looking at the screen. The script is "assuming" a certain game state based on the results of keypresses beforehand. For instance, the script to buy/sell furs will fail every time if you have SW Economy installed, which adds 3 extra commodities. The script is not checking to see if "Furs" is highlighted - it's "assuming" furs is highlighted because in the default game that's where you end up if you press "8" and then "down arrow" 11 times.
User avatar
hiran
Theorethicist
Posts: 2266
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Autopilot for Oolite

Post by hiran »

phkb wrote: Tue May 14, 2024 10:19 pm
You could OXP the entire thing, if you wanted, without needing to use an external tool. If fact, you could do it better, because you could interrogate the game state in a far more exhaustive and accurate way.
That's what I thought as well. And then I thought we might want to create a custumizable set of autopilot maneuvers, with one of the possibilities being the milk run. Another one could be evading pirates.

If done properly we could even communicate the game state as text and feed it into a generic pre-trained processor to see what keys it would press.
phkb wrote: Tue May 14, 2024 10:19 pm
hiran wrote: Tue May 14, 2024 8:07 pm
Plus the script looks at the screen to validate where it's going. Just like - ummm - me when flying here and there.
I'd challenge the idea that the script is looking at the screen. The script is "assuming" a certain game state based on the results of keypresses beforehand. For instance, the script to buy/sell furs will fail every time if you have SW Economy installed, which adds 3 extra commodities. The script is not checking to see if "Furs" is highlighted - it's "assuming" furs is highlighted because in the default game that's where you end up if you press "8" and then "down arrow" 11 times.
I referenced the first of four pages. On the third this guy discusses taking screenshots and interpreting those. That is necessary to reliably navigate to the planet/station. And may be reused elsewhere.

With that technology he can create autopilots for any game.

And this seems to have worked. The guy published the scripts here: https://github.com/jmcaffee/oolite_bot
I have not tested them though.
Sunshine - Moonlight - Good Times - Oolite
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4777
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Autopilot for Oolite

Post by phkb »

hiran wrote: Wed May 15, 2024 4:24 am
I referenced the first of four pages. On the third this guy discusses taking screenshots and interpreting those. That is necessary to reliably navigate to the planet/station. And may be reused elsewhere.
The trouble is, this method is completely dependent on a number of factors:
(1) The screen size *cannot* change. He even says so: "As long as you always play with the game window at the same size, these coordinates will not change." So, every instance of the autopilot would need to be customised for the local game window.
(2) The HUD cannot change. He is assuming the space compass will be in exactly the same location, with the exact colors as he used to build the script. Any deviation from that standard and you need to reconfigure the script to work with the new layout.
(3) The list of commodities cannot change. The script expects Textiles to be after food, then radioactives, then slaves, and so on. Any additional commodities that throw out this order will result in breakage.

While his method is clever and instructive, and achieves his goal within a limited set of parameters, I can't see this method coping with the mix of mods that tend to get loaded. It's really only effective for the base game, and even then it's limited to a fixed game window.

If you're after a fully integrated auto-pilot/auto-trade system, our scripting environment is much better suited to the job.
User avatar
hiran
Theorethicist
Posts: 2266
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Autopilot for Oolite

Post by hiran »

Yes I also believe what he achieved could have been done better in an OXP. He took a different approach and that's what I like:

He controlled Oolite without requiring internal knowledge.
He used simply Bash and a few command line tools.

Likely I'd not try to OXP this as that would be quite a lock-in. OXPs cannot access the disk or network.
Via debug console this could be controlled from outside yet still have access to the game's internal state.
Sunshine - Moonlight - Good Times - Oolite
User avatar
hiran
Theorethicist
Posts: 2266
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Autopilot for Oolite

Post by hiran »

hiran wrote: Thu May 16, 2024 4:24 am
Yes I also believe what he achieved could have been done better in an OXP. He took a different approach and that's what I like
Ok, meanwhile I learned what this guy achieved is not achievable via OXPs: at least the ship's speed cannot be controlled.

See viewtopic.php?p=296660#p296660
Sunshine - Moonlight - Good Times - Oolite
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4777
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Autopilot for Oolite

Post by phkb »

I’m pretty sure you can set the ship velocity via JS. It’s a vector though, so you can’t just do player.ship.speed = 320;. I can’t get to an environment to test this right now, but I’m almost certain it would work.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4777
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Autopilot for Oolite

Post by phkb »

If you’re looking for an example mod, see the “Fuel Injection Cruise Control” mod. It’s doing things at injector speeds, but the logic would be the same for normal speeds.
User avatar
hiran
Theorethicist
Posts: 2266
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Autopilot for Oolite

Post by hiran »

phkb wrote: Thu Jun 13, 2024 8:17 am
If you’re looking for an example mod, see the “Fuel Injection Cruise Control” mod. It’s doing things at injector speeds, but the logic would be the same for normal speeds.
This page should list fhe scripts although I am not yet sure what snippet to look at.
https://ooliteproject.github.io/oolite- ... ntrol.html

Edit: this looks like a speed setting to me:

Code: Select all

// velocity adjustment method
p.velocity = p.vectorForward.multiply(parseFloat(p.maxSpeed * p.injectorSpeedFactor) * ps._accel);
Sunshine - Moonlight - Good Times - Oolite
User avatar
Cholmondely
Archivist
Archivist
Posts: 5188
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Autopilot for Oolite

Post by Cholmondely »

hiran wrote: Wed May 15, 2024 4:24 am
phkb wrote: Tue May 14, 2024 10:19 pm
You could OXP the entire thing, if you wanted, without needing to use an external tool. If fact, you could do it better, because you could interrogate the game state in a far more exhaustive and accurate way.
That's what I thought as well. And then I thought we might want to create a custumizable set of autopilot maneuvers, with one of the possibilities being the milk run. Another one could be evading pirates.

If done properly we could even communicate the game state as text and feed it into a generic pre-trained processor to see what keys it would press.
phkb wrote: Tue May 14, 2024 10:19 pm
hiran wrote: Tue May 14, 2024 8:07 pm
Plus the script looks at the screen to validate where it's going. Just like - ummm - me when flying here and there.
I'd challenge the idea that the script is looking at the screen. The script is "assuming" a certain game state based on the results of keypresses beforehand. For instance, the script to buy/sell furs will fail every time if you have SW Economy installed, which adds 3 extra commodities. The script is not checking to see if "Furs" is highlighted - it's "assuming" furs is highlighted because in the default game that's where you end up if you press "8" and then "down arrow" 11 times.
I referenced the first of four pages. On the third this guy discusses taking screenshots and interpreting those. That is necessary to reliably navigate to the planet/station. And may be reused elsewhere.

With that technology he can create autopilots for any game.

And this seems to have worked. The guy published the scripts here: https://github.com/jmcaffee/oolite_bot
I have not tested them though.
Hiran: could you help me create a page on McAfee's Oolite_bot for our wiki? Do you know if anybody has tried it out yet?

So far all there seems to be is the two links to github and to his website.
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
hiran
Theorethicist
Posts: 2266
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Autopilot for Oolite

Post by hiran »

Cholmondely wrote: Sun Jun 30, 2024 9:23 am
I referenced the first of four pages. On the third this guy discusses taking screenshots and interpreting those. That is necessary to reliably navigate to the planet/station. And may be reused elsewhere.

With that technology he can create autopilots for any game.

And this seems to have worked. The guy published the scripts here: https://github.com/jmcaffee/oolite_bot
I have not tested them though.
Hiran: could you help me create a page on McAfee's Oolite_bot for our wiki? Do you know if anybody has tried it out yet?

So far all there seems to be is the two links to github and to his website.
[/quote]

I'm willing to help. So far I do not know of anyone having tried the documented approach. But as I learned you cannot control the ship from within an OXP this kind of autopilot seems the only viable alternative. It is worth keeping that knowledge.

So what wiki page should we create? And would it not be worth validating the scripts first?
Sunshine - Moonlight - Good Times - Oolite
User avatar
Cholmondely
Archivist
Archivist
Posts: 5188
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Autopilot for Oolite

Post by Cholmondely »

hiran wrote: Mon Jul 01, 2024 9:47 pm
I referenced the first of four pages. On the third this guy discusses taking screenshots and interpreting those. That is necessary to reliably navigate to the planet/station. And may be reused elsewhere.

With that technology he can create autopilots for any game.

And this seems to have worked. The guy published the scripts here: https://github.com/jmcaffee/oolite_bot
I have not tested them though.
Cholmondely wrote: Sun Jun 30, 2024 9:23 am
Hiran: could you help me create a page on McAfee's Oolite_bot for our wiki? Do you know if anybody has tried it out yet?

So far all there seems to be is the two links to github and to his website.
hiran wrote: Mon Jul 01, 2024 9:47 pm
I'm willing to help. So far I do not know of anyone having tried the documented approach. But as I learned you cannot control the ship from within an OXP this kind of autopilot seems the only viable alternative. It is worth keeping that knowledge.

So what wiki page should we create? And would it not be worth validating the scripts first?
I can create the basic page with the links and whatnot. But it will also need a description (and possibly even some pretty pictures) of the working bot if you think you can manage to get it working...
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2353
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Autopilot for Oolite

Post by Wildeblood »

hiran wrote: Mon Jul 01, 2024 9:47 pm
But as I learned you cannot control the ship from within an OXP this kind of autopilot seems the only viable alternative.
It's just wrong to say that, hiran. The player ship object has literally hundreds of properties, and most are read/write. There are a handful of important ones that are still read-only, and you found the most obvious and important one in player.ship.speed. But, the blanket statement that one "cannot control the ship from within an OXP" is misleading, and overly pessimistic.

Consider yourself admonished, for spreading pessimism.
"Would somebody stop that bloody music!"
User avatar
hiran
Theorethicist
Posts: 2266
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Autopilot for Oolite

Post by hiran »

Wildeblood wrote: Tue Jul 02, 2024 5:48 am
It's just wrong to say that, hiran. The player ship object has literally hundreds of properties, and most are read/write. There are a handful of important ones that are still read-only, and you found the most obvious and important one in player.ship.speed. But, the blanket statement that one "cannot control the ship from within an OXP" is misleading, and overly pessimistic.

Consider yourself admonished, for spreading pessimism.
From my desk the possibilities for autopilot are too limited. That is all I am stating.

I'd be delighted to be proven wrong and see a proof of concept. Do you know any?
Sunshine - Moonlight - Good Times - Oolite
User avatar
hiran
Theorethicist
Posts: 2266
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Autopilot for Oolite

Post by hiran »

I just had a closer look at Jeff's solution. It uses xdotool to fire off keyboard input into Oolite.
xdotool works with X.org display server. However since a couple of years Ubuntu migrated towards the Wayland display server - and xdotool cannot deal with that.
Now there might be something like kdotool, dotool but they all require some extra effort.
Sunshine - Moonlight - Good Times - Oolite
Post Reply