giacomelli / GeneticSharp

GeneticSharp is a fast, extensible, multi-platform and multithreading C# Genetic Algorithm library that simplifies the development of applications using Genetic Algorithms (GAs).
MIT License
1.26k stars 330 forks source link

Fixed Chromsome Values. #90

Closed Donaut closed 3 years ago

Donaut commented 3 years ago

Ask a question Currently, I'm trying to implement a minimal Ai. The objective is to navigate on a 2D grid 1 time at a block to a destination. My problem is that since all the chromosome values are changing there is a way to set some gene values manually? (I need this because as I said the chromosome is can only move 1 block at a time. And I give the position as a chromosome value) I tried to use the ReplaceGene method but it caused a runtime error:/. error

chromsosome The First Value is the possible movement direction. (Left, Up, Right, Down) each represented as an int. The second and third numbers are the destination coordinates (X and Y coordinate). Clearly, the Ai doesn't have the necessary information. As I said I'm trying to give the ai more information about itself by storing its position in the chromosome as a value. (Those are missing in the image) But it raises the problem that those values cannot be changed at mutation and can only be changed by manually I think I'm on the wrong path and I need to use a totally different approach but I cannot find one.

fitness This is my fitness function I convert the point distances to a negative value so the algorithm tries to find the smallest negative value and thus the best route.