@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.
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…
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.5accy
gives the correct values.
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(angleM_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]
Actually not.
If we want to make a terraforming to turn Mars into an Earth clone, we have to pollute it. And we humans are EXPERT at polluting Planets. Planet Mars needs Carbon Dioxide which comes from Pollution and that’s because the process would increase the atmospheric density and eliminate the need for pressurised spacesuits making the Red Planet more habitable.
So … yeah … This simulation is against making Mars “better”.
Depends on whether you define “better” as “more habitable” or as “more like natural state”. I suspect that you will get different answers to this if you polled different people.
just started working lvl 2, and am I to assume we have to manually strafe left and right to fide the landing site first? as getting the land_x and land_y from the input is only resulting in the endpoint (using python)
Thnx
Your solution will not work for the other levels without a ridiculous amount of experimenting!
Another approach is to look at the desired end result (safe landing speed) and correct the craft for any error at every stage of the descent. That way is more scalable to the other problems (not to say they are easy of course).
This exercise is really confusing and unclear in many ways.
It is not clear what part are fixed and what are not: the platform is always below, but is it always 100m high?
No test case input/output is provided, you have to print yourself the different test case, and retro engineer how the speed and position are computed.
The mix variation of integer (speed, position) / double input (gravity) makes it difficult to understand what is expected (rounded values? ceil? floor?)
Many people want to write logical and good code for this exercice, telling them that a trivial answer would be enough is not an excuse for not rewrite the description.
If you try to print the output of a free fall, you realize that the variation of speed (acceleration) is not constant (sometimes -3, sometimes -4), even if the power of engine is always at 0. It makes it very difficult to retro-engineer, and to build test cases for it.
To make it 100% clear for people struggling with rounding, just store everything (position, vectors) as double, and ignore the input CG is giving to you, as it’s innacurate integers while they still use the accurate doubles in their engine.
Instead use what you’ve computed from your previous round, and it should all be fine.
As many people already mentionned, not so cool for the players, and makes unit testing complicated since you can’t just use CG input to generate a test case.