Live data from Hacker News

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

szhu.github.io

61–70 of 73 posts

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

#61

Earlier quoted context omitted.

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…

replace the brute-force with a linear constraint solver, and you got yourself an MPC !

non-linear constraint solvers are not used because they cannot guarantee a time to solution, hence useless for control applications

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

#62

Earlier quoted context omitted.

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.

Obviously next you switch up the game to do things besides lunar landing. Have it be a take off ascent simulator for example. After a few years we can have an entire space mission programmed by gamers...

People have released very sophisticated autopilots for KSP. The game can practically play itself.

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

#63

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.

Thanks for this comment, I hadn't thought to try and sabotage my trajectory prior to engaging autopilot. I thought for sure it was gonna fail, but it managed to set me down gently right at the last moment quite brilliantly.

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

#64
Update: I improved the algorithm.

The autopilot now scores a "perfect landing" almost every single time, it lands very noticeably faster, and the code no longer contains a complicated, trial-by-error formula!

I got my first 103+ point landing! (It does this about half the time now)

https://user-images.githubusercontent.com/1570168/224399420-...

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

#65
post #48

One suggestion: if the lander is within about 10 feet of the ground and is still either swaying back and forth or going really fast laterally, it should thrust upwards to buy more time to correct those things.

oh yeah definitely. Left as an exercise for the reader?? (accepting PRs!)

Actually, I think my new algorithm fixes this -- and without any dedicated "swaying" edge case!

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

#66
post #8

I wanted to go for a record of as many flips as possible. So I boosted up to 25,000 feet; started spinning until it was doing about one flip per second; waited a few minutes; then turned on the autopilot to come into a landing. The autopilot did a perfect job of stopping the rotation and lateral motion, so the lander came down straight as an arrow. Unfortunately, the autopilot didn't even try to decelerate! I crashed…

Update: I added a new algorithm, and I think it might be impossible to crash the ship now.

Let me know if you can still reproduce the bug!

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

#68
post #66
post #8

I wanted to go for a record of as many flips as possible. So I boosted up to 25,000 feet; started spinning until it was doing about one flip per second; waited a few minutes; then turned on the autopilot to come into a landing. The autopilot did a perfect job of stopping the rotation and lateral motion, so the lander came down straight as an arrow. Unfortunately, the autopilot didn't even try to decelerate! I crashed…

Update: I added a new algorithm, and I think it might be impossible to crash the ship now. Let me know if you can still reproduce the bug!

Max speed: 148.7 Max height: 3998 Flips: 34

Perfect landing. :)

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

#70

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…

I wish I could play them in the browser instead of with apps.
Post reply on HN