Package org.nlogo.agent

Examples of org.nlogo.agent.Turtle


  @Override
  public Object report(final Context context) throws LogoException {
    Object thing = args[0].report(context);
    if (thing instanceof Turtle) {
      Turtle turtle = (Turtle) thing;
      return (turtle.id != -1 &&
          turtle.getBreed() == world.getBreed(breedName))
          ? Boolean.TRUE
          : Boolean.FALSE;
    } else if (thing instanceof Link) {
      Link link = (Link) thing;
      return (link.id != -1 &&
View Full Code Here


          breedName == NO_BREED
              ? world.turtles()
              : world.getBreed(breedName);
      org.nlogo.util.MersenneTwisterFast random = context.job.random;
      for (int i = 0; i < numberOfTurtles; i++) {
        Turtle turtle =
            world.createTurtle(breed, random.nextInt(14),
                random.nextInt(360));
        agentset.add(turtle);
        workspace.joinForeverButtons(turtle);
      }
View Full Code Here

  @Override
  public Object report(final org.nlogo.nvm.Context context) throws LogoException {
    org.nlogo.agent.LinkManager linkManager = world.linkManager;
    AgentSet breed = breedName == null ? world.links() : world.getLinkBreed(breedName);
    mustNotBeUndirected(breed, context);
    Turtle parent = (Turtle) context.agent;
    Turtle target = argEvalTurtle(context, 0);
    Link link = linkManager.findLinkFrom(parent, target, breed, true);
    if (link == null) {
      return org.nlogo.api.Nobody$.MODULE$;
    }
    return link;
View Full Code Here

  public Object report(final Context context)
      throws LogoException {
    org.nlogo.agent.LinkManager linkManager = world.linkManager;
    AgentSet breed = breedName == null ? world.links() : world.getLinkBreed(breedName);
    mustNotBeUndirected(breed, context);
    Turtle target = argEvalTurtle(context, 0);
    Link link = linkManager.findLinkFrom(target, (Turtle) context.agent, breed, true);
    if (link == null) {
      return org.nlogo.api.Nobody$.MODULE$;
    }
    return link;
View Full Code Here

  }

  @Override
  public Object report(final org.nlogo.nvm.Context context) throws LogoException {
    org.nlogo.agent.LinkManager linkManager = world.linkManager;
    Turtle parent = (Turtle) context.agent;
    Turtle target = argEvalTurtle(context, 0);
    AgentSet breed = breedName == null ? world.links() : world.getLinkBreed(breedName);
    mustNotBeUndirected(breed, context);
    return linkManager.findLinkFrom(parent, target, breed, true) == null
        ? Boolean.FALSE
        : Boolean.TRUE;
View Full Code Here

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

  @Override
  public void perform(final Context context) throws LogoException {
    Turtle src = argEvalTurtle(context, 0);
    Turtle dest = (Turtle) context.agent;
    AgentSet breed = breedName == null ? world.links() : world.getLinkBreed(breedName);
    mustNotBeUndirected(breed, context);
    checkForBreedCompatibility(breed, context);
    if (breed == world.links()) {
      breed.setDirected(true);
View Full Code Here

  @Override
  public void perform(final org.nlogo.nvm.Context context) throws LogoException {
    int numberOfTurtles = argEvalIntValue(context, 0);
    if (numberOfTurtles > 0) {
      Turtle parent = (Turtle) context.agent;
      AgentSet agentset =
          new org.nlogo.agent.ArrayAgentSet(Turtle.class, numberOfTurtles, false, world);
      if (breedName == NO_BREED) {
        for (int i = 0; i < numberOfTurtles; i++) {
          Turtle child = parent.hatch();
          agentset.add(child);
          workspace.joinForeverButtons(child);
        }
      } else {
        AgentSet breed = world.getBreed(breedName);
        for (int i = 0; i < numberOfTurtles; i++) {
          Turtle child = parent.hatch();
          child.setBreed(breed);
          agentset.add(child);
          workspace.joinForeverButtons(child);
        }
      }
      context.runExclusiveJob(agentset, next);
View Full Code Here

    long id = validLong(idDouble);
    if (id != idDouble) {
      throw new EngineException
          (context, this, idDouble + " is not an integer");
    }
    Turtle turtle = world.getTurtle(id);
    if (turtle == null) {
      return Nobody$.MODULE$;
    }
    AgentSet breed = world.getBreed(breedName);
    if (!breed.contains(turtle)) {
View Full Code Here

  @Override
  public void perform(final Context context)
      throws LogoException {
    AgentSet nodeset = argEvalAgentSet(context, 0, Turtle.class);
    AgentSet linkset = argEvalAgentSet(context, 1, Link.class);
    Turtle root = argEvalTurtle(context, 2);
    try {
      org.nlogo.agent.Layouts.radial(world, nodeset, linkset, root);
    } catch (org.nlogo.api.AgentException e) {
      throw new EngineException(context, this, e.getMessage());
    }
View Full Code Here

    return Syntax.commandSyntax(right, "-T--", true);
  }

  @Override
  public void perform(final Context context) throws LogoException {
    Turtle turtle = (Turtle) context.agent;
    Double newx = argEvalDouble(context, 0);
    Double newy = argEvalDouble(context, 1);
    try {
      double xvalue = newx.doubleValue();
      double yvalue = newy.doubleValue();
      double x = turtle.shortestPathX(xvalue);
      double y = turtle.shortestPathY(yvalue);
      if (x != xvalue) {
        newx = Double.valueOf(x);
      }
      if (y != yvalue) {
        newy = Double.valueOf(y);
      }
      turtle.xandycor(newx, newy);
    } catch (org.nlogo.api.AgentException e) {
      throw new EngineException(context, this,
          I18N.errorsJ().getN("org.nlogo.prim.etc._setxy.pointOutsideWorld",
              newx.doubleValue(), newy.doubleValue()));
    }
View Full Code Here

TOP

Related Classes of org.nlogo.agent.Turtle

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.