Package org.nlogo.agent

Examples of org.nlogo.agent.Agent


  @Override
  public Object report(final Context context) throws LogoException {
    Object agentOrSet = args[1].report(context);
    if (agentOrSet instanceof Agent) {
      Agent agent = (Agent) agentOrSet;
      if (agent.id == -1) {
        throw new EngineException(context, this,
          I18N.errorsJ().getN("org.nlogo.$common.thatAgentIsDead", agent.classDisplayName()));
      }
      args[0].checkAgentClass(agent, context);
      return new Context(context, agent).evaluateReporter(agent, args[0]);
    } else if (agentOrSet instanceof AgentSet) {
      AgentSet sourceSet = (AgentSet) agentOrSet;
View Full Code Here


  public boolean report_1(final Context context, AgentSet sourceSet, Reporter reporterBlock)
      throws LogoException {
    Context freshContext = new Context(context, sourceSet);
    reporterBlock.checkAgentSetClass(sourceSet, context);
    for (AgentSet.Iterator iter = sourceSet.iterator(); iter.hasNext();) {
      Agent tester = iter.next();
      Object value = freshContext.evaluateReporter(tester, reporterBlock);
      if (!(value instanceof Boolean)) {
        throw new EngineException(context, this,
            I18N.errorsJ().getN("org.nlogo.prim.$common.expectedBooleanValue",
                displayName(), Dump.logoObject(tester), Dump.logoObject(value)));
View Full Code Here

    }
    if (o1 instanceof String && o2 instanceof String) {
      return (((String) o1).compareTo((String) o2) >= 0);
    }
    if (o1 instanceof Agent && o2 instanceof Agent) {
      Agent a1 = (Agent) o1;
      Agent a2 = (Agent) o2;
      if (a1.getAgentBit() == a2.getAgentBit()) {
        return a1.compareTo(a2) >= 0;
      }
    }
    throw new EngineException(context, this,
        I18N.errorsJ().getN("org.nlogo.prim._greaterorequal.cannotCompareParameters",
View Full Code Here

  }

  @Override
  public void perform(final org.nlogo.nvm.Context context)
      throws LogoException {
    Agent otherAgent = argEvalAgent(context, 0);
    if (otherAgent.id == -1) {
      throw new EngineException(context, this,
          I18N.errorsJ().getN("org.nlogo.$common.thatAgentIsDead", otherAgent.classDisplayName()));
    }
    if (otherAgent instanceof org.nlogo.agent.Link) {
      throw new EngineException(context, this, "you can't move-to a link");
    }
    try {
View Full Code Here

    double winningValue = Double.MAX_VALUE;
    Context freshContext = new Context(context, sourceSet);
    List<Agent> result = new ArrayList<Agent>();
    args[1].checkAgentSetClass(sourceSet, context);
    for (AgentSet.Iterator iter = sourceSet.iterator(); iter.hasNext();) {
      Agent tester = iter.next();
      Object value = freshContext.evaluateReporter(tester, args[1]);
      if (!(value instanceof Double)) {
        continue;
      }
      double dvalue = ((Double) value).doubleValue();
View Full Code Here

    return Syntax.reporterSyntax(right, Syntax.NumberType(), "-TP-");
  }

  @Override
  public Object report(Context context) throws LogoException {
    Agent agent = argEvalAgent(context, 0);
    if (agent instanceof org.nlogo.agent.Link) {
      throw new EngineException
          (context, this, I18N.errorsJ().get("org.nlogo.prim.etc.$common.expectedTurtleOrPatchButGotLink"));
    }
    if (agent.id == -1) {
      throw new EngineException(context, this,
        I18N.errorsJ().getN("org.nlogo.$common.thatAgentIsDead", agent.classDisplayName()));
    }
    try {
      return validDouble
          (world.protractor().towards
              (context.agent, agent, true)); // true = wrap
View Full Code Here

TOP

Related Classes of org.nlogo.agent.Agent

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.