{"id":17255570,"url":"https://github.com/ffmathy/fluffyspoon.neuro.evolution","last_synced_at":"2025-07-11T07:09:52.138Z","repository":{"id":48569724,"uuid":"219023447","full_name":"ffMathy/FluffySpoon.Neuro.Evolution","owner":"ffMathy","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-12T16:12:30.000Z","size":172,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-22T22:32:48.148Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","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/ffMathy.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,"governance":null}},"created_at":"2019-11-01T16:33:40.000Z","updated_at":"2023-03-12T16:12:35.000Z","dependencies_parsed_at":"2023-01-21T06:15:12.464Z","dependency_job_id":"d629d5cc-e3b2-4e17-be71-9595ea4e604c","html_url":"https://github.com/ffMathy/FluffySpoon.Neuro.Evolution","commit_stats":{"total_commits":49,"total_committers":2,"mean_commits":24.5,"dds":0.4897959183673469,"last_synced_commit":"27a3f79159daac5a4a5c0857fde222a778a475e8"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffMathy%2FFluffySpoon.Neuro.Evolution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffMathy%2FFluffySpoon.Neuro.Evolution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffMathy%2FFluffySpoon.Neuro.Evolution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffMathy%2FFluffySpoon.Neuro.Evolution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ffMathy","download_url":"https://codeload.github.com/ffMathy/FluffySpoon.Neuro.Evolution/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228054244,"owners_count":17862126,"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":"2024-10-15T07:12:03.680Z","updated_at":"2024-12-04T05:40:45.235Z","avatar_url":"https://github.com/ffMathy.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FluffySpoon.Neuro.Evolution\n\n```csharp\nnamespace FluffySpoon.Neuro.Evolution.Sample\n{\n    class Program\n    {\n        static async Task Main(string[] args)\n        {\n            var serviceCollection = new ServiceCollection();\n            serviceCollection.AddFluffySpoonNeuroEvolution(new EvolutionSettings\u003cCarSimulation\u003e() {\n                AmountOfGenomesInPopulation = 100,\n                AmountOfWorstGenomesToRemovePerGeneration = 10,\n\n                //3 input neurons, 4 neurons in 1st hidden layer, 5 neurons in 2nd hidden layer, 2 output neurons\n                NeuronCounts = new [] { 3, 4, 5, 2 },\n                \n                SimulationFactoryMethod = () =\u003e new CarSimulation()\n            });\n\n            var serviceProvider = serviceCollection.BuildServiceProvider();\n\n            var firstGeneration = serviceProvider.GetRequiredService\u003cIGeneration\u003cCarSimulation\u003e\u003e();\n            var secondGeneration = await firstGeneration.EvolveAsync();\n            var thirdGeneration = await secondGeneration.EvolveAsync();\n            //etc\n\n            var carSimulationsOfThirdGeneration = thirdGeneration.Genomes.Select(x =\u003e x.Simulation);\n            foreach(var carSimulationOfThirdGeneration in carSimulationsOfThirdGeneration)\n            {\n                //render the car simulation or something else.\n            }\n        }\n    }\n\n    class CarSimulation : ISimulation\n    {\n        enum SteeringType\n        {\n            TurnLeft,\n            DoNothing,\n            TurnRight\n        }\n\n        enum AccelerationType\n        {\n            Accelerate,\n            DoNothing,\n            Decelerate\n        }\n\n        public int DistanceTravelled { get; private set; }\n\n        public double Fitness =\u003e -DistanceTravelled;\n\n        public bool HasEnded =\u003e DistanceTravelled \u003e 10;\n\n        /// \u003csummary\u003e\n        /// This is called by the learning algorithm to determine the inputs to feed into the neural network.\n        /// \u003c/summary\u003e\n        /// \u003creturns\u003e\u003c/returns\u003e\n        public async Task\u003cdouble[]\u003e GetInputsAsync()\n        { \n            //we simulate that 3 LIDAR sensor readings come in. \n            //the left one reads 100 meters, the middle one reads 80 meters and the right one reads 30 meters. \n            //these will be fed as input neurons.\n\n            return new double[]\n            {\n                100, //left sensor input neuron\n                80, //center sensor input neuron\n                30 //right sensor input neuron\n            };\n        }\n\n        /// \u003csummary\u003e\n        /// This is called by the learning algorithm with the neural network's suggestion on what to do based on the input that was given in \u003csee cref=\"GetInputsAsync\"/\u003e.\n        /// \u003c/summary\u003e\n        public async Task TickAsync(double[] outputs)\n        {\n            var steeringType = NeuronInterpretationHelper.InterpretAsEnum\u003cSteeringType\u003e(outputs[0]);\n            var accelerationType = NeuronInterpretationHelper.InterpretAsEnum\u003cAccelerationType\u003e(outputs[1]);\n\n            //do something here based on the steering type and acceleration type the neural net suggested.\n\n            if(accelerationType == AccelerationType.Accelerate)\n                DistanceTravelled++;\n        }\n\n        public async Task ResetAsync()\n        {\n            //reset car positions.\n        }\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fffmathy%2Ffluffyspoon.neuro.evolution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fffmathy%2Ffluffyspoon.neuro.evolution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fffmathy%2Ffluffyspoon.neuro.evolution/lists"}