Autopilot for Oolite
Moderators: winston, another_commander
- hiran
- Theorethicist
- Posts: 2403
- Joined: Fri Mar 26, 2021 1:39 pm
- Location: a parallel world I created for myself. Some call it a singularity...
Autopilot for Oolite
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?
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
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Autopilot for Oolite
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.
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.
- hiran
- Theorethicist
- Posts: 2403
- 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
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.
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.phkb wrote: ↑Tue May 14, 2024 10:19 pmI'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.
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
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Autopilot for Oolite
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.
- hiran
- Theorethicist
- Posts: 2403
- 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
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.
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
- hiran
- Theorethicist
- Posts: 2403
- 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
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
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Autopilot for Oolite
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.
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Autopilot for Oolite
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.
- hiran
- Theorethicist
- Posts: 2403
- 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
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
- Cholmondely
- Archivist
- Posts: 5365
- 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
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?hiran wrote: ↑Wed May 15, 2024 4:24 amThat'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.
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.phkb wrote: ↑Tue May 14, 2024 10:19 pmI'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.
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.
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?
•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?
- hiran
- Theorethicist
- Posts: 2403
- 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
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?Cholmondely wrote: ↑Sun Jun 30, 2024 9:23 amI 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.
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
- Cholmondely
- Archivist
- Posts: 5365
- 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
hiran wrote: ↑Mon Jul 01, 2024 9:47 pmI 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 amHiran: 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.
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...hiran wrote: ↑Mon Jul 01, 2024 9:47 pmI'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?
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?
•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?
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Autopilot for Oolite
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.
In your heart, you know it's flat.
- hiran
- Theorethicist
- Posts: 2403
- 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
From my desk the possibilities for autopilot are too limited. That is all I am stating.Wildeblood wrote: ↑Tue Jul 02, 2024 5:48 amIt'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.
I'd be delighted to be proven wrong and see a proof of concept. Do you know any?
Sunshine - Moonlight - Good Times - Oolite
- hiran
- Theorethicist
- Posts: 2403
- 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
I just had a closer look at Jeff's solution. It uses
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.
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