Mars Lander - Puzzle discussion

Seems like when you explain to 4 yo child how much is 2x2, you can say: “it actually 4 but approx. 3 or 5, whatever, if you say any of those numbers it will be ok, because of you are 4yo.”
You gave great condition for speed from 0 to -40 that allows to newbies not worry about precision… And there are std functions for parsing numbers, does anybody write everytime his own function to parse?
Of course I’m not the author or any other site’s staff, but it is still seems strange. When displays rounded but inside calculations are precise! Use integers instead, or round it in the “engine” level but not only for display… U have just to move the call of rounding function befor calculations…

IMHO there’s a psychological issue with providing too much precision, in that it gives the impression the puzzle requires precision to solve, when in fact it doesn’t.

Save your 80-bit exact calculations for the optimization problems, and solve the generic ones with PID automation or more crude, like they’re intended.

2 Likes

Can’t agree with you.
Why you put such gravity? Why not 4? All input data (except first line) is useless. You can just send it to “dev/null”… you can solve problem with one formula! And it doesn’t matter which numbers are in input data (int, float etc). Rounded numbers useful when you solve the problem step by step on paper and then hard code all your steps. With such learning path newbie never will learn that there is effective algorithms and effective methods of solving problems…
One of the reasons to use programs is that it’s a hard task to operate manually with complex data, big data or so. But we can invent an effective algo and it will solve the problem with any type of data…
I didn’t say any word about optimization or so, you can read again and u’ll see that there is other meaning in my messages, but you still talk about optimization. Ok, i won’t continue discussing. I hope you’re right and your way is better…

The input data are here because you have the same data in Mars Lander 2 and Mars Lander 3. So you can share some code between this 3 puzzles.

1 Like

Granted, the creators and administrators of this site should be beheaded for all their sins (yes, I’m thinking about you CvxFous), but I’m not quite sure Mars Lander is the best reason to start searching for solid ropes. After all, in real life, a newbie who’ve learned to pay attention to the value of a sensor has probably more chance to land anything safely than a veteran who forgot than the 4 m/s value printed on its trusters is probably rounded too… thanks to these fuckingly incompetent technicians. And I’m pretty sure than an excuse such as “your fucking lander should theoretically have landed there” would make any Space Agency director a bit angry in turn.

1 Like

To simulate the simulation there is no need to use 100ms timestep. The internal timestep is 1 second.
the integration step can be summed up as this:

            currentFuel -= currentPower;
            currentAccelleration = thrust + GRAVITY;
            currentVelocity = currentVelocity + currentAccelleration;
            currentPosition = currentPosition + currentVelocity - (currentAccelleration * 0.5); (averaging velocity)

Where those are all vectors of 2 elements. I used double precision fp numbers.
Collision with terrain is calculated with segment to segment collision not simply height < terrainHeight. You will notice this in the fourth scenario where the simulation may “skip” the spiky mountain.

14 Likes

Cool video Fededevi! I’m kind of ashamed of my terrible ASCII visualiser now :wink: We have more or less the same algorithm, but I think your “continuous” fuel made a big difference for those few precious extra points!

1 Like

Hey jeff! Thankyou!

The continuous fitness functions help a lot in getting out a local min/max, but it is important that the “fit bonus” will always be lower than ±1 or else the algorithm may drop solutions with better actual final score.
To implement it I tried various approaches. One approach was to estimate the amount of fuel used in the last step; so not necessarily 4 but an estimation based on the space travelled in the last step before landing.

BTW I admit that I had to fiddle a lot with the simulated annealing parameters to find my best results in the fourth and fifth cases. In the first three it actually find (one of) the best solutions quite fast.
I also tried much more complex neural networks with more parameters (10 inputs, 2 hidden layers, 200 weights) without any improvements.
In the end what really matters as input is target position and lander velocity, at least in the easy cases. It is more like a PID controller rather than a neural network. But neural network sounds cooler and, in the end, a PID is just a very simple neural network :slight_smile:

PS: I think there is still space for improvement. I did not reach your score in case 4 :wink:

Is there any other criteria for the Economics achivement in Level 1? As you see, in IDE I barely finish above 300L left of fuel. But when I submited, didn’t get the achivement. I know the validator is slightly different than IDE, now I don’t know if I need to tweek or rewrite since you don’t get any details from the validation.

After submitting you can replay the solution wih submitted parameters. The GUI for mars lander contains all important infos, you can check there how much fuel was left in the submission case :wink:

1 Like

