Package org.nlogo.agent

Examples of org.nlogo.agent.Agent


    }
    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._lessorequal.cannotCompareParameters",
View Full Code Here


        (Syntax.AgentType(), "-TPL");
  }

  @Override
  public Object report(final Context context) throws LogoException {
    Agent myself = context.myself();
    if (myself == null || myself instanceof Observer) {
      throw new EngineException
          (context, this, I18N.errorsJ().get("org.nlogo.prim.etc._myself.noAgentMyself"));
    }
    return myself;
View Full Code Here

    }
    return myself;
  }

  public Agent report_1(Context context) throws LogoException {
    Agent myself = context.myself();
    if (myself == null || myself instanceof Observer) {
      throw new EngineException
          (context, this, I18N.errorsJ().get("org.nlogo.prim.etc._myself.noAgentMyself"));
    }
    return myself;
View Full Code Here

    } else if (obj instanceof String) {
      return ((String) obj).indexOf(argEvalString(context, 0)) != -1
          ? Boolean.TRUE
          : Boolean.FALSE;
    } else if (obj instanceof AgentSet) {
      Agent agent = argEvalAgent(context, 0);
      AgentSet agentset = (AgentSet) obj;
      if (agent instanceof Turtle) {
        if (agent.id == -1) {
          return Boolean.FALSE;
        }
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

      throws LogoException {
    Context freshContext = new Context(context, sourceSet);
    int result = 0;
    reporterBlock.checkAgentSetClass(sourceSet, context);
    for (AgentSet.Iterator iter = sourceSet.iterator(); iter.hasNext();) {
      Agent tester = iter.next();
      if (tester == context.agent) {
        continue;
      }
      Object value = freshContext.evaluateReporter(tester, reporterBlock);
      if (!(value instanceof Boolean)) {
View Full Code Here

  @Override
  public Object report(final Context context) throws LogoException {
    Object agentOrSet = args[0].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()));
      }
      try {
        return agent.getLinkVariable(vn);
      } catch (org.nlogo.api.AgentException ex) {
        throw new EngineException(context, this, ex.getMessage());
      }
    } else if (agentOrSet instanceof AgentSet) {
      AgentSet sourceSet = (AgentSet) agentOrSet;
View Full Code Here

    return Syntax.reporterSyntax(right, ret);
  }

  public Object report_1(final Context context, Object agentOrSet) throws LogoException {
    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()));
      }
      try {
        return agent.getLinkVariable(vn);
      } catch (org.nlogo.api.AgentException ex) {
        throw new EngineException(context, this, ex.getMessage());
      }
    } else if (agentOrSet instanceof AgentSet) {
      AgentSet sourceSet = (AgentSet) agentOrSet;
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._greaterthan.cannotCompareParameters",
View Full Code Here

  @Override
  public Object report(Context context) throws LogoException {
    Object agentOrSet = args[0].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()));
      }
      try {
        return agent.getBreedVariable(name);
      } catch (org.nlogo.api.AgentException ex) {
        throw new EngineException(context, this, ex.getMessage());
      }
    } else if (agentOrSet instanceof AgentSet) {
      AgentSet sourceSet = (AgentSet) agentOrSet;
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.