示例#1
0
        public FitnessInfo Evaluate(IBlackBox brain, ParallelEvaluationParameters parallelParameters)
        {
            ProgramMalmo programMalmo = new ProgramMalmo();

            // The brain to Malmo controller will be subscribed to the update
            // events of ProgramMalmo, and it will controll the actions of the
            // Minecraft character. Here we only care about evaluating the results
            // of these actions.
            //BrainToMalmoController brainToMalmoController = new BrainToMalmoController(brain, programMalmo);
            //BuilderController brainToMalmoController = new BuilderController(brain, programMalmo);
            MazeControllerNoTurn brainToMalmoController = new MazeControllerNoTurn(brain, programMalmo);

            //MazeControllerWithDiagonals brainToMalmoController = new MazeControllerWithDiagonals(brain, programMalmo);
            ++evalCount;

            System.Diagnostics.Debug.WriteLine("Evaluate one. Simulation name: " + parallelParameters.simulationName +
                                               " with assigned port: " + parallelParameters.assignedPort.ToString());
            System.Diagnostics.Debug.WriteLine("\nEnter evaluation " + evalCount);
            programMalmo.RunMalmo(parallelParameters);
            // FitnessInfo takes an "alternative fitness", so here we simply pass
            // the same fitness value twice.
            System.Diagnostics.Debug.WriteLine("Exit evaluation " + evalCount + "\n");


            brainToMalmoController.CleanUp();
            brainToMalmoController = null;
            return(new FitnessInfo(fitness, fitness));
        }
示例#2
0
 static void RemoveUser(string userName)
 {
     System.Diagnostics.Debug.WriteLine("Removing user: "******"Removing user from active list. ", userName);
     ProgramMalmo.FreePort(userName);
     userNameToAlgorithm[userName].StopEvolution();
     EvolutionCoordination.DessubscribeEventsFromUser(userName);
     userNameToUser.Remove(userName);
     userNameToAlgorithm.Remove(userName);
 }