Mars Lander Fuel puzzle discussion

Feel free to send your feedback or ask some help here!

Level 2 - Fuel Optimization


hy i am not able to control hs speed … any idea ?

You can adjust the angle, to control hs speed.

Hello. Mars landers, this can help you : https://www.codingame.com/forum/t/mars-the-game/756

Much as you can watch a replay of other player’s multiplayer games by browsing the leaderboards, I think being able to watch a replay of the results of other players’ optimization submissions would be very educational. Wouldn’t it be nice to see how the #1 coder landed the Mars Lander with so little fuel expenditure? Of course this is hampered a bit by the fact that the actual scored verifications aren’t even visible to the submitter. Is this something we could see in the future please?

9 Likes

I agree. Or simply the maximum remaining fuel achieved in individual test cases (not just the the sum for all test cases) is useful too.

Achieved figures for reference:
Test case 2.1: 341L
Test case 2.2: 372L
Test case 2.3: 517L
Test case 2.4: 545L
Test case 2.5: 728L
Total: 2503L

1 Like

Hello

Did anyone ever try to figure out theoretical maximum limits for each tracks ?

I mean the first obvious limit is the starting fuel.

But then taking into account starting position plus other parameters and constraints, there should be some mathematical formula to devise a fuel limit.

I’m not from a math background but I made some calculation of this kind for the first track removing the X component that gave me a limit of 364 (by removing X component i mean moving the ship right over the landing ground in the problem, allowing a straight landing).

But I just can’t figure how I could integrate the X component into the calculation.

For X movements implies angle rotation which impact Y so it’s more complicated.

Anyone got a an idea :wink: ?

3 Likes

Hey !

I just achieved the first 3 test cases using a not so intelligent algorithm :smile:

Now I’m facing the two last test cases and clearly my tinkering will not be enough. I have to get out of my confort zone and learn new things, which is why I’m here, but I really don’t know where to start.

If someone has some guidelines or a link with some theory I could use it’ll be appreciated. Not looking for a solution but something to understand and then use in my code. (It can be in French or English).

Achieved figures for reference:
Test case 2.1: 338L
Test case 2.2: 367L
Test case 2.3: 510L
Test case 2.4: 539L
Test case 2.5: 722L
Total: 2475L

While simulating speed over time I get discrepencies (minor but still annoying) with what’s shown in the output. I’m only doing simple trigonometry to compute forces so I wonder if there are approximations to be known (like float rounding) in the engine?

1 Like

Same question

I’m using floats for the shuttle position and speed parameters and all simulation calculations. As far as I remember, if I wanted the exact (integer) results for the shuttle parameters I round to nearest, after all commands for the turns are applied:

(float turn0X, float turn0y) -> apply turn0 rotate and power using float calculations ->
(float turn1X, float turn1y) -> apply turn1 rotate and power using float calculations ->
(float turn2X, float turn2y) -> apply turn2 rotate and power using float calculations ->
(float turn3X, float turn3y)

print(round(turn3X)) // To see if the X for turn 3 matches the X for turn 3 from the CG platform
print(round(turn3Y)) // To see if the Y for turn 3 matches the Y for turn 3 from the CG platform

I am trying to display the landers’ landing path with Python turtle. But the drawing is really slow. This is a population of 200. I am afraid it could not finish in a given amount of time. Is this due to the python turtle package or my algoritem ? Or this is correct?

How can i reduce his vertical speed

I had the same problem and finally solved it.
Remember that given a constant acceleration,

speed(t) = initial_speed + acceleration * t
position(t) = initial_position + initial_speed * t + 1/2 * acceleration * t^2

Here is my simulation sequence

update rotate and power
calculate acceleration vector (combining power/orientation and gravity)
position += speed + 1/2 * acceleration
speed += acceleration

acceleration, speed and position are float 2D vectors.
I never round values.

With that I managed to exactly reproduce every position and speed.

Hope it will help you

2 Likes

It’s been a long time since I messed with this but my memory is that the sim is keeping your position in a float (maybe a double), but it gives you the rounded number in the inputs. Or at least, I built my bot with that assumption and didn’t have any mismatches between expected and actual position.

1 Like

for anyone looking to simulate the next turn, this was pretty accurate for me

    const radians = R * (Math.PI / 180)
    const xAcc = Math.sin(radians) * P
    const yAcc = Math.cos(radians) * P - gravity
    HS -= xAcc
    VS += yAcc
    const newX = X + HS - xAcc * 0.5
    const newY = Y + VS + yAcc * 0.5 + gravity

2 Likes

Hi!
I am trying to solve by solving this system of equation.
I’m stuck because I can’t isolate more than one unknown.
Do you think is possible?

I am not very smart and dont understand this simulation, it was not working for me so I rewrited like so:

//Be aware of gravity sign
MARS_GRAVITY = 3.711;
//Convert degree to radians for sin() / cos() methods
radians = Math.toRadians(rotateAngle);
//sin() of 90 / -90 will return 1 / -1 so if shuttle pointing left/right full power goes along X axis
xAcc = Math.sin(radians) * power;
//cos() of 0 / 180 = 1 / -1
yAcc = Math.cos(radians) * power - MARS_GRAVITY;
//We need to reverse X acceleration sign because in puzzle positive acceleration is along x axis, but in
//the formula positive sin(90) = 1 is left (conter-clockwise)
x += hSpeed - xAcc * 0.5;
y += vSpeed + yAcc * 0.5;
//If simple - we applying “turn” acceleration as half of it because acceleration is not instant, but after the
//turn we save full acceleration to speed value as we reach it during turn
hSpeed -= xAcc;
vSpeed += yAcc;