Ejemplo n.º 1
0
Archivo: GA.cs Proyecto: jonasstr/NEAT
    public void LoadBest()
    {
        if (SaveManager.instance.Load())
        {
            time  = 0f;
            state = State.BestCreature;
            foreach (var p in population)
            {
                if (p != null)
                {
                    Destroy(p.gameObject);
                }
            }
            population = new List <Creature>();

            var creature = Instantiate(creaturePrefab, startPos, Quaternion.identity, transform).GetComponent <Creature>();
            creature.brain = new NeuralNetwork(new Genome(SaveManager.instance.GetNeurons(), SaveManager.instance.GetWeights()));
            population.Add(creature);
            visualizer.Draw(creature.brain.genome.neurons, creature.brain.genome.weights);
            creature.StartSimulation();
        }
        else
        {
            Debug.LogError("No network found!");
        }
    }
Ejemplo n.º 2
0
Archivo: GA.cs Proyecto: jonasstr/NEAT
    private void Init()
    {
        time              = 0f;
        state             = State.RandomPopulation;
        visualizer        = GameObject.Find("NetworkVisualizer").GetComponent <NetworkVisualizer>();
        population        = new List <Creature>();
        populationGenomes = new List <Genome>();
        species           = new List <Species>();

        for (int i = 0; i < populationSize; i++)
        {
            var creature = Instantiate(creaturePrefab, startPos, Quaternion.identity, transform).GetComponent <Creature>();
            creature.brain = new NeuralNetwork(nInputs, nOutputs);
            population.Add(creature);
            populationGenomes.Add(creature.brain.genome);
            visualizer.Draw(creature.brain.genome.neurons, creature.brain.genome.weights);
        }

        foreach (var creature in population)
        {
            creature.StartSimulation();
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// This method is executed whenever the panel needs to repaint itself
 /// </summary>
 /// <param name='sender'>
 /// Sender.
 /// </param>
 /// <param name='e'>
 /// E.
 /// </param>
 void drawPanel_Paint(object sender, PaintEventArgs e)
 {
     NetworkVisualizer.Draw();
 }