Mars Lander Fuel puzzle discussion

Level 2 - Fuel Optimization

hy i am not able to control hs speed â€¦ any idea ?

You can adjust the angle, to control hs speed.

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?

8 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

2 Likes

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 ?

4 Likes

Hey !

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

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?

2 Likes

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.

7 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.

2 Likes

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

``````
4 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
//sin() of 90 / -90 will return 1 / -1 so if shuttle pointing left/right full power goes along X axis
//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;

Hi all.
Iâ€™m trying to learn Genetic algo and apply it to this mars lander game.
Just to be sure I got it right

``````For each input :
update ship status
generate a list of random (angle, power) tuple (that's the population in GA)
apply each tuple to the ship to get a new ship status and evaluate a score ,