Feel free to send your feedback or ask some help here!
Feel free to send your feedback or ask some help here!
I tried a physics approach on the mars lander level 1 challenge like this: computing the total energy of the system we get mghf+m*(vf^2)/2=mgh1+m*(v1^2)/2-L , where m is the mass, g acceleration, hf final height - 100m, vf - final velocity which i’ve set to 40 m/s, h1 height at which thrust starts, v1 - velocity at h1, and L the mechanical work needed to prevent the crash. My goal was to burn the least amount of fuel so i let the object fall freely until height h1 and then i set the thrusters to full (so as to ensure that the time frame in which the module is burning fuel is minimal). Considering the starting point and the landing zone invariant at (2500,2500) and (some_x_interval, 100) i came up with the following equation: ghf+(vf^2)/2=gh1+(v1^2)/2-1*(v1+0.5g+0.5)-2(v1+1.5g+2)-3(v1+2.5g+4.5)-4(h1-3v1-4.5g-7); v1 is equal to sqrt(2g(2500-h1)) - which must be substituted in the top formula, thus obtaining a non-linear equation in h1. First term to the right of the eq sign is potential energy at height h, second is the kinetic energy and the last 4 terms are the total work that the thruster must do in order to keep the vf=40m/s; these come from the fact that the thruster needs 1 second to increase the acceleration by 1m/s^2, so for each acceleration i compute the mechanical work based on the acceleration(1,2,3,4) and their corresponding distance in which that acceleration takes place (i compute the mean velocity for a 1 second interval and multiply it with the time interval - again 1s thus obtaining distance).
TL DR VERSION with my formula i’ve obtained a height of 2115.7m at which i must start the thrusters at full which is a wrong answer. If anyone has time please show me where is the mistake in my calculations; if not maybe someone could give an explanation on how to physically compute the height from which the thrusters must go from 0 to 4 so as the landing speed is exactly 40 m/s. While this should be a programming challenge i would want a physical solution, plus it should yield a very efficient program.
Less fuel, better for planet Mars
click here problem : ‘Unhandled Error: Undefined variable: displayFullQuestion’
I configm this problem. Can’t get to the full set of instructions by clicking “here” link in Chrome 37 on Linux.
Yes, it’s exact, links are broken on level 2 and 3 for mars lander puzzle. You can get information on level 1 (in easy exercices)
Thank you for this hint, @McKelian
You are welcome
Kind of unclear that the first time you play it there’s only a straight vertical descent, and no further tests. I wasted a lot of time on a more complete solution because I made the mistake of believing what I was told in the description. : /
That’s not wasted time, as you’ll need your more complete solution for level 2 anyway
I took the shotgun approach. It seems that you need to land with a vertical descent of -20. If you start falling before engaging the thrusters in time then you might have the correct thrust but your descent won’t slow to -20 in time. I came up with the formula to solve it though I am not very happy with the solution for level 1. P = min(abs(VS) / 5,4)
I don’t know if my solution will work on levels 2 and 3 but I haven’t gotten there yet. I am working through all the “easy” games now.
Whew… made it at last through the second level. I’ve started and abandoned it several times, but in the end i was victorious! Though there are some codepieces in there that I’m not proud of. But still, win is a win
About algorythm. It’s pretty complicated, but rough. First, you need to find angle, that will allow you to accelerate and, at the same time, not to lose altitude, when using throttle 4. It’s about 17 degrees. Using it, you can relatively comfortably travel across the gamefield. Next, you need couple of if’s, that can keep ship’s horisontal speed at bay - you don’t need to rush too much, especially in some cases, when it’s too high from the start. Don’t forget the slowing if - you’ll need to nullify your speed once you get close to landing pad. Simply put, you need to alter your angle once you’re near, and, after that, set it to 0 at the moment horisontal speed is nullified. And then, there’s a landing procedure, which(i hope) you’ve already mastered on level 1
It’s actually (+ / -) 21.9 deg:) but hSpeed will be quite bigger, so you need to brake after strafing.
If you don’t want to hardcode that:
We have G (3.711) and we have Pmax = 4 (max throttle).
To strafe freely we need to find an angle (either positive or negative), which will split Pmax vector to two components: horizontal one (no matter what it will be) and vertical one, should be equal to or approximate to our G (3.711) to strafe.
cos λ = G / Pmax (to get vertical part of split vector)
λ = acos (G / Pmax)
So, basically, whatever you update G or Pmax, you can always calculate strafe angle.
In our case:
λ = acos(3.711 / 4) = acos(0.9275) = 21.9
Yeah, you’re right, it looks more optimal that way =) Thought lander still loses altitude and i have no idea why =\ I couldn’t finish fourth test because of it, and taking in account heights on the way to the landing pad looks like a pain
I don’t know if it’s a bug in game engine or my miscalculations, but there are some strange bugs like this. For example, when i try accelerate till the halfway, and then decelerate on the other half(starting speed 0, same throttle and angle), lander doesn’t end up in a position it should be.
So in the end I’ve just set the speedlimit and angle i found during several tests. It works, for the better or worse =)
You can start strafing with t (time) equal to 4 (1, 2 and 3 throttle, then 4 as a max).
During that time, you earn some vertical speed.
It’s because you output 1, 2 and 3 m / s ^ 2, and with angle (15, 22). You don’t extinguish G which is equal to 3.711.
Because G > your throttles for these 3 turns, you gain vertical speed of 6m/s ^2 (approximately), and YOU KEEP IT BY KEEPING ANGLE AT 22. So basically you need to include extra logic into your code That when you are 22 deg and 4 throttle, your VSpeed should be 0
I’m so jealous for you, because i only do math now. Can’t code second level
In a way, that’s what bother me with this puzzle. In the end, it’s more about “Have you listened in high school?” than about Code ^^
There is an additional achievement at level 1. My code provide needed solution (I tested), but I didn’t get it.
You tested on ide. You can’t know if it pass on submission (input is different). I have this success, so it should work.
omg more achivement i see one more in skynet finale 1 too, cool stuff