Live data from Hacker News

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

szhu.github.io

41–50 of 73 posts

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

#41
post #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.

It is already there, just not this particular implementation (or maybe it is?).

You can run PPO or DQN right now on the Open AI Gym implementation using Stable-Baselines3: https://stable-baselines3.readthedocs.io/en/master/

In fact I previously ran it locally and PPO solved the problem within 10 minutes of training with max reward of about 200.

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

#43
post #23

That's cool, but it has a very conservative descent profile and would use a ton of fuel. Having played Kerbal I'm used to attempting fuel efficient landings, which means more of a suicide burn approach, but of course this game doesn't keep track of that. There's something timelessly appealing about lunar lander games. The very first game I ever played on a computer, written in BASIC, was a 'turn based' one dimensiona…

The first program I ever keyed in was the one dimensional lunar lander simulation on my dad's HP calculator. Must have been 6 or 7 years old (by 9 years old I was doing BASIC on an Apple ][ with floating point card and programming intersections of two pipes to make cutting templates). Even back then I got to the 'suicide burn' approach. Made playing the arcade game pretty easy years later.

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

#47
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…

The target velocity is a factor of height, and the autopilot has “160” hardcoded as the ceiling, so going above that means it will never decelerate fast enough. https://github.com/szhu/lunar-lander-autopilot/blob/master/a...

That's a ceiling for the speed the autopilot is okay with letting the lander descend. There is no ceiling to how much hard it will try to "apply the brakes".

I agree that the target velocity calculation is off though. I was excited that I came up with something reasonably theoretically correct for correcting rotation... and for figuring out when to fire the engines I just gave up and eyeballed it :)

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

#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!)

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

#49
"Oh SNAP! I'm amazing at this!" 101.1 point landing on my second try!

At least, that's what I thought, until I realized I had previously activated the auto-pilot. Best #footgun today (so far!).

So I guess I should say: > Oh SNAP! This auto-pilot is amazing at this!

Thanks!

Post reply on HN