public WalkStraightExperiment( 
     WorldInputInterface Wii,
     WorldOutputInterface Woi
     )
     : base(Wii, Woi)
 {
     sensorNames = new List<string>();
 }
示例#2
0
        private bool moveRandom = false; // whether or not the leader should move randomly

        #endregion Fields

        #region Constructors

        public DFSExperiment( 
            WorldInputInterface Wii,
            WorldOutputInterface Woi)
            : base(Wii, Woi)
        {
            //Note the sensorNames list is being generated in the code here
            //However it can easily be extended to read from a Configuration File from the disk
            sensorNames = new List<string>();

            //sensorNames.Add("RobotSensor");
            sensorNames.Add("DFSSensor");
            sensorNames.Add("GridSensor");
            sensorNames.Add("BoundarySensor");
        }
示例#3
0
        /// <summary>
        /// Constructor. Initialize the robots. Initialize the world state.
        /// </summary>
        /// <param name="Wii"></param>
        /// <param name="Woi"></param>
        public ControlLoop(WorldInputInterface Wii, WorldOutputInterface Woi)
        {
            this.Wii = Wii;
            this.Woi = Woi;

            worldState = Wii.ws;

            List<Robot> robots = worldState.robots;
            List<PhysObject> worldObjects = worldState.physobjects;

            foreach (Robot robot in robots)
            {
                Robots.Add(robot.Id,robot);
            }

            foreach (PhysObject obj in worldObjects)
            {
                WorldObjects.Add(obj.Id, obj);
            }
            // Assume default for now. Experiment class can change after
            globalAlgorithm = new DefaultGlobalAlgorithm();
        }
示例#4
0
        public void RunExperiment()
        {
            ControlLoop cl = new ControlLoop(Wii, Woi);
            if(globalAlg != null)
                cl.setGlobalAlgorithm(globalAlg);
            while (true)
            {
                try
                {
                    Console.WriteLine("Running Control Loop");
                    cl.RunLoop();
                    //Thread.Sleep(1000);
                }
                catch (AlgorithmFinishedException e)
                {

                    //This may need to be cleared out. This is if one robot finds a food source, but we may
                    //want other stop criterion
                    Console.WriteLine("Experiment Finished by Robot: " + e.robotid);
                    // Check for batch mode
                    if (Wii.GetType() == typeof(SimulatorInputInterface))
                    {
                        CS266.SimCon.Simulator.OurSimulator osNew = ((SimulatorInputInterface)Wii).getOurSimulator().Finished();
                        if (osNew == null)
                        {
                            // We're done
                            break;
                        }
                        else
                        {
                            Wii = new SimulatorInputInterface(osNew);
                            Woi = new SimulatorOutputInterface(osNew);
                            SetupExperiment();
                            RunExperiment();
                            break;
                        }
                    }
                }
                catch (GlobalAlgorithmFinishedException e)
                {
                    Console.WriteLine("Experiment Finished globally");
                    // Check for batch mode
                    if (Wii.GetType() == typeof(SimulatorInputInterface))
                    {
                        CS266.SimCon.Simulator.OurSimulator osNew = ((SimulatorInputInterface)Wii).getOurSimulator().Finished();
                        if (osNew == null)
                        {
                            // We're done
                            break;
                        }
                        else
                        {
                            Wii = new SimulatorInputInterface(osNew);
                            Woi = new SimulatorOutputInterface(osNew);
                            SetupExperiment();
                            RunExperiment();
                            break;
                        }
                    }
                }
                Thread.Sleep(3000);
            }
        }
示例#5
0
 //Boolean used to return whether or not the experiment has finished running
 //Used to tell the control loop to stop looping
 //public Boolean isRunning = true;
 public Experiment(WorldInputInterface Wii, WorldOutputInterface Woi)
 {
     this.Wii = Wii;
     this.Woi = Woi;
     //this.numRobots = Wii.GetRobots().Count;
 }