{"id":24021124,"url":"https://github.com/zipcodecore/zip-marslander","last_synced_at":"2025-04-15T21:15:29.411Z","repository":{"id":53754367,"uuid":"337459504","full_name":"ZipCodeCore/Zip-MarsLander","owner":"ZipCodeCore","description":"write software to land on Mars","archived":false,"fork":false,"pushed_at":"2021-03-16T01:52:57.000Z","size":53,"stargazers_count":0,"open_issues_count":1,"forks_count":23,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T21:15:12.742Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZipCodeCore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-09T16:04:02.000Z","updated_at":"2022-02-03T16:44:52.000Z","dependencies_parsed_at":"2022-09-24T05:40:47.839Z","dependency_job_id":null,"html_url":"https://github.com/ZipCodeCore/Zip-MarsLander","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipCodeCore%2FZip-MarsLander","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipCodeCore%2FZip-MarsLander/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipCodeCore%2FZip-MarsLander/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipCodeCore%2FZip-MarsLander/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZipCodeCore","download_url":"https://codeload.github.com/ZipCodeCore/Zip-MarsLander/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249153949,"owners_count":21221330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-08T12:39:02.807Z","updated_at":"2025-04-15T21:15:29.393Z","avatar_url":"https://github.com/ZipCodeCore.png","language":"Java","readme":"# Zip Mars Lander\na simulation of the SpaceX Starship landing on Mars.\n\n### Mars Simulation\n\n_Elon Musk has sent a really expensive Starship to land on Mars.\nThe on-board computer has failed! You have to land the spacecraft manually.\nSet burn rate of retro rockets to any value between 0 (free fall) and 200\n(maximum burn) kilo per second. Set burn rate every 10 seconds.\nYou must land at a speed of 2 m/s or 1 m/s. Good Luck!_\n\n\nYour project is to do two things.\n\n- build the code for the Vehicle class.\n  - there is quite  bit of pseudocode in the Vehicle and Simulation classes\n- design a new, replacement landing computer\n  - You need to write a method that allows the lander to land safely (after you can do it manually)\n\nIf you're having trouble understanding what we mean, look at the\n[SpaceX Mars Mission](https://www.spacex.com/human-spaceflight/mars/)\nScroll to the bottom of the page, and watch the simulation.\nSee how the Starship adjusts it's thrust cone to slow down and land.\n\nThis is basically a simulation that lets a user enter a rocket burn amount every\nten seconds. At each point, the player enters a number between 0 and 200. \nIt turns out that a burn of 100 is enough to not change the velocity downwards at all.\nA burn of zero increases the speed of descent by +100 m/s, a burn of 200 reduces \nthe speed of descent by -100 m/s.\n\nThe main loop of the simulation looks like this:\n\n``` java\n        DescentEvent status;\n        int burnInterval = 0;\n        printString(gameHeader());\n        printString(getHeader());\n        while (vehicle.stillFlying()) {\n            status = vehicle.getStatus(burnInterval);\n            System.out.print(status.toString()+\"\\t\\t\");\n            vehicle.adjustForBurn(burnSource.getNextBurn());\n            if (vehicle.outOfFuel()) {\n                break;\n            }\n            burnInterval++;\n            if (burnInterval % 9 == 0) {\n                printString(getHeader());\n            }\n        }\n        printString(vehicle.checkFinalStatus());\n```\n\nLooking at the source files, you'll see an interface called `BurnStream`. \nIt is how input into the game is handled.\nSee how if there is an Interface for BurnStream, you can implement a few different ways of handling input to the vehicle.\nThe first is a list of pre-calculated burns, which should allow the lander to land safely from a predetermined altitude.\nThe second is the one used to play with a human player.\nUse this one to play the game and figure out the simulation.\nAnd, in the Hard Part below, you can write a new class, OnBoardComputer, that can\nact like a smart software system that mimics a human and lands the Starship all the time safely.\n\nAnd this means that the \"real game\" which takes user input looks like this\n\n``` java\n    public static void main(String[] args) {\n        Simulation game = new Simulation(new Vehicle(Simulation.randomaltitude()));\n        BurnStream burnSource = new BurnInputStream();\n        game.runSimulation(burnSource);\n    }\n```\n\nand a unit test version of the simulator might look like this:\n\n``` java\n    public void runSimulationCrash() {\n        int[] burns = {0,0,0,0,0};\n        BurnStream burnSource = new BurnDataStream(burns);\n        Simulation game = new Simulation(new Vehicle(5000));\n        game.runSimulation(burnSource);\n\n    }\n```\n\nIn the first `main`, the user inputs the various burn numbers, trying to land the Starship\nvery slowly.\n\nIn the second, we start at a know altitude, and don't burn any fuel, which should crash\nthe Starship every time. There is a second unit test that has a series of burns that\nshould land Starship softly enough to survive.\n\nThe main layout of classes looks like this.\n\n![Zip Mars Lander](ZipMarsLanderArch.png)\n\n## Hard Part\n\nBUT, while you can runs your simulations, and maybe even land once or twice,\nhow do you create an onboard computer that lands the Starship?\n\nElon may be willing to pay you a lot of money for it(!) (no, not really, geez!)\n\nNow, the hard part of this lab, is \n__how do you create a class that gets DescentEvent objects as telemetry,\nand computes a new burn that lets the Starship land safely?__\n\nThis class, called `OnBoardComputer`, you need to take in the status object \n(Descent Event) which tells you the status of the vehicle. \nThen, you make a make a burn recommendation.\nAnd you keep doing that until the Starship lands softly.\n\nThe math is not hard. \nBut you do need to land at a speed of 1-2 m/s to be successful.\n\nNotice how the DescentEvent gives you the time, the speed, the altitude and how much fuel is left.\nYou'll see that burning 100 kilos leaves the speed the same as last time.\n\nAnd you could even do a table:\nBurn is in kilos, the DeltaV (change in velocity) is in m/s\n\n| Burn | DeltaV |\n|------|--------|\n|  0   |  +100  |\n| 100  |    0   |\n|200|-100|\n|105| -5|\n|150|-50|\n|95|+5|\n|50|+50|\n\nSo if you need to land at 2 m/s, you need a way to slow down alot, and do it very close to the martian surface.\n\nMaybe the way to do this is to descend from your initial altitude until you're at about \n1000m and moving at 100m/s, then descend to 200m at 100 m/s, and then descend to 50m at 25m/s.\nWhen at 50m, slow to 10m/s, then descend to 10m and slow to 2m/s. \nThen maintain speed and descend until you land.\n\nYou may need to dig up some high school physics to figure this out.\n\nHint: `a = (speed * speed)/(2 * altitude)`\n\nAnd remember, you brun zero kilos of fuel to increase descent speed by 100 m/s.\nYou burn 100 kilos of fuel to maintain your current descent speed.\nYou Burn 200 kilos of fuel to reduce you descent speed by 100 m/s.\n\nSo your end goal makes the class diagram look like this:\n![Zip Mars Lander with OnBoard Computer](OnBoardComputer.png)\n\nRemember, there are astronauts onboard the Starship, so you need to make\nsure they stay safe!\n\n-kristofer\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzipcodecore%2Fzip-marslander","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzipcodecore%2Fzip-marslander","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzipcodecore%2Fzip-marslander/lists"}