Package org.nlogo.agent

Examples of org.nlogo.agent.Turtle


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

  @Override
  public void perform(final Context context) throws LogoException {
    Turtle dest = argEvalTurtle(context, 0);
    Turtle src = (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


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

  public boolean report_1(Context context, Turtle target) throws LogoException {
    Turtle parent = (Turtle) context.agent;
    AgentSet breed =
        breedName == null
            ? world.links()
            : world.getLinkBreed(breedName);
    mustNotBeDirected(breed, context);
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);
    mustNotBeDirected(breed, context);
    Link link = linkManager.findLinkEitherWay(parent, target, breed, true);
    if (link == null) {
      return org.nlogo.api.Nobody$.MODULE$;
View Full Code Here

    if (breed == world.links()) {
      breed.setDirected(true);
    }
    AgentSet edgeset = new org.nlogo.agent.ArrayAgentSet(Link.class, agentset.count(),
        false, world);
    Turtle dest = (Turtle) context.agent;
    // We have to shuffle here in order for who number assignment
    // to be random! - ST 3/15/06
    for (AgentSet.Iterator iter = agentset.shufflerator(context.job.random); iter.hasNext();) {
      Turtle src = (Turtle) iter.next();
      if (world.linkManager.findLinkFrom(src, dest, breed, false) == null) {
        if (src == dest) {
          throw new EngineException
              (context, this,
                  I18N.errorsJ().get("org.nlogo.prim.$common.turtleCantLinkToSelf"));
View Full Code Here

      AgentSet agentset =
          new ArrayAgentSet(Turtle.class, numberOfTurtles,
              false, world);
      if (breedName == NO_BREED) {
        for (int i = 0; i < numberOfTurtles; i++) {
          Turtle child = parent.sprout
              (random.nextInt(14), random.nextInt(360), world.turtles());
          agentset.add(child);
          workspace.joinForeverButtons(child);
        }
      } else {
        AgentSet breed = world.getBreed(breedName);
        for (int i = 0; i < numberOfTurtles; i++) {
          Turtle child = parent.sprout
              (random.nextInt(14), random.nextInt(360), breed);
          agentset.add(child);
          workspace.joinForeverButtons(child);
        }
      }
View Full Code Here

      AgentSet breed =
          breedName == NO_BREED
              ? world.turtles()
              : world.getBreed(breedName);
      for (int i = 0; i < numberOfTurtles; i++) {
        Turtle turtle = world.createTurtle(breed);
        turtle.colorDouble(Double.valueOf(10.0 * i + 5.0));
        turtle.heading((360.0 * i) / numberOfTurtles);
        agentset.add(turtle);
        workspace.joinForeverButtons(turtle);
      }
      context.runExclusiveJob(agentset, next);
    }
View Full Code Here

    if (breed == world.links()) {
      breed.setDirected(false);
    }
    AgentSet edgeset = new org.nlogo.agent.ArrayAgentSet(Link.class, agentset.count(),
        false, world);
    Turtle src = (Turtle) context.agent;
    // We have to shuffle here in order for who number assignment
    // to be random! - ST 3/15/06
    for (AgentSet.Iterator iter = agentset.shufflerator(context.job.random); iter.hasNext();) {
      Turtle dest = (Turtle) iter.next();
      if (world.linkManager.findLinkEitherWay(src, dest, breed, false) == null) {
        if (src == dest) {
          throw new EngineException
              (context, this,
                  I18N.errorsJ().get("org.nlogo.prim.$common.turtleCantLinkToSelf"));
View Full Code Here

          breedName == _createturtles.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));
        workspace.joinForeverButtons(turtle);
      }
    }
View Full Code Here

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

  @Override
  public void perform(final Context context) throws LogoException {
    Turtle dest = argEvalTurtle(context, 0);
    Turtle src = (Turtle) context.agent;
    AgentSet breed = breedName == null ? world.links() : world.getLinkBreed(breedName);
    mustNotBeDirected(breed, context);
    checkForBreedCompatibility(breed, context);
    if (breed == world.links()) {
      breed.setDirected(false);
    }
    if (world.linkManager.findLinkEitherWay(src, dest, breed, false) == null) {
      if (src == dest) {
        throw new EngineException
            (context, this,
                I18N.errorsJ().get("org.nlogo.prim.$common.turtleCantLinkToSelf"));
      }
      if (src.id > dest.id) {
        Turtle tmp = src;
        src = dest;
        dest = tmp;
      }
      if (src.id != -1 && dest.id != -1) {
        Link link = world.linkManager.createLink(src, dest, breed);
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;
      if (breedName == _hatch.NO_BREED) {
        for (int i = 0; i < numberOfTurtles; i++) {
          workspace.joinForeverButtons(parent.hatch());
        }
      } else {
        AgentSet breed = world.getBreed(breedName);
        for (int i = 0; i < numberOfTurtles; i++) {
          Turtle child = parent.hatch();
          child.setBreed(breed);
          workspace.joinForeverButtons(child);
        }
      }
    }
    context.ip = next;
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.