Package org.nlogo.agent

Examples of org.nlogo.agent.Patch


  public Object report(Context context) {
    return report_1(context);
  }

  public Object report_1(Context context) {
    Patch patch;
    if (context.agent instanceof Patch) {
      patch = ((Patch) context.agent).getPatchEast();
    } else if (context.agent instanceof Turtle) {
      patch = ((Turtle) context.agent).getPatchHere().getPatchEast();
    } else {
View Full Code Here


  public Object report(Context context) {
    return report_1(context);
  }

  public AgentSet report_1(Context context) {
    Patch patch;
    if (context.agent instanceof Turtle) {
      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 Object report(Context context) {
    return report_1(context);
  }

  public Object report_1(Context context) {
    Patch patch;
    if (context.agent instanceof Patch) {
      patch = ((Patch) context.agent).getPatchNorthWest();
    } else if (context.agent instanceof Turtle) {
      patch = ((Turtle) context.agent).getPatchHere().getPatchNorthWest();
    } else {
View Full Code Here

  public Object report(final Context context) {
    return report_1(context);
  }

  public AgentSet report_1(Context context) {
    Patch patch;
    if (context.agent instanceof Turtle) {
      patch = ((Turtle) context.agent).getPatchHere();
    } else {
      patch = (Patch) context.agent;
    }
    return patch.turtlesHereAgentSet();
  }
View Full Code Here

    double bgcolor =
        ((Double) world.observer().variables
            [world.program().globals().indexOf("BGCOLOR")])
            .doubleValue();
    for (int i = 0; i < patchCount; i++) {
      Patch patch = world.getPatch(i);
      int liveNeighbors = 0;
      for (AgentSet.Iterator iter = patch.getNeighbors().iterator(); iter.hasNext();) {
        if (((Boolean) (((Patch) iter.next()).variables[LIVING_VAR]))
            .booleanValue()) {
          liveNeighbors++;
        }
      }
      patch.variables[LIVE_NEIGHBORS_VAR] = Double.valueOf(liveNeighbors);
    }
    for (int i = 0; i < patchCount; i++) {
      Patch patch = world.getPatch(i);
      int liveNeighbors =
          ((Double) patch.variables[LIVE_NEIGHBORS_VAR]).intValue();
      if (liveNeighbors == 3) {
        patch.variables[LIVING_VAR] = Boolean.TRUE;
        patch.pcolor(fgcolor);
      } else if (liveNeighbors != 2) {
        patch.variables[LIVING_VAR] = Boolean.FALSE;
        patch.pcolor(bgcolor);
      }
    }
    world.tickCounter.tick(1);
    context.ip = next;
  }
View Full Code Here

  public Object report(Context context) {
    return report_1(context);
  }

  public Object report_1(Context context) {
    Patch patch;
    if (context.agent instanceof Patch) {
      patch = ((Patch) context.agent).getPatchSouth();
    } else if (context.agent instanceof Turtle) {
      patch = ((Turtle) context.agent).getPatchHere().getPatchSouth();
    } else {
View Full Code Here

  public Object report(Context context) {
    return report_1(context);
  }

  public Object report_1(Context context) {
    Patch patch;
    if (context.agent instanceof Patch) {
      patch = ((Patch) context.agent).getPatchSouthWest();
    } else if (context.agent instanceof Turtle) {
      patch = ((Turtle) context.agent).getPatchHere().getPatchSouthWest();
    } else {
View Full Code Here

  public Object report(Context context) {
    return report_1(context);
  }

  public Object report_1(Context context) {
    Patch patch;
    if (context.agent instanceof Patch) {
      patch = ((Patch) context.agent).getPatchNorth();
    } else if (context.agent instanceof Turtle) {
      patch = ((Turtle) context.agent).getPatchHere().getPatchNorth();
    } else {
View Full Code Here

      throw new EngineException(context, this, ex.getMessage());
    }
  }

  public double report_2(Context context) {
    Patch patch =
        (context.agent instanceof Turtle)
            ? ((Turtle) context.agent).getPatchHere()
            : (Patch) context.agent;
    return patch.getPatchVariableDouble(vn);
  }
View Full Code Here

  public Object report(Context context) throws LogoException {
    return report_1(context);
  }

  public double report_1(final Context context) throws LogoException {
    Patch patch;
    if (context.agent instanceof Turtle) {
      patch = ((Turtle) context.agent).getPatchHere();
    } else {
      patch = (Patch) context.agent;
    }
    double sum = 0;
    for (AgentSet.Iterator it = patch.getNeighbors4().iterator(); it.hasNext();) {
      Object value = ((Patch) it.next()).getPatchVariable(vn);
      if (!(value instanceof Double)) {
        throw new EngineException(context, this,
            I18N.errorsJ().getN("org.nlogo.prim.$common.noSumOfListWithNonNumbers",
                Dump.logoObject(value).toString(), TypeNames.name(value)));
View Full Code Here

TOP

Related Classes of org.nlogo.agent.Patch

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.