Just noticed :slight_smile: Thanks!
I’ve even tweeked it to be 309L left in IDE. But submitted gets me at 288L. So it’s quite far from target… have no idea where to get 12 liters from…

Maybe don’t hardcode it, or hardcode less, calculate the distance from the ground where you need to turn on the trusters to 4 :wink:

Well, wasn’t hardcoded at all actually, just over complicating stuff. ^^ And what got me was that the IDE now gave me 302L - same as the validator but my over complicated solution to give me 310L in IDE and 292 in validator…
So I made assuptions… you should never make assumptions :wink:

Thanks for your help, getting me back on track and back to basics - and I need to learn to submit even if I don’t think it will do :wink: In this case I would have been maybe two puzzles ahead now! :slight_smile:

@fededevi, thanks for this message that help me for two things.

First I’ve spent 1h trying to compute the values of X and Y on my own to do some optimizations, but I didn’t thought about using the mean of the previous and new values for the accelleration. That’s why I was always a bit off.

And also I was wondering how some people were doing to use programs that “learned” for all their attempts. From what I understand, the trick is to use external tools.

Thanks again!

1 Like

Hi all. I cant pass the 300L challenge. I get 306L left, but the game reacts the same, nothing new happens. On the Achievements page I can see a text telling me to pass it again with more than 300L left, but it doesn’t work…

Anyone knows why?

Brake advance. You do not spend a lot of fuel if

help me to fix my physics simulator - it’s having an error in calculations, and it’s growing fast with turns

dir = vector(-sin(newRotationInRadians), cos(newRotationInRadians))*newPower;
newPos = pos+(dir+(GravityVec+velocity)/2).rounded();
newVelocity = GravityVec+velocity;

looks like newVelocity is the same as in Game Info for all the time, but newPos’s getting a huge error in 30 turns

1 Like

The formula for position is x = x0 + v0t + 0.5at^2
t in this case is 1
so newPos = pos + velocity + (dir+GravityVec)/2

This is inaccurate since you use the new velocity to calculate the updated position, when in reality you should use the old velocity. (Also not sure why you are subtracting acceleration)


Edit: After some testing, I have made a strange discovery…
I took the starting coords and velocity and simulated about 100 moves ahead and compared the results and what I found is that
new.x = old.x + new.hs + 0.5accx
new.y = old.y + old.vs + 0.5
accy
gives the correct values.

Perhaps someone can verify this?

1 Like

No, the physic is OK ; this gives correct x, y, vx & vy along the whole simulation for all cases:

[code]#include <stdio.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.1415926535898
#endif
#define G 3.711

int main()
{
int surfaceN; // the number of points used to draw the surface of Mars.
scanf("%d", &surfaceN);
for(int i=0;i<surfaceN;++i) {
int landX; // X coordinate of a surface point. (0 to 6999)
int landY; // Y coordinate of a surface point. By linking all the points together in a sequential fashion, you form the surface of Mars.
scanf("%d%d", &landX, &landY);
}
// game loop
long double x,y,vx,vy;
for(int k=0;;++k) {
int X, Y;
int hSpeed, vSpeed; // the horizontal & vertical speed (in m/s), can be negative.
int fuel; // the quantity of remaining fuel in liters.
int rotate; // the rotation angle in degrees (-90 to 90).
int power; // the thrust power (0 to 4).
scanf("%d%d%d%d%d%d%d", &X, &Y, &hSpeed, &vSpeed, &fuel, &rotate, &power);
if(k==0) {
x = X; y = Y;
vx = hSpeed; vy = vSpeed;
}
int angle, thrust;
// … angle & thrust calculation …
if(angle>rotate+15) angle = rotate+15;
if(angle<rotate-15) angle = rotate-15;
if(thrust>power+1) thrust = power+1;
if(thrust<power-1) thrust = power-1;
x = x+vx-0.5sin(angleM_PI/180.)thrust;
y = y+vy+0.5
(cos(angle*M_PI/180.)thrust-G);
vx = vx-1.sin(angleM_PI/180.)thrust;
vy = vy+1.
(cos(angle
M_PI/180.)*thrust-G);
fprintf(stderr,“x -> %.0Lf ; y = %.0Lf\n”,x,y);
fprintf(stderr,“vx -> %.0Lf ; vy = %.0Lf\n”,vx,vy);
printf("%d %d\n",angle,thrust);
}
return 0;
}[/code]

2 Likes

i already fixed that, it was about rounding - it works without rounding