// Start is called before the first frame update void Start() { spawner[0].color = new Color(1, 0, 0); spawner[1].color = new Color(0, 1, 0); spawner[2].color = new Color(0, 0, 1); geneticAlgorithm = new GeneticAglorithm <float> [3]; for (int i = 0; i < 3; i++) { geneticAlgorithm[i] = new GeneticAglorithm <float>(i, 10, dnaSize, 0, random, GetRandomGene, GetInitGene, FitnessFunction, mutationRate: mutationRate); } //geneticAlgorithm[1] = new GeneticAglorithm<float>(10, dnaSize, 0, random, GetRandomGene, GetInitGene, FitnessFunction, mutationRate: mutationRate); //geneticAlgorithm[2] = new GeneticAglorithm<float>(10, dnaSize, 0, random, GetRandomGene, GetInitGene, FitnessFunction, mutationRate: mutationRate); bestPrerformanceList = new List <float>(); follow = Camera.main.GetComponent <Follow>(); orderedCars = new List <DNA <float> >(); for (int i = 0; i < 3; i++) { generationText[i].text = geneticAlgorithm[i].Generation.ToString(); bestFitnessText[i].text = geneticAlgorithm[i].BestFitness.ToString("F2"); currentFitnessText[i].text = Camera.main.transform.position.x.ToString("F2"); } }
// Use this for initialization void Start() { // Create the Random class // Create genetic algorithm class geneticAglorithm = new GeneticAglorithm <float>(factory.ships.Count, dnaSize, GetRandomGene, FitnessFunction, mutationRate, mutationVariance); }
private float bestJump = 0; // Store for the highest jump so far - Used for Mutation // Use this for initialization void Start() { // Create the Random class random = new System.Random(); // Create our Agent Manager and give them the height and width of grid along with agent prefab agentManager = new AgentManager(gridHeight, gridWidth, agentPrefab); // Create genetic algorithm class ga = new GeneticAglorithm <float>(agentManager.agents.Count, innerCount, random, GetRandomGene, FitnessFunction, mutationRate: mutationRate); // Calculate DeadZone position and size deadZone.transform.position = new Vector3(gridWidth, deadZone.transform.position.y, gridHeight); deadZone.transform.localScale = new Vector3(gridWidth * 2.5f, 1, gridHeight * 2.5f); }
// Start is called before the first frame update void Start() { geneticAlgorithm = new GeneticAglorithm <float>(1, 20, dnaSize, selectionProcess, random, GetRandomGene, GetInitGene, FitnessFunction, mutationRate: mutationRate); bestPrerformanceList = new List <float>(); orderedCars = new List <DNA <float> >(); generationText.text = geneticAlgorithm.Generation.ToString(); medianFitnessText.text = geneticAlgorithm.BestFitness.ToString("F2"); currentFitnessText.text = Camera.main.transform.position.x.ToString("F2"); selectionProcessText.text = "Random Parent Selection"; mutationText.text = mutationRate.ToString("F2"); liveCars = 20 - spawner.deadCars; liveCarText.text = liveCars.ToString() + "/20"; }
void Start() { // Intialise the random generator and genetic algorithm class random = new System.Random(); ga = new GeneticAglorithm <char>(populationSize, targetString.Length, random, GetRandomGene, FitnessFunction, mutationRate: mutationRate); }
public void Restart() { spawner.SpawnCars(); follow = Camera.main.GetComponent <Follow>(); geneticAlgorithm = new GeneticAglorithm <float>(1, 20, dnaSize, selectionProcess, random, GetRandomGene, GetInitGene, FitnessFunction, mutationRate: mutationRate); }