{"id":13795718,"url":"https://github.com/trekhleb/self-parking-car-evolution","last_synced_at":"2025-04-04T15:11:23.229Z","repository":{"id":37509603,"uuid":"367045564","full_name":"trekhleb/self-parking-car-evolution","owner":"trekhleb","description":"🧬 Training the car to do self-parking using a genetic algorithm","archived":false,"fork":false,"pushed_at":"2022-10-21T20:27:26.000Z","size":33303,"stargazers_count":732,"open_issues_count":9,"forks_count":79,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-28T14:11:09.398Z","etag":null,"topics":["cannon-js","cannonjs","evolutionary-algorithm","evolutionary-algorithms","genetic-algorithm","genetics","self-driving-car","three-js","threejs"],"latest_commit_sha":null,"homepage":"https://trekhleb.dev/self-parking-car-evolution","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trekhleb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"trekhleb","patreon":"trekhleb"}},"created_at":"2021-05-13T12:43:53.000Z","updated_at":"2025-03-05T04:25:23.000Z","dependencies_parsed_at":"2022-07-14T04:10:27.860Z","dependency_job_id":null,"html_url":"https://github.com/trekhleb/self-parking-car-evolution","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trekhleb%2Fself-parking-car-evolution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trekhleb%2Fself-parking-car-evolution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trekhleb%2Fself-parking-car-evolution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trekhleb%2Fself-parking-car-evolution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trekhleb","download_url":"https://codeload.github.com/trekhleb/self-parking-car-evolution/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198464,"owners_count":20900081,"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":["cannon-js","cannonjs","evolutionary-algorithm","evolutionary-algorithms","genetic-algorithm","genetics","self-driving-car","three-js","threejs"],"created_at":"2024-08-03T23:01:01.138Z","updated_at":"2025-04-04T15:11:23.204Z","avatar_url":"https://github.com/trekhleb.png","language":"TypeScript","funding_links":["https://github.com/sponsors/trekhleb","https://patreon.com/trekhleb"],"categories":["TypeScript"],"sub_categories":[],"readme":"# 🧬 Self-Parking Car Evolution\n\nTraining the car to do self-parking using a genetic algorithm.\n\n\u003e - 🚕 [Launch the demo](https://trekhleb.dev/self-parking-car-evolution)\n\u003e - 📃 [Read about how it works](https://trekhleb.dev/blog/2021/self-parking-car-evolution/)\n\n[![Self-Parking Car Evolution](./public/site-meta-image-02.jpg)](https://trekhleb.dev/self-parking-car-evolution)\n\nThis is an experimental project with the aim to learn the basics of how [genetic algorithm](https://en.wikipedia.org/wiki/Genetic_algorithm) works by teaching the cars to do the self-parking. The evolution process is happening directly in the browser. You may check the [evolution source-code](https://github.com/trekhleb/self-parking-car-evolution/tree/master/src/libs) (in TypeScript) or read the [explanation of how it works](https://trekhleb.dev/blog/2021/self-parking-car-evolution/) in my blog-post.\n\n**At the beginning of the evolution** the generation of cars has random genomes which make them behave something like this:\n\n![Self-parking cars at the beginning of the evolution](./public/01-cars-before-01.gif)\n\n**On the 40th generation** the cars start learning what the self-parking is and start getting closer to the parking spot (although hitting the other cars along the way):\n\n![Self-parking car in ](./public/02-car-after-01.gif)\n\nAnother example with a bit more challenging starting point:\n\n![Self-parking car in ](./public/02-car-after-03.gif)\n\n## Genetic Source-Code\n\nThe `≈92%` of the code in this repository relates to the UI logic (3D simulation of the cars world, form controls for the evolution training process, etc.).\n\nHowever, the actual [code that implements a genetic algorithm](https://github.com/trekhleb/self-parking-car-evolution/tree/master/src/libs) takes less than `\u003c500` lines of code.\n\n## Development Details\n\nThe project is a [React](https://create-react-app.dev/) application written on TypeScript. Styled with [BaseWeb](https://baseweb.design/).\n\nThe 3D world simulation is made with [Three.js](https://threejs.org/) library using [@react-three/fiber](https://github.com/pmndrs/react-three-fiber) wrapper. The physics is simulated with [Cannon.js](https://github.com/schteppe/cannon.js) using [cannon-es](https://github.com/pmndrs/cannon-es) wrapper.\n\nThe whole evolution simulation is happening directly in the browser.\n\nTo launch the project, fork/clone it and run the following commands:\n\n```shell\nnpm install\nnpm run start\n```\n\nThe website will be available on `http://localhost:3000/self-parking-car-evolution`.\n\n**Hints:**\n\n- You may upload one of the [pre-trained checkpoints](https://github.com/trekhleb/self-parking-car-evolution/tree/master/src/checkpoints) to avoid starting the evolution from scratch.\n- Use the `?debug=true` URL param to see the FPS performance monitor and debugging logs in the console (i.e. `http://localhost:3000/self-parking-car-evolution?debug=true`).\n- Training progress is being saved to the local storage for each generation (not for each batch/group).\n\n## Author\n\n- [@trekhleb](https://trekhleb.dev)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrekhleb%2Fself-parking-car-evolution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrekhleb%2Fself-parking-car-evolution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrekhleb%2Fself-parking-car-evolution/lists"}