Ejemplo n.º 1
0
        public Robot(float x, float y, float angle, int id, ref StaticMap map)
        {
            _x      = x;
            _y      = y;
            _angle  = angle;
            _map    = map;
            this.id = id;

            for (int i = -5; i <= 5; i++)
            {
                sensors.Add(new Sensor(0, 0, (float)i * 0.1f));
            }
        }
Ejemplo n.º 2
0
        public float CheckDistance(StaticMap map, Robot robot)
        {
            float step = 1;
            float sin = (float)Math.Sin(_angle + robot.Angle);
            float cos = (float)Math.Cos(_angle + robot.Angle);
            float xCurrent = _x, yCurrent = _y;           //промежуточные точки луча

            for (float i = 0; i < MaxDist; i += step)
            {
                xCurrent += step * cos;
                yCurrent += step * sin;

                if (map.IsCellOccupied(robot.X + xCurrent, robot.Y + yCurrent))
                {
                    return(measuredDist = (float)Math.Sqrt(xCurrent * xCurrent + yCurrent * yCurrent));
                }
            }

            return(measuredDist = MaxDist);
        }
Ejemplo n.º 3
0
 /**
  * params:
  *      staticMap - map with static obstacles
  *      logTextBox - text window for debug information and auction results output
  */
 public World(ref StaticMap staticMap, RichTextBox logTextBox)
 {
     this.staticMap  = staticMap;
     this.logTextBox = logTextBox;
 }