Package org.nlogo.agent

Examples of org.nlogo.agent.ArrayAgentSet$Iterator


      patch = ((Turtle) context.agent).getPatchHere();
    } else {
      patch = (Patch) context.agent;
    }
    AgentSet agentset =
        new ArrayAgentSet(Turtle.class, patch.turtleCount(),
            false, world);
    AgentSet breed = world.getBreed(breedName);
    for (Turtle turtle : patch.turtlesHere()) {
      if (turtle.getBreed() == breed) {
        agentset.add(turtle);
      }
    }
    return agentset;
  }
View Full Code Here


public final strictfp class _patchrow
    extends Reporter {
  @Override
  public Object report(Context context) throws LogoException {
    AgentSet result =
        new ArrayAgentSet(Patch.class, world.worldWidth(),
            false, world);
    double yDouble = argEvalDoubleValue(context, 0);
    int y = (int) yDouble;
    if (y == yDouble && y >= world.minPycor() && y <= world.maxPycor()) {
      int xMax = world.maxPxcor();
      for (int x = world.minPxcor(); x <= xMax; x++) {
        result.add(world.fastGetPatchAt(x, y));
      }
    }
    return result;
  }
View Full Code Here

          (context, this, 0,
              Syntax.TurtleType() | Syntax.PatchType() |
                  Syntax.TurtlesetType() | Syntax.PatchsetType(),
              agentOrSet);
    }
    return new ArrayAgentSet
        (Turtle.class, resultList.toArray(new Turtle[resultList.size()]), world);
  }
View Full Code Here

          (context, this, 0,
              Syntax.TurtleType() | Syntax.PatchType() |
                  Syntax.TurtlesetType() | Syntax.PatchsetType(),
              sourceSet);
    }
    return new ArrayAgentSet
        (Turtle.class, resultList.toArray(new Turtle[resultList.size()]), world);
  }
View Full Code Here

          (context, this, 0,
              Syntax.TurtleType() | Syntax.PatchType() |
                  Syntax.TurtlesetType() | Syntax.PatchsetType(),
              agent);
    }
    return new ArrayAgentSet
        (Turtle.class, resultList.toArray(new Turtle[resultList.size()]), world);
  }
View Full Code Here

    for (Turtle t : turtle.getPatchHere().turtlesHere()) {
      if (t.getBreed() == breed) {
        resultList.add(t);
      }
    }
    return new ArrayAgentSet
        (Turtle.class, resultList.toArray(new Turtle[resultList.size()]), world);
  }
View Full Code Here

    for (Turtle turtle : patch.turtlesHere()) {
      if (turtle.getBreed() == breed) {
        resultList.add(turtle);
      }
    }
    return new ArrayAgentSet
        (Turtle.class, resultList.toArray(new Turtle[resultList.size()]), world);
  }
View Full Code Here

public final strictfp class _patchcol
    extends Reporter {
  @Override
  public Object report(Context context) throws LogoException {
    AgentSet result =
        new ArrayAgentSet(Patch.class, world.worldHeight(),
            false, world);
    double xDouble = argEvalDoubleValue(context, 0);
    int x = (int) xDouble;
    if (x == xDouble && x >= world.minPxcor() && x <= world.maxPxcor()) {
      int yMax = world.maxPycor();
      for (int y = world.minPycor(); y <= yMax; y++) {
        result.add(world.fastGetPatchAt(x, y));
      }
    }
    return result;
  }
View Full Code Here

    Patch parent = (Patch) context.agent;
    int numberOfTurtles = argEvalIntValue(context, 0);
    org.nlogo.util.MersenneTwisterFast random = context.job.random;
    if (numberOfTurtles > 0) {
      AgentSet agentset =
          new ArrayAgentSet(Turtle.class, numberOfTurtles,
              false, world);
      if (breedName == NO_BREED) {
        for (int i = 0; i < numberOfTurtles; i++) {
          Turtle child = parent.sprout
              (random.nextInt(14), random.nextInt(360), world.turtles());
          agentset.add(child);
          workspace.joinForeverButtons(child);
        }
      } else {
        AgentSet breed = world.getBreed(breedName);
        for (int i = 0; i < numberOfTurtles; i++) {
          Turtle child = parent.sprout
              (random.nextInt(14), random.nextInt(360), breed);
          agentset.add(child);
          workspace.joinForeverButtons(child);
        }
      }
      context.runExclusiveJob(agentset, next);
    }
View Full Code Here

  public void perform(final Context context)
      throws LogoException {
    int numberOfTurtles = argEvalIntValue(context, 0);
    if (numberOfTurtles > 0) {
      AgentSet agentset =
          new ArrayAgentSet(Turtle.class, numberOfTurtles, false, world);
      AgentSet breed =
          breedName == NO_BREED
              ? world.turtles()
              : world.getBreed(breedName);
      for (int i = 0; i < numberOfTurtles; i++) {
        Turtle turtle = world.createTurtle(breed);
        turtle.colorDouble(Double.valueOf(10.0 * i + 5.0));
        turtle.heading((360.0 * i) / numberOfTurtles);
        agentset.add(turtle);
        workspace.joinForeverButtons(turtle);
      }
      context.runExclusiveJob(agentset, next);
    }
    context.ip = offset;
View Full Code Here

TOP

Related Classes of org.nlogo.agent.ArrayAgentSet$Iterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.