Package org.nlogo.agent

Examples of org.nlogo.agent.AgentSet


  }

  public AgentSet report_3(Context context, Agent agent)
      throws LogoException {
    List<Turtle> resultList = new ArrayList<Turtle>();
    AgentSet breed = world.getBreed(breedName);
    if (agent instanceof Turtle) {
      Turtle turtle = (Turtle) agent;
      if (turtle.id == -1) {
        throw new EngineException(context, this,
          I18N.errorsJ().getN("org.nlogo.$common.thatAgentIsDead", turtle.classDisplayName()));
View Full Code Here


  }

  public AgentSet report_4(Context context, Turtle turtle)
      throws LogoException {
    List<Turtle> resultList = new ArrayList<Turtle>();
    AgentSet breed = world.getBreed(breedName);
    if (turtle.id == -1) {
      throw new EngineException(context, this,
        I18N.errorsJ().getN("org.nlogo.$common.thatAgentIsDead", turtle.classDisplayName()));
    }
    for (Turtle t : turtle.getPatchHere().turtlesHere()) {
View Full Code Here

        (Turtle.class, resultList.toArray(new Turtle[resultList.size()]), world);
  }

  public AgentSet report_5(Context context, Patch patch) {
    List<Turtle> resultList = new ArrayList<Turtle>();
    AgentSet breed = world.getBreed(breedName);
    for (Turtle turtle : patch.turtlesHere()) {
      if (turtle.getBreed() == breed) {
        resultList.add(turtle);
      }
    }
View Full Code Here

    return super.toString() + ":+" + offset;
  }

  @Override
  public void perform(final org.nlogo.nvm.Context context) throws LogoException {
    AgentSet agentset = argEvalAgentSet(context, 0);
    if (!(context.agent instanceof org.nlogo.agent.Observer)) {
      if (agentset == world.turtles()) {
        throw new EngineException
            (context, this, I18N.errorsJ().get("org.nlogo.prim.$common.onlyObserverCanAskAllTurtles"));
      }
View Full Code Here

        return agent.getPatchVariable(vn);
      } catch (org.nlogo.api.AgentException ex) {
        throw new EngineException(context, this, ex.getMessage());
      }
    } else if (agentOrSet instanceof AgentSet) {
      AgentSet sourceSet = (AgentSet) agentOrSet;
      LogoListBuilder result = new LogoListBuilder();
      try {
        for (AgentSet.Iterator iter = sourceSet.shufflerator(context.job.random);
             iter.hasNext();) {
          result.add(iter.next().getPatchVariable(vn));
        }
      } catch (org.nlogo.api.AgentException ex) {
        throw new EngineException(context, this, ex.getMessage());
View Full Code Here

        return agent.getPatchVariable(vn);
      } catch (org.nlogo.api.AgentException ex) {
        throw new EngineException(context, this, ex.getMessage());
      }
    } else if (agentOrSet instanceof AgentSet) {
      AgentSet sourceSet = (AgentSet) agentOrSet;
      LogoListBuilder result = new LogoListBuilder();
      try {
        for (AgentSet.Iterator iter = sourceSet.shufflerator(context.job.random);
             iter.hasNext();) {
          result.add(iter.next().getPatchVariable(vn));
        }
      } catch (org.nlogo.api.AgentException ex) {
        throw new EngineException(context, this, ex.getMessage());
View Full Code Here

      throws LogoException {
    return report_1(context, argEvalAgentSet(context, 0));
  }

  public AgentSet report_1(final Context context, AgentSet sourceSet) {
    AgentSet result =
        new org.nlogo.agent.ArrayAgentSet(sourceSet.type(), sourceSet.count(),
            false, world);
    for (AgentSet.Iterator it = sourceSet.iterator(); it.hasNext();) {
      Agent otherAgent = it.next();
      if (context.agent != otherAgent) {
        result.add(otherAgent);
      }
    }
    return result;
  }
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

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

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

  public AgentSet report_1(Context context) throws LogoException {
    AgentSet breed = breedName == null ? world.links() : world.getLinkBreed(breedName);
    mustNotBeDirected(breed, context);
    return world.linkManager.findLinkedWith((Turtle) context.agent, breed);
  }
View Full Code Here

TOP

Related Classes of org.nlogo.agent.AgentSet

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.