Mars Lander - Puzzle discussion

Thank you :slight_smile:
The only explanation I could come up with was that the “mars_gravity” number provided in the problem’s text wasn’t accurate, actually haven’t checked that yet but only because I feel it would be absurd after so many people attempted it, and chances are 99% I’ve messed up the math x_x

No issue with the gravity number in the problem’s text.

While the v_speed given to you is an integer, the actual calculation done by the game engine uses “unrounded” figures. So, there’ll be discrepancies if you rely on the input figures entirely during your simulation.

1 Like

Ah, I see - I had already some doubts because the mars_gravity was a float but the project was setup with all the inputs in int, so deep down I might have suspected I wasn’t expected to do this eheh
Thanks for the help :blush:

1 Like

I wish I could +100 this comment. So many pro programmers find errors through this process. I am guessing 5DN1L has been around a block or two. https://en.wikipedia.org/wiki/Rubber_duck_debugging

1 Like

Way better than how I did it. I just flew over the map drawing straight lines to the landing spot until it didn’t intersect ground, then i did my code that passed stage 2. It is…not pretty…nor is it fuel efficient.

hey i dont know why is the land_x is 0 and not an other value

Hi guys. Just wondering if someone knows how the ranking and coding points works for this event.

There is neither ranking nor coding points. It’s not a competition.

You won XP if you solve the puzzle, in this case, 250XP / 500 XP / 750 XP if you pass half of validators / all validators / all validators plus enough fuel at the end.

Okay. Thank you for your explanation.

Hi Everyone.
Someone please help me.

I am using slope to calculate the rotation angle. Everything is working fine, but the vertical speed is -45 instead of -40. What to do?

If the final vertical speed is excessive then you need to reduce it by spending more time firing the rocket engine at full power, and at zero or a very small tilt. You need to avoid the vertical-velocity-downwards becoming too great before starting the descent. As a rule of thumb, starting at height y metres, the maximum downward velocity is y/20 otherwise you will never be able to bleed off that speed before hitting the ground. (Final Speed=Initial speed -2xDistancexacceleration) Acceleration on full downward power is only 4-3.711 = 0.289 m/s/s i.e. Rocket power minus mars-gravity

" I just flew over the map drawing straight lines to the landing spot until it didn’t intersect ground" That’s an interesting approach - but I found the detection of two lines crossing to be quite an involved algorithm - would you like to post the code? So as an alternative I computed gradients from the start of the Flat to preceding points - the biggest negative gradient (or smallest positive gradient) gives a corridor-to-cave constraint. Then doing the same from the end of Flat to later points gives the other corridor constraint. Drawing a line from Lander initial position to highest point before corridor gives WayPoint 1 etc, and from there to the corridor, the next WayPoint.

Maybe i made it sound more complex than it was. Each turn i just draw a line to the center of the landing zone. If it intersects any ground then i continue to just fly across the top of the map. Once the line doesnt intersect it uses my very basic heuristic approach.

Right, but the code to detect an intersection of two line segments is not trivial - I’d be interested to see that code?

def do_segments_intersect(x1, y1, x2, y2, line_segments):
nearest_segments = find_nearest_segments((x1, y1, x2, y2), line_segments, n=5)

for segment in nearest_segments:
    a1, b1, a2, b2 = segment

    # Check for intersection between the two line segments
    if do_line_segments_intersect(x1, y1, x2, y2, a1, b1, a2, b2):
        return True

return False

def do_line_segments_intersect(x1, y1, x2, y2, a1, b1, a2, b2):

def orientation(p, q, r):
    val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r[1] - q[1])
    if val == 0:
        return 0  # Collinear
    return 1 if val > 0 else 2  # Clockwise or counterclockwise

o1 = orientation((x1, y1), (x2, y2), (a1, b1))
o2 = orientation((x1, y1), (x2, y2), (a2, b2))
o3 = orientation((a1, b1), (a2, b2), (x1, y1))
o4 = orientation((a1, b1), (a2, b2), (x2, y2))

if o1 != o2 and o3 != o4:
    return True

if o1 == 0 and is_point_on_segment((x1, y1), (a1, b1), (x2, y2)):
    return True
if o2 == 0 and is_point_on_segment((x1, y1), (a2, b2), (x2, y2)):
    return True
if o3 == 0 and is_point_on_segment((a1, b1), (x1, y1), (a2, b2)):
    return True
if o4 == 0 and is_point_on_segment((a1, b1), (x2, y2), (a2, b2)):
    return True

return False
1 Like

That posted kind of weirdly. I have a function comparing my line to the landing zone vs each segment in the ground segments. The do_line_segments_intersect with all 4 points is what actually checks for intersections.

You may edit your message and use the </> button on the formatting toolbar or manually use 3 backticks to enclose your code (3 backticks at the front and 3 backticks at the end) so that the code is formatted properly.

我感觉我似乎在使用,一种类似硬编码的方式解题(在完成第二关的时候)可以说这是我接触编程的第三个题目,做法都非常的,,非主流。
我需要补习我的数学和更多cpp知识,以后再来挑战(顺便,这里可以分享代码吗?)

Please write in English only in this forum. Also, you’re advised to avoid sharing codes here.

Alright, so I wanted to try to use a time function to do this but I’m unsure how to make one log turn off when the other is on, can you help me on this?