{"id":18752884,"url":"https://github.com/ashleve/evolution","last_synced_at":"2025-04-13T00:31:29.615Z","repository":{"id":107186809,"uuid":"149898971","full_name":"ashleve/EvOLuTIoN","owner":"ashleve","description":"A simple simulation in Unity, which uses genetic algorithm to optimize forces applied to cubes","archived":false,"fork":false,"pushed_at":"2021-01-20T22:09:06.000Z","size":58760,"stargazers_count":49,"open_issues_count":0,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-05-22T04:22:45.338Z","etag":null,"topics":["ai","c-sharp","evolutionary-algorithms","fitness-score","genetic-algorithm","mutation","natural-selection","pathfinding","unity"],"latest_commit_sha":null,"homepage":"","language":"C#","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/ashleve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-09-22T17:14:24.000Z","updated_at":"2024-04-15T01:02:50.000Z","dependencies_parsed_at":"2024-01-14T09:00:39.503Z","dependency_job_id":null,"html_url":"https://github.com/ashleve/EvOLuTIoN","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashleve%2FEvOLuTIoN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashleve%2FEvOLuTIoN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashleve%2FEvOLuTIoN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashleve%2FEvOLuTIoN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashleve","download_url":"https://codeload.github.com/ashleve/EvOLuTIoN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650590,"owners_count":21139670,"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":["ai","c-sharp","evolutionary-algorithms","fitness-score","genetic-algorithm","mutation","natural-selection","pathfinding","unity"],"created_at":"2024-11-07T17:23:01.022Z","updated_at":"2025-04-13T00:31:24.605Z","avatar_url":"https://github.com/ashleve.png","language":"C#","readme":"# EvOLuTIoN\nA simple simulation in Unity, which uses genetic algorithm to optimize forces applied to cubes.\n\n\n![](gifs/genalg1.gif)\n![](gifs/genalg3.gif)\n![](gifs/genalgpic.png)\n\n\n# Download\nUnity game build:\n\u003cbr\u003e\nhttps://github.com/hobogalaxy/EvOLuTIoN/releases/download/v1.0/GenAlgBuild.zip\n\n\n# How Does It Work\n\nEach cube spawns with an instance of `Player.cs` script that contains his array of 3D vectors. Those vectors are applied to player as forces over time.\n\n\nThe genetic algorithm optimises those vectors.\n\n\n*What it means is players don't learn how to navigate in the environment, they only memorise the vectors that enable them to get closer to the goal.*\n\n\nYou can find the algorithm scripts in [`Assets\u003e\u003eScripts\u003e\u003eAlgorithmScripts`](https://github.com/hobogalaxy/EvOLuTIoN/tree/master/Assets/Scripts/AlgorithmScripts)\n\n\n`Population.cs` contains the Genetic Algorithm applied by NaturalSelection() function.\n\n```Csharp\n\n    void NaturalSelection()\n    {\n        SetChampion();  //finds the best player from generation\n\n        CalculateFitness();\n        CalculateFitnessSum();  //needed for selecting parents\n\n        CopyBrain(Players[0], champion);   //best player is always reborn in next generation \n                                           //unchanged as player0\n\n        for (int i = 1; i \u003c playerNum; i++)\n        {\n            GameObject parent = SelectParent();\n            CopyBrain(Players[i], parent);\n            Mutate(Players[i]);\n        }\n        \n    }\n```\n\nEach player has only one parent, no crossover is used.\n\u003cbr\u003e\n\n## Other mechanics:\n- The green cube is the best player from previous generation, which is always reborn without any mutations\n- Incremental learning is applied, which means each player has a certain lifespan which is increased each 5 generations. This is to give them time to master their first moves before moving on to the next ones.\n- When the first player reaches the goal, the minStep variable is assigned which is the minimum of steps he needed to take to reach the goal. From now on, if any player takes more steps then minStep, he will die. This makes them optimise their way so they get to the goal faster each generation.\n- The jumping is enabled just by giving players the abilty to have vectors mutated on Y axis (they're mutated only on X and Z by default).\n\n\n\u003cbr\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashleve%2Fevolution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashleve%2Fevolution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashleve%2Fevolution/lists"}