Пример #1
0
        public double[] EvaluateNetworkMultipleObjective(INetwork network)
        {
            INetwork tempNet = null;

            NeatGenome.NeatGenome tempGenome = null;

            tempGenome = substrate.generateGenome(network);

            tempNet = tempGenome.Decode(null);
            SharpNeatExperiments.Pacman.MyForm1.neatGenome = tempGenome;
            SharpNeatExperiments.Pacman.MyForm1.network    = tempNet;

            double retries        = 1;
            double totalFitness   = 0;
            double totalEatScore  = 0;
            double totalLifeScore = 0;

            for (int i = 0; i < retries; i++)
            {
                var pacman = new PacmanAINeural.NeuralPacmanSUPG();
                //pacman.SetBrain(network);
                pacman.SetBrain(tempNet, true, tempGenome, network, substrate.getSUPGMap());

                var simplePacmanController = new PacmanAINeural.SimplePacmanController();
                simplePacmanController.SetBrain(tempNet, true, tempGenome, network, substrate.getSUPGMap());

                Visualizer visualizer = null;
                SharpNeatExperiments.Pacman.SimplePacman simplePacman = null;
                Thread visualizerThread;

                visualizerThread = new System.Threading.Thread(delegate()
                {
                    simplePacman = new SharpNeatExperiments.Pacman.SimplePacman(simplePacmanController, false);
                    System.Windows.Forms.Application.Run(simplePacman);

                    //visualizer = new Visualizer(pacman);
                    //System.Windows.Forms.Application.Run(visualizer);
                });
                visualizerThread.Start();
                visualizerThread.Join();

                totalFitness   += simplePacman.returnGameScore;
                totalEatScore  += simplePacman.returnEatScore;
                totalLifeScore += simplePacman.returnLifeScore;
            }
            double avgFitness   = totalFitness / retries;
            double avgEatScore  = totalEatScore / retries;
            double avgLifeScore = totalLifeScore / retries;

            return(new double[] { avgFitness, avgEatScore, avgLifeScore });
        }
        public double EvaluateNetwork(INetwork network)
        {
            INetwork tempNet = null;

            NeatGenome.NeatGenome tempGenome = null;

            tempGenome = substrate.generateGenome(network);

            tempNet = tempGenome.Decode(null);
            SharpNeatExperiments.Pacman.MyForm1.neatGenome = tempGenome;
            SharpNeatExperiments.Pacman.MyForm1.network    = tempNet;
            SharpNeatExperiments.Pacman.MyForm1.InitStartLine();

            double retries      = 1;
            double totalFitness = 0;

            for (int i = 0; i < retries; i++)
            {
                var simplePacmanController = new PacmanAINeural.SPSUPGController();
                simplePacmanController.SetBrain(tempNet, false, tempGenome, network, substrate.getSUPGMap());
                simplePacmanController.Substrate = substrate;

                SharpNeatExperiments.Pacman.SimplePacman simplePacman = null;
                Thread visualizerThread;

                visualizerThread = new System.Threading.Thread(delegate()
                {
                    bool fastNoDraw = true;
                    simplePacman    = new SharpNeatExperiments.Pacman.SimplePacman(simplePacmanController, fastNoDraw, new Random(i));
                    if (!fastNoDraw)
                    {
                        System.Windows.Forms.Application.Run(simplePacman);
                    }
                });
                visualizerThread.Start();
                visualizerThread.Join();


                totalFitness += simplePacman.returnGameScore;// visualizer.returnGameState;
            }
            double avgFitness = totalFitness / retries;

            return(avgFitness);

            /*int time = visualizer.returnGameState;
             * return (double)time;//fitness;*/
        }
Пример #3
0
 public SimplePacmanEnemyController(SharpNeatExperiments.Pacman.SimplePacman gameState)
 {
     pos            = new Point(0, 0);
     this.gameState = gameState;
 }