Ejemplo n.º 1
0
    public void test()
    {
        PokemonExperiment test = new PokemonExperiment(pD);

        config.Load("configfiles/NEATConfig.config.xml");

        test.Initialize("Pokemon", config.DocumentElement);


        var           genomeDecoder = test.CreateGenomeDecoder();
        IBlackBox     box           = genomeDecoder.Decode(bestGenome);
        BattleHandler b             = new BattleHandler();

        int score = 0;

        List <PokemonTeam> evalTeams = pD.getEvalTeams();

        foreach (PokemonTeam t in pD.getEvalTeams())
        {
            string debug = "\nBattling against a team with: ";

            foreach (Pokemon p in t.getMembers())
            {
                debug += p.getName() + " ";
            }
            Console.Write(debug);

            box.ResetState();
            ISignalArray inputArray;
            inputArray = box.InputSignalArray;
            float[] pkmnDnaIn = pD.createDnaUsingPkmn(t);

            for (int j = 0; j < t.getMembers().Length; j++)
            {
                inputArray[j] = pkmnDnaIn[j];
            }

            box.Activate();

            ISignalArray outputArray;
            outputArray = box.OutputSignalArray;
            float[] pkmnDnaOut = new float[outputArray.Length];
            for (int j = 0; j < pkmnDnaOut.Length; j++)
            {
                pkmnDnaOut[j] = (float)outputArray[j];
            }

            PokemonTeam attacker = pD.createTeamUsingDNA(pkmnDnaOut);

            score += b.battle(attacker.getMembers(), t.getMembers());
        }

        Console.Write("\nA Score of " + score + " was achieved agains the evaluation teams! (NEAT)");
        Console.Write("\nThe NEAT has a complexity of " + bestGenome.Complexity);
    }
Ejemplo n.º 2
0
    public void train()
    {
        PokemonExperiment exp = new PokemonExperiment(pD);

        config.Load("configfiles/NEATConfig.config.xml");

        exp.Initialize("Pokemon", config.DocumentElement);

        testType         = XmlUtils.GetValueAsInt(config.DocumentElement, "TrainingType");
        targetFitness    = XmlUtils.GetValueAsInt(config.DocumentElement, "TargetFitness");
        targetGeneration = XmlUtils.GetValueAsInt(config.DocumentElement, "TargetGeneration");

        evo = exp.CreateEvolutionAlgorithm();

        evo.UpdateEvent += new EventHandler(evo_UpdateEvent);

        evo.StartContinue();
    }