Package org.nlogo.api

Examples of org.nlogo.api.Turtle


  private void updateTurtles(World world, DiffBuffer buf) {
    // turtles, on the other hand, can die, so we move each one to a new
    // map as we encounter it...
    Map<Double, TurtleData> newTurtles = new HashMap<Double, TurtleData>();
    for (Agent a : world.turtles().agents()) {
      Turtle turtle = (Turtle) a;
      TurtleData diffs = updateTurtle(turtle);
      if (diffs != null) {
        buf.addTurtle(diffs);
      }
      TurtleData tmp = turtles.remove(Double.valueOf(turtle.id()));
      newTurtles.put(Double.valueOf(turtle.id()), tmp);
    }
    // now, any turtles left in the old map must have died...
    for (TurtleData turtle : turtles.values()) {
      // so, add a new "dead" TurtleData to the outgoing buffer.
      buf.addTurtle(new TurtleData(turtle.id()));
    }
    // finally, the new map replaces the old one.
    turtles = newTurtles;
  }
View Full Code Here


   * and the observer is not riding this agent). Note: if this agent has a label, the agent will
   * be regarded as "visible".
   */
  boolean agentIsVisible(Agent agent) {
    if (agent instanceof Turtle) {
      Turtle turtle = (Turtle) agent;

      boolean riding_agent = (world.observer().perspective() == PerspectiveJ.RIDE())
          && (world.observer().targetAgent() == turtle);

      return !riding_agent && !turtle.hidden()
        && (turtle.alpha() > 0.0 || turtle.hasLabel());
    } else if (agent instanceof Link) {
      Link link = (Link) agent;
      return !link.hidden() && (link.alpha() > 0.0 || link.hasLabel());
    } else if (agent instanceof Patch3D) {
      // Patch3D supports the alpha variable, so check Patch3D
View Full Code Here

  // detects which turtle(s) a pick-ray intersects with
  void pickTurtles(List<Agent> agents, double[][] ray) {
    // detect any turtles in the pick-ray
    for (Agent a : world.turtles().agents()) {
      Turtle turtle = (Turtle) a;
      if (!turtle.hidden()) {
        double size = turtle.size();

        double[] coord = getTurtleCoords(turtle, size);

        // determining distance to pick ray
        double ux = ray[1][0] - ray[0][0];
View Full Code Here

      }
    }
    if (turtlesDrawn < world.turtles().count()) {
      // uh oh, we have some unbreeded turtles we need to go back and draw
      for (Agent a : world.turtles().agents()) {
        Turtle turtle = (Turtle) a;
        if (turtle.getBreed() == world.turtles()) {
          turtleDrawer.drawTurtle(g, topology, turtle, patchSize);
        }
      }
    }
    if (outlineAgent instanceof Turtle) {
View Full Code Here

    double xcor, ycor, spotlightSize;
    boolean wrap = false;
    Agent agent = targetAgent();

    if (agent instanceof Turtle) {
      Turtle turtle = (Turtle) agent;
      spotlightSize = turtle.size() * 2;
      xcor = turtle.xcor();
      ycor = turtle.ycor();
      wrap = true;
    } else if (agent instanceof Link) {
      Link link = (Link) agent;
      spotlightSize = link.size();
      xcor = link.midpointX();
View Full Code Here

TOP

Related Classes of org.nlogo.api.Turtle

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.