Package org.nlogo.agent

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


        new LinkedHashSet<Patch>();
    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.Patch.class) {
          throw new ArgumentTypeException
              (context, this, i, Syntax.PatchType() | Syntax.PatchsetType(), elt);
        }
        for (AgentSet.Iterator iter = tempSet.iterator(); iter.hasNext();) {
          resultSet.add((Patch) iter.next());
View Full Code Here


      Object obj = iter.next();
      if (obj instanceof Patch) {
        result.add((Patch) obj);
      } else if (obj instanceof AgentSet) {
        AgentSet tempSet = (AgentSet) obj;
        if (tempSet.type() != org.nlogo.agent.Patch.class) {
          throw new EngineException(context, this,
              I18N.errorsJ().getN("org.nlogo.prim.etc._patchset.listInputNonPatchAgentset",
                  this.displayName(), Dump.logoObject(tempList, true, false), Dump.logoObject(obj, true, false)));
        }
        for (AgentSet.Iterator iter2 = tempSet.iterator();
View Full Code Here

      AgentSet agentset = (AgentSet) obj;
      if (agent instanceof Turtle) {
        if (agent.id == -1) {
          return Boolean.FALSE;
        }
        if (agentset.type() != Turtle.class) {
          return Boolean.FALSE;
        }
        if (agentset == world.turtles()) {
          return Boolean.TRUE;
        }
View Full Code Here

      }
      if (agent instanceof Link) {
        if (agent.id == -1) {
          return Boolean.FALSE;
        }
        if (agentset.type() != Link.class) {
          return Boolean.FALSE;
        }
        if (agentset == world.links()) {
          return Boolean.TRUE;
        }
View Full Code Here

          return agentset == ((Link) agent).getBreed() ?
              Boolean.TRUE :
              Boolean.FALSE;
        }
      } else if (agent instanceof Patch) {
        if (agentset.type() != Patch.class) {
          return Boolean.FALSE;
        }
        if (agentset == world.patches()) {
          return Boolean.TRUE;
        }
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

    LinkedHashSet<Link> resultSet = new LinkedHashSet<Link>();
    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.Link.class) {
          throw new ArgumentTypeException
              (context, this, i, Syntax.LinkType() | Syntax.LinksetType(), elt);
        }
        for (AgentSet.Iterator iter = tempSet.iterator(); iter.hasNext();) {
          resultSet.add((Link) iter.next());
View Full Code Here

    for (Object obj : tempList) {
      if (obj instanceof Link) {
        result.add((Link) obj);
      } else if (obj instanceof AgentSet) {
        AgentSet tempSet = (AgentSet) obj;
        if (tempSet.type() != org.nlogo.agent.Link.class) {
          throw new EngineException(context, this,
              I18N.errorsJ().getN("org.nlogo.prim.etc._linkset.invalidLAgentsetTypeInputToList",
                  this.displayName(), Dump.logoObject(tempList, true, false), Dump.logoObject(obj, true, false)));
        }
        for (AgentSet.Iterator iter2 = tempSet.iterator();
View Full Code Here

      addAll(resultList, turtle.getPatchHere().turtlesHere());
    } else if (agentOrSet instanceof Patch) {
      addAll(resultList, ((Patch) agentOrSet).turtlesHere());
    } else if (agentOrSet instanceof AgentSet) {
      AgentSet sourceSet = (AgentSet) agentOrSet;
      if (sourceSet.type() == Turtle.class) {
        for (AgentSet.Iterator iter = sourceSet.iterator(); iter.hasNext();) {
          addAll(resultList, ((Turtle) iter.next()).getPatchHere().turtlesHere());
        }
      } else {
        for (AgentSet.Iterator iter = sourceSet.iterator(); iter.hasNext();) {
View Full Code Here

          resultList.add(turtle);
        }
      }
    } else if (agentOrSet instanceof AgentSet) {
      AgentSet sourceSet = (AgentSet) agentOrSet;
      if (sourceSet.type() == Turtle.class) {
        for (AgentSet.Iterator iter = sourceSet.iterator(); iter.hasNext();) {
          for (Turtle turtle : ((Turtle) iter.next()).getPatchHere().turtlesHere()) {
            if (turtle.getBreed() == breed) {
              resultList.add(turtle);
            }
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.