コード例 #1
0
        public static void Main(string[] args)
        {
            NEATGame ng   = new NEATGame();
            Thread   play = new Thread(new ThreadStart(ng.Game));

            play.IsBackground = true;
            play.Start();

            // Initialise log4net (log to console).
            XmlConfigurator.Configure(new FileInfo("log4net.properties"));

            // Experiment classes encapsulate much of the nuts and bolts of setting up a NEAT search.
            KeepawayExperiment experiment = new KeepawayExperiment();

            // Load config XML.
            XmlDocument xmlConfig = new XmlDocument();

            xmlConfig.Load("Keepaway.config.xml");
            experiment.Initialize("Keepaway", xmlConfig.DocumentElement);

            // Create evolution algorithm and attach update event.
            _ea              = experiment.CreateEvolutionAlgorithm();
            _ea.UpdateEvent += new EventHandler(ea_UpdateEvent);
            // Start algorithm (it will run on a background thread).
            _ea.StartContinue();
            //Hit return to quit
            //Console.ReadLine();
            NEATProgram np = new NEATProgram();

            np.WorkMethod();
            //ThreadPool.QueueUserWorkItem(new WaitCallback(WorkMethod), eventAuto);
        }
コード例 #2
0
        public FitnessInfo Evaluate(IBlackBox agent)
        {
            double fitness = 0;

            double[] score = new double[4];
            //synchronize the access to game controller
            lock (this)
            {
                //call a keepaway game controller
                fitness = NEATGame.FitnessValue(agent, out score);
            }
            _evalCount++;
            fitness /= scale;
            //termination condition
            if (fitness >= 1)
            {
                _stopConditionSatisfied = true;
            }

            return(new FitnessInfo(fitness, score));
        }
コード例 #3
0
        public FitnessInfo Evaluate(IBlackBox agent, out double[] behVector)
        {
            config = KPExperimentConfig.Load("KPExperimentConfig.xml");
            double fitness = 0;

            double[] values = new double[4];
            //synchronize the access to game controller
            lock (this)
            {
                //call a keepaway game controller
                fitness = NEATGame.FitnessValue(agent, out values);
            }
            behVector = values;
            _evalCount++;
            fitness /= scale;
            //termination condition
            if (fitness >= 1)
            {
                _stopConditionSatisfied = true;
            }

            return(new FitnessInfo(fitness, fitness));
        }