Live data from Hacker News

Show HN: I built an autopilot for the lunar lander game

szhu.github.io

31–40 of 73 posts

Re: Show HN: I built an autopilot for the lunar lander game

#31

It’s amazing how a simple algorithm performs so well, the autopilot is able to recover from some pretty extreme situations, and does it gracefully. Adding some realism to the engine physics (firing delays, minimum firing time, power ramp up, heat limits etc) would likely make it 10x harder.

Especially nondeterminism. Everything you say is still deterministic, so either you're able to land or you're not. With nondeterminism it's more interesting. You have to make tradeoffs between optimizing resources and making success probable.

Re: Show HN: I built an autopilot for the lunar lander game

#32
Nice auto pilot! Very basic, but works well enough.

In the real world, you would derive physics equations (acceleration -> velocity -> position), add constraints and then solve everything to obtain an optimal trajectory (mostly in term of fuel, but you can add other constraints too, for ex due to radar-ground or Antenna-Earth visibility). I wrote a blog post about Apollo's algorithm: https://blog.nodraak.fr/2020/12/aerospace-sim-2-guidance-law... (Described in the second section ; the first section is about a naive algorithm similar to yours that in the end did not work as well as I wanted).

Also, thanks for the code, I wanted to do the same, but lost motivation when I could not really expose in a satisfying way the internal state out of these JS modules (it's not complicated in the end, but I'm simply not a frontend dev ; and I wanted to avoid forking and monkey patching everything and simply adding some JS code throught the console or something).

Re: Show HN: I built an autopilot for the lunar lander game

#33
post #26

Earlier quoted context omitted.

Which points to a lovely idea - the game becomes writing competitive lander algorithms. Just need a bit of JSFiddle adding...

That'd be very fun indeed!

Maybe not for long, because for a given set of constraints to optimze for, there's probably a solution for which it can be proven to be optimal. At that point there's no more contest.

Re: Show HN: I built an autopilot for the lunar lander game

#34
Lunar lander is a one of the problems in Open AI Gym, where you test AI against standard set of problems: https://www.gymlibrary.dev/environments/box2d/lunar_lander/

Then you have stable baselines which implements popular reinforcement learning algorithms to solve these gym problems: https://stable-baselines3.readthedocs.io/en/master/

Shamless plug: I've built a series of games where you solve puzzles (2048) / toy problems (MDP) like the lunar lander using various AI and ML algorithms.

You can check it out here: https://ai-simulator.com/

Re: Show HN: I built an autopilot for the lunar lander game

#35
post #22

What about adding a limited fuel supply?

For what it’s worth fuel is in the original arcade game.

“Unlike other arcade games, Lunar Lander does not feature a time limit; instead, the game starts with a set amount of fuel and inserting additional quarters purchases more fuel, allowing indefinite gameplay.“

https://en.m.wikipedia.org/wiki/Lunar_Lander_(1979_video_gam...

Re: Show HN: I built an autopilot for the lunar lander game

#36
post #6

It's interesting to think about how the optimal strategy to land the lander would look like. If the distance to the moon was large, I would expect 4 phases: 1: Turn the lander towards the moon 2: Constant thrust towards the moon 3: Turn the lander away from the moon 4: Constant thrust away from the moon But if the initial distance is small enough, turning it around might not be worth it or even possible. So the optim…

when discussing about optimality, it is worth specifying what are you optimising for. time optimal landing lends techniques from bang-bang control (e.g. starting with v=0, max thrust towards the target, before flipping around half way and max thrust away from target) fuel optimal landing (incuding RCS) technique would depend on the available time to turn retrograde (pointy end pointing away from direction of movement…

In implementing an AI to achieve orbit in a Spacewar-style simulation with gravity, I ended up with a brute-force constraint optimizer that resembles MCP(I've never studied the theory): for each timestep, predict the solutions resulting for each combination of digital thrust inputs(left, right, forward, backwards). Then predict ahead several more steps with additional permutations of input. Then evaluate distance to goal and rank final solution by distance to target orbit and velocity match.

In doing this, it results in a few hundreds to thousands of solutions to test per timestep, which modern CPUs can shrug off easily. Not nearly as elegant as closed-form control theory systems, but easy to tune and give different goals.

Re: Show HN: I built an autopilot for the lunar lander game

#37

Lunar lander is a one of the problems in Open AI Gym, where you test AI against standard set of problems: https://www.gymlibrary.dev/environments/box2d/lunar_lander/ Then you have stable baselines which implements popular reinforcement learning algorithms to solve these gym problems: https://stable-baselines3.readthedocs.io/en/master/ Shamless plug: I've built a series of games where you solve puzzles (2048) / toy pr…

Yes, I would like to see the environment ported to Python, wrapped in gym, and given a good shaped reward, i.e. like reward = prior_height_delta - (height - target_height) - fuel_cost. Run Stable Baselines PPO or DQN on that and it should converge to something close to an optimized MPC controller.

Re: Show HN: I built an autopilot for the lunar lander game

#39

Lunar lander is a one of the problems in Open AI Gym, where you test AI against standard set of problems: https://www.gymlibrary.dev/environments/box2d/lunar_lander/ Then you have stable baselines which implements popular reinforcement learning algorithms to solve these gym problems: https://stable-baselines3.readthedocs.io/en/master/ Shamless plug: I've built a series of games where you solve puzzles (2048) / toy pr…

Looking at your website I’m curious how exactly you’re building «ChatGPT for mobile games»? Are you using language models to build these AI solvers?

Re: Show HN: I built an autopilot for the lunar lander game

#40
post #39

Lunar lander is a one of the problems in Open AI Gym, where you test AI against standard set of problems: https://www.gymlibrary.dev/environments/box2d/lunar_lander/ Then you have stable baselines which implements popular reinforcement learning algorithms to solve these gym problems: https://stable-baselines3.readthedocs.io/en/master/ Shamless plug: I've built a series of games where you solve puzzles (2048) / toy pr…

Looking at your website I’m curious how exactly you’re building «ChatGPT for mobile games»? Are you using language models to build these AI solvers?

Well to be honest it is just a marketing term I am using to try to get some attention.

In a way what I am building is a "general AI engine" that is capable of taking in an arbitrary game and play it, which is somewhat conceptually similar to how ChatGPT is a general AI that is able to solve a wide range of text-based tasks.

Post reply on HN