Package org.nlogo.agent

Examples of org.nlogo.agent.AgentSet.type()


            if (turtle.getBreed() == breed) {
              resultList.add(turtle);
            }
          }
        }
      } else if (sourceSet.type() == Patch.class) {
        for (AgentSet.Iterator iter = sourceSet.iterator(); iter.hasNext();) {
          for (Turtle turtle : ((Patch) iter.next()).turtlesHere()) {
            if (turtle.getBreed() == breed) {
              resultList.add(turtle);
            }
View Full Code Here


  public org.nlogo.agent.AgentSet argEvalAgentSet(Context context, int argIndex, Class<? extends Agent> type)
      throws LogoException {
    Object obj = args[argIndex].report(context);
    try {
      AgentSet set = (org.nlogo.agent.AgentSet) obj;
      if (set.type() != type) {
        throw new ArgumentTypeException(context, this, argIndex,
            getAgentSetMask(type), obj);
      }
      return set;
    } catch (ClassCastException ex) {
View Full Code Here

  }

  @Override
  public void perform(final Context context) throws LogoException {
    AgentSet agentset = argEvalAgentSet(context, 0);
    if (agentset.type() != Turtle.class) {
      throw new ArgumentTypeException(
        context, this, 0, Syntax.TurtlesetType(), agentset);
    }
    AgentSet breed = breedName == null ? world.links() : world.getLinkBreed(breedName);
    mustNotBeUndirected(breed, context);
View Full Code Here

  }

  @Override
  public void perform(final Context context) throws LogoException {
    AgentSet agentset = argEvalAgentSet(context, 0);
    if (agentset.type() != Turtle.class) {
      throw new ArgumentTypeException(
        context, this, 0, Syntax.TurtlesetType(), agentset);
    }
    AgentSet breed = breedName == null ? world.links() : world.getLinkBreed(breedName);
    mustNotBeUndirected(breed, context);
View Full Code Here

  }

  @Override
  public void perform(final Context context) throws LogoException {
    AgentSet agentset = argEvalAgentSet(context, 0);
    if (agentset.type() != Turtle.class) {
      throw new ArgumentTypeException(
        context, this, 0, Syntax.TurtlesetType(), agentset);
    }
    AgentSet breed = breedName == null ? world.links() : world.getLinkBreed(breedName);
    mustNotBeDirected(breed, context);
View Full Code Here

    // part 2: figure out which patches are at the given points
    Set<Patch> patches =
        getPatchesAtPoints(context, context.agent, points);

    // part 3: construct a new agentset and return it
    if (sourceSet.type() == Patch.class) {
      if (sourceSet != world.patches()) {   //sourceSet is not the entire set of patches
        for (Iterator<Patch> iter = patches.iterator(); iter.hasNext();) {
          Patch patch = iter.next();
          if (sourceSet.contains(patch)) {
            result.add(patch);
View Full Code Here

          }
        }
      } else //sourceSet is the entire set of patches
        result.addAll(patches);
      }
    } else if (sourceSet.type() == Turtle.class) {
      if (sourceSet != world.turtles()) {  //sourceSet is not the entire set of turtles
        if (world.isBreed(sourceSet)) {  //source set is a breed
          for (Iterator<Patch> iter = patches.iterator(); iter.hasNext();) {
            Patch otherPatch = iter.next();
            for (Turtle tempTurtle : otherPatch.turtlesHere()) {
View Full Code Here

        }
      }

    }
    return new ArrayAgentSet
        (sourceSet.type(), result.toArray(new Agent[result.size()]),
            world);
  }

  private boolean validateListEntry(Object entry) {
    if (entry instanceof LogoList) {
View Full Code Here

        }
        result.add(tester);
      }
    }
    return new org.nlogo.agent.ArrayAgentSet
        (sourceSet.type(),
            result.toArray(new Agent[result.size()]),
            world);
  }
}
View Full Code Here

        new LinkedHashSet<Turtle>();
    for (int i = 0; i < args.length; i++) {
      Object elt = args[i].report(context);
      if (elt instanceof AgentSet) {
        AgentSet tempSet = (AgentSet) elt;
        if (tempSet.type() != org.nlogo.agent.Turtle.class) {
          throw new ArgumentTypeException
              (context, this, i, Syntax.TurtleType() | Syntax.TurtlesetType(), elt);
        }
        for (AgentSet.Iterator iter = tempSet.iterator();
             iter.hasNext();) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.