Package org.nlogo.agent

Examples of org.nlogo.agent.Link


        (Syntax.AgentType(), "-T-L");
  }

  @Override
  public Object report(final org.nlogo.nvm.Context context) throws LogoException {
    Link link;
    Turtle node;
    if (context.agent instanceof Link) {
      link = (Link) context.agent;
      if (!(context.myself() instanceof Turtle)) {
        throw new EngineException(context, this,
            I18N.errorsJ().get("org.nlogo.prim.etc._otherend.onlyTurtleCanGetLinkEnd"));
      }
      node = (Turtle) context.myself();
    } else {
      node = (Turtle) context.agent;
      if (!(context.myself() instanceof Link)) {
        throw new EngineException(context, this,
            I18N.errorsJ().get("org.nlogo.prim.etc._otherend.onlyLinkCanGetTurtleEnd"));
      }
      link = (Link) context.myself();
    }

    Turtle dest = link.end2();
    Turtle src = link.end1();
    if (dest == node) {
      return src;
    }
    if (src == node) {
      return dest;
    }

    throw new EngineException(context, this,
        I18N.errorsJ().getN("org.nlogo.prim.etc._otherend.incorrectLink", node.toString(), link.toString()));
  }
View Full Code Here


          throw new EngineException
              (context, this,
                  I18N.errorsJ().get("org.nlogo.prim.$common.turtleCantLinkToSelf"));
        }
        if (src.id != -1 && dest.id != -1) {
          Link link = world.linkManager.createLink(src, dest, breed);
          edgeset.add(link);
          workspace.joinForeverButtons(link);
        }
      }
    }
View Full Code Here

        throw new EngineException
            (context, this,
                I18N.errorsJ().get("org.nlogo.prim.$common.turtleCantLinkToSelf"));
      }
      if (src.id != -1 && dest.id != -1) {
        Link link = world.linkManager.createLink(src, dest, breed);
        if (offset - context.ip > 2) {
          AgentSet edgeset = new org.nlogo.agent.ArrayAgentSet(Link.class, 1,
              false, world);
          edgeset.add(link);
          workspace.joinForeverButtons(link);
View Full Code Here

    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$;
    }
    return link;
  }
View Full Code Here

          throw new EngineException
              (context, this,
                  I18N.errorsJ().get("org.nlogo.prim.$common.turtleCantLinkToSelf"));
        }
        if (src.id != -1 && dest.id != -1) {
          Link link = world.linkManager.createLink(src, dest, breed);
          edgeset.add(link);
          workspace.joinForeverButtons(link);
        }
      }
    }
View Full Code Here

          throw new EngineException
              (context, this,
                  I18N.errorsJ().get("org.nlogo.prim.$common.turtleCantLinkToSelf"));
        }
        if (src.id != -1 && dest.id != -1) {
          Link link;
          if (src.id > dest.id) {
            link = world.linkManager.createLink(dest, src, breed);
          } else {
            link = world.linkManager.createLink(src, dest, breed);
          }
View Full Code Here

        Turtle tmp = src;
        src = dest;
        dest = tmp;
      }
      if (src.id != -1 && dest.id != -1) {
        Link link = world.linkManager.createLink(src, dest, breed);
        workspace.joinForeverButtons(link);

        if (offset - context.ip > 2) {
          // Needed to run the commands with runExclusive(). I was not
          // clear how to run those commands otherwise.  -CLB 03/16/06
View Full Code Here

  }

  @Override
  public Object report(final Context context) throws LogoException {
    AgentSet breed = world.getLinkBreed(breedName);
    Link link = world.getLink(argEvalDouble(context, 0),
        argEvalDouble(context, 1), breed);
    if (link == null) {
      return Nobody$.MODULE$;
    }
    return link;
View Full Code Here

      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 &&
          link.getBreed() == world.getLinkBreed(breedName))
          ? Boolean.TRUE
          : Boolean.FALSE;
    } else {
      return Boolean.FALSE;
    }
View Full Code Here

    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

TOP

Related Classes of org.nlogo.agent.Link

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.