示例#1
0
        /// <summary>
        /// Generates all the farm stuff
        /// </summary>
        private void GenerateFarm()
        {
            backgroundName = "Farm";

            _workspace = new Workspace(X_MIN, X_MAX, Y_MIN, Y_MAX) { Obstacles = GenerateBaseFarmObstacles() };
            _workspace.GenerateEvenGraph((UInt16)(X_RANGE + 1), (UInt16)(Y_RANGE + 1));

            List<Node> groundPatrolPath = new List<Node>() {
                _workspace.GetNode(new HomeworkTwo.Point(18, 10)),
                _workspace.GetNode(new HomeworkTwo.Point(18, 35)),
                _workspace.GetNode(new HomeworkTwo.Point(28, 35)),
                _workspace.GetNode(new HomeworkTwo.Point(28, 2)),
                _workspace.GetNode(new HomeworkTwo.Point(28, 35)),
                _workspace.GetNode(new HomeworkTwo.Point(18, 35))};

            // Create our robot group with our agents
            _robotGroup = new RobotGroup(
                GeneratePursuers(new HomeworkTwo.Point(25, 38), _workspace, _workspace, groundPatrolPath),
                GenerateTargets(new HomeworkTwo.Point(30, 39), _workspace, _workspace),
                TIME_STEP_LENGTH,
                TIME_HORIZON,
                VISIBLITY_CRITERIA);
        }
示例#2
0
        private List<RobotBase> GeneratePursuers(HomeworkTwo.Point point, Workspace traversabilityMap, 
            Workspace visibilityMap, List<Node> groundPatrolPath)
        {
            Workspace airWorkspace = new Workspace(X_MIN, X_MAX, Y_MIN, Y_MAX) { };
            airWorkspace.GenerateEvenGraph((UInt16)(X_RANGE + 1), (UInt16)(Y_RANGE + 1));

            List<Node> airPatrolPath = new List<Node>() {
                airWorkspace.GetNode(new HomeworkTwo.Point(1, 39)),
                airWorkspace.GetNode(new HomeworkTwo.Point(39, 39)),
                airWorkspace.GetNode(new HomeworkTwo.Point(39, 1)),
                airWorkspace.GetNode(new HomeworkTwo.Point(1, 1))};

            return new List<RobotBase>() { new GroundPursuer(GroundPursuerPatrol.TheInstance,
                point, // location
                RADIUS, // radius
                new Vector2D(), // intial velocity
                MAX_SPEED * .6f, // max speed
                new Vector2D(), // intial heading
                MASS, // mass
                new Vector2D(1, 1), // scale
                TURN_RATE, // turn rate
                MAX_FORCE, // max force
                groundPatrolPath, // patrol path
                traversabilityMap, // traversability map
                visibilityMap),// visibility map

                new AerialPursuer(AerialPursuerPatrol.TheInstance,
                    new HomeworkTwo.Point(1,15), // location
                    RADIUS, // radius
                    new Vector2D(), // intial velocity
                    MAX_SPEED * .75f, // max speed
                    new Vector2D(), // intial heading
                    MASS, // mass
                    new Vector2D(), // scale
                    TURN_RATE, // turn rate
                    MAX_FORCE, // max force
                    airPatrolPath, // patrol path
                    airWorkspace, // traversability map
                    airWorkspace) }; // visibility map
        }
示例#3
0
        /// <summary>
        /// Generates all the city stuff
        /// </summary>
        private void GenerateCity()
        {
            backgroundName = "City";
            Obstacles obstacles = new Obstacles();

            // Create obstacles
            for (double i = 3.5; i <= 38; i = i + 5.5)
                for (double j = 25.5; j <= 38; j = j + 5.5)
                    obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(j,i), 4, 4));

            for (double i = 25.5; i <= 38; i = i + 5.5)
                for (double j = 3.5; j <= 22; j = j + 5.5)
                    obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(j,i), 4, 4));

            // Set up workspace and generate nodes
            _workspace = new Workspace(X_MIN, X_MAX, Y_MIN, Y_MAX) { Obstacles = obstacles };
            _workspace.GenerateEvenGraph((UInt16)(X_RANGE + 1), (UInt16)(Y_RANGE + 1));

            Workspace airWorkspace = new Workspace(X_MIN, X_MAX, Y_MIN, Y_MAX) { };
            airWorkspace.GenerateEvenGraph((UInt16)(X_RANGE + 1), (UInt16)(Y_RANGE + 1));

            List<Node> groundPatrolPath = new List<Node>() {
                airWorkspace.GetNode(new HomeworkTwo.Point(1, 20)),
                airWorkspace.GetNode(new HomeworkTwo.Point(20, 20)),
                airWorkspace.GetNode(new HomeworkTwo.Point(20, 1)),
                airWorkspace.GetNode(new HomeworkTwo.Point(1, 1))};

            List<Node> airPatrolPath = new List<Node>() {
                airWorkspace.GetNode(new HomeworkTwo.Point(1, 39)),
                airWorkspace.GetNode(new HomeworkTwo.Point(39, 39)),
                airWorkspace.GetNode(new HomeworkTwo.Point(39, 1)),
                airWorkspace.GetNode(new HomeworkTwo.Point(1, 1))};

            // Create our agents
            List<RobotBase> pursuerRobots = new List<RobotBase>() {
                new GroundPursuer(GroundPursuerPatrol.TheInstance,
                    new HomeworkTwo.Point(1,1), // location
                    RADIUS, // radius
                    new Vector2D(), // intial velocity
                    MAX_SPEED * .8f, // max speed
                    new Vector2D(), // intial heading
                    MASS, // mass
                    new Vector2D(), // scale
                    TURN_RATE, // turn rate
                    MAX_FORCE, // max force
                    groundPatrolPath, // patrol path
                    _workspace, // traversability map
                    _workspace), // visibility map

                new AerialPursuer(AerialPursuerPatrol.TheInstance,
                    new HomeworkTwo.Point(1,15), // location
                    RADIUS, // radius
                    new Vector2D(), // intial velocity
                    MAX_SPEED, // max speed
                    new Vector2D(), // intial heading
                    MASS, // mass
                    new Vector2D(), // scale
                    TURN_RATE, // turn rate
                    MAX_FORCE, // max force
                    airPatrolPath, // patrol path
                    airWorkspace, // traversability map
                    airWorkspace) }; // visibility map

            List<Target> targetRobots = new List<Target>() { new Target(TargetPatrol.TheInstance,
                new HomeworkTwo.Point(30,39), // location
                RADIUS, // radius
                new Vector2D(), // intial velocity
                MAX_SPEED, // max speed
                new Vector2D(), // intial heading
                MASS, // mass
                new Vector2D(), // scale
                TURN_RATE, // turn rate
                MAX_FORCE, // max force
                new List<Node>(), // patrol path
                _workspace, // traversability map
                _workspace)}; // visibility map

            // Create our robot group with our agents
            _robotGroup = new RobotGroup(pursuerRobots, targetRobots, TIME_STEP_LENGTH, TIME_HORIZON, VISIBLITY_CRITERIA);
        }