Ejemplo n.º 1
0
        private void Execute(string agentModel)
        {
            File.Delete("homerobotsim.csv");

            Core.HomeRobot robot;
            //Elegir la operación a realizar moverse o limpiar dependiendo de la estrategia.

            foreach (var setting in settings)
            {
                Console.WriteLine("Simulating: {0}", setting);

                //Ciclo de 30 simulaciones
                successfullCount         = 0;
                robotDissmissedCount     = 0;
                timeoutCount             = 0;
                dirtPercentPerSimulation = new double[simulationCount];

                var simulationIndex = 0;
                while (simulationIndex < simulationCount)
                {
                    //Iniciar el ambiente
                    Type robotType;
                    switch (agentModel.ToLower())
                    {
                    case "random":
                        robotType = typeof(RandomRobot);
                        break;

                    case "cleaner":
                        robotType = typeof(CleanerRobot);
                        break;

                    case "catcher":
                        robotType = typeof(CatcherRobot);
                        break;

                    case "smart":
                        robotType = typeof(SmartRobot);
                        break;

                    default:
                        robotType = null;
                        break;
                    }

                    var env = new Core.Environment(setting, robotType);
                    env.Played       += Env_Played;
                    env.Robot.Played += Robot_Played;

                    //Comenzar simulación
                    var simulation = new Simulation(env, env.Robot);
                    var end        = simulation.Run();

                    dirtPercentPerSimulation[simulationIndex] = env.SimulationDirtPercent();
                    simulationIndex++;

                    switch (end)
                    {
                    case ExecutionEnd.Succefull:
                        successfullCount++;
                        break;

                    case ExecutionEnd.RobotDismissed:
                        robotDissmissedCount++;
                        break;

                    case ExecutionEnd.Timeout:
                        timeoutCount++;
                        break;
                    }
                }
                ExportData("homerobotsim.csv");
            }
        }