Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PopulateWorld {
- public static void addAllAgents(AgentWorld world) {
- addGroupedAgents(world, AgentType.PERSUER, 20, 1,-300,300);
- // addGroupedAgents(world, AgentType.EVADER, 10, 0, 0, 200);
- //addGroupedAgents(world, AgentType.PERSUER, 1, 1, 160, 160);
- //addGroupedAgents(world, AgentType.EVADER, 5, 0, 180, 180);
- // addGroupedAgents(world, AgentType.EVADER, 5, 0, 0, -125);
- addGroupedAgents(world, AgentType.EVADER, 20, 1, -300, 300);
- // addGroupedAgents(world, AgentType.PERSUER, 20, 0, -180, -180);
- }
- private static void addGroupedAgents(AgentWorld world, AgentType type, int count,int numberOfGroups, int x, int y) {
- AgentFactory factory = new AgentFactory(world.getPhysicsWorld(), world.getIdMap());
- if (type.equals(type.EVADER)) {
- int randx = 0;
- int randy = 0;
- Random r = new Random();
- for (int i = 1; i <= count; i++) {
- randx = x + r.nextInt((y - x) + 1);
- randy = x + r.nextInt((y - x) + 1);
- AbstractAgent agent = factory.createAgent(new Vector2(randx, randy), type);
- world.addAgent(agent);
- }
- }
- else if (type.equals(type.PERSUER)){
- int agentGroup= 0;
- int randx = 0;
- int randy = 0;
- Random r = new Random();
- for (int i = 0; i <= count; i++) {
- randx = x + r.nextInt((y - x) + 1);
- randy = x + r.nextInt((y - x) + 1);
- AbstractAgent agent = factory.createAgent(new Vector2(randx, randy), type);
- world.addAgent(agent);
- }
- // for (int j=1; j<=numberOfGroups;j++){
- //
- // agentGroup++;
- //
- // for (int i=1; i<=count/numberOfGroups;i++){
- // AbstractAgent agent = factory.createAgent(new Vector2(x, y), type);
- // agent.setAgentGroup(agentGroup);
- // world.addAgent(agent);
- // //System.out.println(agent.getAgentGroup());
- // }
- // }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement