Challenge: Mars Lander Simulation


Space exploration is not only dangerous but also expensive. We can’t afford to test all ideas or software with real space equipment. One of the solutions to this problem is computing simulations.

We can model various situations and environments with computers and experiment without fear to lose expensive equipment or human lives. Of course, we can’t simulate all the possible factors and consider everything, and more complex model takes much more efforts to create it. So one of the main problems of computing simulations is to choose this border. Even a simple model can help to test ideas and find their disadvantages for early stages.


Let’s look at one of the simple models of the Mars lander. This simulation is realized as a coding game at CodinGame site with various difficulties (you can find links in the next section). Try to solve it and land the model of the Mars Lander. How do you think to solve it? Which algorithms will you use for this? Is it a practical and useful coding problem or do you think it’s just a game?


The algorithm description as a text or as a code. You can use any services to share your code (gist for example). Your thoughts about the real usage of coding tasks like “Mars Lander” by CodinGame.

Additional material

Mars Lander Level 1

Mars Lander Level 2

Mars Lander Level 3

Useful Resources

Computer simulation

NASA Rover Curiosity: Meeting on Mars

Curiosity landing simulation


Theme: Coding

Skills: Programming, Software Architecture

Difficulty: ★★★☆☆


One comment

  1. “Mars Lander” is a simple model of the real lander, but it’s a nice example how to make it interesting. CodinGame added a simple animation and it became a game where only your coding skills are important.

    The first two problems are simplified versions of the last third problem. To solve the first, you don’t need to be a serious coder.

    The simplest way is to turn off engines and wait until your vertical speed will be about 40m/s. If your speed is more than this value, then turn on engines for 4 power. This way you will land on the surface without problems.

    if vSpeed <= -40:
    print("0 4")
    print("0 0")

    Of course, this is not the fastest and not the best if you want to save fuel, but this is the safest. For the vertical landing, you can use mathematics and find the speed and the optimal point where you need to start your engine.

    Let’s skip the second level and look at the last. This is the full problem, where you need to choose the landing zone, think about rotating and calculate wing strength. First you need to find a landing zone. I think, it’s not required an explanation, because the surface is described as a sequence of points, and it’s not too hard to find a flat zone with enough length. But if we will find several zone, then the problem can be more interesting.

    Ok. Let’s think how to solve a problem. I’m not good in physics, so I think about the problem with the knowledge that I have already. And my first thought is “This is a game, thus let’s use game algorithms”. And we can think about this problem as about pathfinding task.

    First we need to find a route to the landing zone (or to any of the possible). For this, we can use a grid, but we need to choose a size of grid cells. If we will take a small step, then the pathfinding will be complex. So this part require some experiments.

    Or we can to choose a big size step for the grid and then reduce it. When we choose the size, we need to find a route through this grid. It’s not a hard and we can use A-star search algorithm. The main problem is a heuristic algorithm. The simplest here is a distance, but maybe we can choose more complex algorithms and try to find first “key points”, from which we can “see” the start and the end position.
    Or maybe it will be more than one “key” point. With these points, we can improve our heuristics.


    The next step is simpler – we simulate various combinations of parameters and trying to move along our route. And again we can use here graph path search algorithms.

    I’ve not written code here (except a short fragment) because I think it’s more important to understand the logic of development and algorithms and you can easily to implement it. I’m sure this problem can be solved more optimal way and physics knowledge can help here.

    Feel free to criticize it and ask any questions.

    P.S.: Yep, I haven’t written a solution on CodinGame, because for me the most interested part is to think up a “roadmap” of the solution.

    Liked by 1 person

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s