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...
https://github.com/szhu/lunar-lander-autopilot/blob/master/a...
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 :)