Esempio n. 1
0
 public LocalGridSensor(ControllerWorldState worldState, int rows, int cols)
 {
     this.worldState = worldState;
     localgrid = new double[rows, cols];
     localnumrows = rows;
     localnumcols = cols;
 }
Esempio n. 2
0
        // constructor gets a reference to the world state
        public Grid(ControllerWorldState ws, double WorldWidth, double WorldHeight, int numX, int numY)
        {
            this.prevLocations = new Dictionary<Robot, Coordinates>();
            this.prevLocationsForMark = new Dictionary<Robot, Coordinates>();
            this.WorldWidth = WorldWidth;
            this.WorldHeight = WorldHeight;
            this.NumSquaresX = numX;
            this.NumSquaresY = numY;

            cellData = new CellData[NumSquaresX, NumSquaresY];
            for (int i = 0; i < NumSquaresX; i++)
            {
                for (int j = 0; j < NumSquaresY; j++)
                {
                    cellData[i, j] = new CellData(i,j);
                }
            }
        }
Esempio n. 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();
        }
Esempio n. 4
0
        /// <summary>
        /// Updates the states of robots and objects with new information
        /// 1. Get's the world state from the world input interface
        /// 2. update each robot's local view by updating that robots' sensors
        /// </summary>
        private void GetInput()
        {
            worldState = Wii.GetWorldState();
               //  Console.WriteLine("Control Loop WS Angle before sensor: "+ worldState.robots[0].Orientation);
               // Console.WriteLine("controloop con");

            //Console.WriteLine("*****Number of objects in the world: " + (worldState.physobjects.Count) + "*******");
            //Console.WriteLine("**********Number of food objects in the world: " + (worldState.foodlist.Count) + "*******");
            //update robot orientation and location
            foreach (Robot z in worldState.robots)
            {

                if (Robots.ContainsKey(z.Id))
                {
                    Robots[z.Id].Orientation = z.Orientation;
                    Robots[z.Id].Location = z.Location;
                }
            }

            foreach (Robot r in Robots.Values)
            {
                foreach (InputSensor sensor in r.Sensors.Values)
                {

                    sensor.UpdateWorldState(worldState);
                  //  Console.WriteLine("SENSOR AFTER WORLD STATE UPDATE: " + sensor.worldState.robots[0].Orientation);
                    sensor.UpdateSensor();
                }
            }
        }
Esempio n. 5
0
 public LocalGridSensor(ControllerWorldState worldState)
 {
     this.worldState = worldState;
 }