static void setupScenario(SFSimulator sim) { /* Specify the global time step of the simulation. */ sim.setTimeStep(0.25f); /* Specify the default parameters for agents that are subsequently added. */ AgentProperty ap = new AgentProperty(15.0f, 10, 5.0f, 1.2f, 2.0f, 2.0f, 0.5f, 8, 0.6f, 100, 13.3f, 10, 0.000005f, 0.25f, 1.0f, new Vector2()); sim.setAgentDefaults(ap); /* * Add agents, specifying their start position, and store their goals on the * opposite side of the environment. */ for (int i = 0; i < 5; ++i) { for (int j = 0; j < 5; ++j) { sim.addAgent(new Vector2(55.0f + i * 10.0f, 55.0f + j * 10.0f)); goals.Add(new Vector2(-75.0f, -75.0f)); sim.addAgent(new Vector2(-55.0f - i * 10.0f, 55.0f + j * 10.0f)); goals.Add(new Vector2(75.0f, -75.0f)); sim.addAgent(new Vector2(55.0f + i * 10.0f, -55.0f - j * 10.0f)); goals.Add(new Vector2(-75.0f, 75.0f)); sim.addAgent(new Vector2(-55.0f - i * 10.0f, -55.0f - j * 10.0f)); goals.Add(new Vector2(75.0f, 75.0f)); } } /* * Add (polygonal) obstacles, specifying their vertices in counterclockwise * order. */ List<Vector2> obstacle1 = new List<Vector2>(); List<Vector2> obstacle2= new List<Vector2>(); List<Vector2> obstacle3= new List<Vector2>(); List<Vector2> obstacle4= new List<Vector2>(); obstacle1.Add(new Vector2(-10.0f, 40.0f)); obstacle1.Add(new Vector2(-40.0f, 40.0f)); obstacle1.Add(new Vector2(-40.0f, 10.0f)); obstacle1.Add(new Vector2(-10.0f, 10.0f)); obstacle2.Add(new Vector2(10.0f, 40.0f)); obstacle2.Add(new Vector2(10.0f, 10.0f)); obstacle2.Add(new Vector2(40.0f, 10.0f)); obstacle2.Add(new Vector2(40.0f, 40.0f)); obstacle3.Add(new Vector2(10.0f, -40.0f)); obstacle3.Add(new Vector2(40.0f, -40.0f)); obstacle3.Add(new Vector2(40.0f, -10.0f)); obstacle3.Add(new Vector2(10.0f, -10.0f)); obstacle4.Add(new Vector2(-10.0f, -40.0f)); obstacle4.Add(new Vector2(-10.0f, -10.0f)); obstacle4.Add(new Vector2(-40.0f, -10.0f)); obstacle4.Add(new Vector2(-40.0f, -40.0f)); sim.addObstacle(obstacle1); sim.addObstacle(obstacle2); sim.addObstacle(obstacle3); sim.addObstacle(obstacle4); /* Process the obstacles so that they are accounted for in the simulation. */ sim.processObstacles(); }
static void setupScenario(SFSimulator sim) { // Specify the global time step of the simulation sim.setTimeStep(0.25f); // Specify the default parameters for agents that are subsequently added AgentProperty ap = new AgentProperty(15.0f, 10, 5.0f, 1.2f, 2.0f, 2.0f, 0.5f, 8, 0.6f, 100, 13.3f, 10, 0.000005f, 0.25f, 1.0f, new SFVector2()); sim.setAgentDefaults(ap); // Add agents, specifying their start position, and store their goals on the opposite side of the environment for (int i = 0; i < 5; ++i) { for (int j = 0; j < 5; ++j) { sim.addAgent(new SFVector2(55.0f + i * 10.0f, 55.0f + j * 10.0f)); goals.Add(new SFVector2(-75.0f, -75.0f)); sim.addAgent(new SFVector2(-55.0f - i * 10.0f, 55.0f + j * 10.0f)); goals.Add(new SFVector2(75.0f, -75.0f)); sim.addAgent(new SFVector2(55.0f + i * 10.0f, -55.0f - j * 10.0f)); goals.Add(new SFVector2(-75.0f, 75.0f)); sim.addAgent(new SFVector2(-55.0f - i * 10.0f, -55.0f - j * 10.0f)); goals.Add(new SFVector2(75.0f, 75.0f)); } } // Add (polygonal) obstacles, specifying their vertices in counterclockwise order List <SFVector2> obstacle1 = new List <SFVector2>(); List <SFVector2> obstacle2 = new List <SFVector2>(); List <SFVector2> obstacle3 = new List <SFVector2>(); List <SFVector2> obstacle4 = new List <SFVector2>(); obstacle1.Add(new SFVector2(-10.0f, 40.0f)); obstacle1.Add(new SFVector2(-40.0f, 40.0f)); obstacle1.Add(new SFVector2(-40.0f, 10.0f)); obstacle1.Add(new SFVector2(-10.0f, 10.0f)); obstacle2.Add(new SFVector2(10.0f, 40.0f)); obstacle2.Add(new SFVector2(10.0f, 10.0f)); obstacle2.Add(new SFVector2(40.0f, 10.0f)); obstacle2.Add(new SFVector2(40.0f, 40.0f)); obstacle3.Add(new SFVector2(10.0f, -40.0f)); obstacle3.Add(new SFVector2(40.0f, -40.0f)); obstacle3.Add(new SFVector2(40.0f, -10.0f)); obstacle3.Add(new SFVector2(10.0f, -10.0f)); obstacle4.Add(new SFVector2(-10.0f, -40.0f)); obstacle4.Add(new SFVector2(-10.0f, -10.0f)); obstacle4.Add(new SFVector2(-40.0f, -10.0f)); obstacle4.Add(new SFVector2(-40.0f, -40.0f)); sim.addObstacle(obstacle1); sim.addObstacle(obstacle2); sim.addObstacle(obstacle3); sim.addObstacle(obstacle4); // Process the obstacles so that they are accounted for in the simulation sim.processObstacles(); }