Live data from Hacker News

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

szhu.github.io

21–30 of 73 posts

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

#21
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). if the duration before the decelerating burn is T1 (so t1 = t0+T1), the smallest possible rcs impulse would be applied so that at t1-T_st the lander is pointing retrograde (retrograde at t1), with T_st being the time needed to cancel the initial rcs impulse. For the deceleration of the lander, fuel optimal landing includes a single burn, constantly retrograde, so that at t_end the lander altitude is 0, and both the vertical and horizontal velocity components are 0.

The time t1 to start that burn depends on the maximum thrust available, the rate of mass change when firing the rocket (not modelled in the game), the initial velocity etc.

in this simple case, model predictive control is not needed, and an LQR (linear quadratic regulator) is sufficient to achieve optimality

source: rocket scientist with control theory background. I remember this example (a bit more realistically modelled) being a project during my studies

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

#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 dimensional lunar lander game where you input how much thrust you used for each second of the descent, and then it recalculated your altitude, velocity, etc. I learned programming by rewriting it to be a real-time game where you pressed a key to fire the engine.

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

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

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

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

#27
post #26
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…

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!

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

#29
post #19
post #17

Would it be possible to put the autopilot in a bookmarklet for the original game?

I really wanted to! But unfortunately none of the lander's stats are exposed as global variables, so the only way I could make the autopilot was by modifying the existing code. (My commits are actually broken down exactly like this: a commit to expose the necessary variables globally, and another to actually add the autopilot.) I would also love to be able to play it in the original game though, so I made a PR! I thi…

I will take a look!
Post reply on HN