Examples of FastNodeList


Examples of net.sf.l2j.gameserver.pathfinding.utils.FastNodeList

    // Generally returns a bit (only a bit) more intelligent looking routes than
    // the basic version. Not a true distance image (which would increase CPU
    // load) level of intelligence though.

    // List of Visited Nodes
    FastNodeList visited = new FastNodeList(550);

    // List of Nodes to Visit
    LinkedList<Node> to_visit = new LinkedList<Node>();
    to_visit.add(start);
    short targetx = end.getLoc().getNodeX();
    short targety = end.getLoc().getNodeY();
    int dx, dy;
    boolean added;
    int i = 0;
    while (i < 550)
    {
      Node node;
      try
      {
         node = to_visit.removeFirst();
      }
      catch (Exception e)
      {
        // No Path found
        return null;
      }
      if (node.equals(end)) //path found!
        return constructPath(node);
     
      i++;
      visited.add(node);
      node.attacheNeighbors();
      Node[] neighbors = node.getNeighbors();
      if (neighbors == null) continue;
      for (Node n : neighbors)
      {
        if (!visited.containsRev(n) && !to_visit.contains(n))
        {
          added = false;
          n.setParent(node);
          dx = targetx - n.getLoc().getNodeX();
          dy = targety - n.getLoc().getNodeY();
View Full Code Here

Examples of net.sf.l2j.gameserver.pathfinding.utils.FastNodeList

    int start_x = start.getLoc().getX();
    int start_y = start.getLoc().getY();
    int end_x = end.getLoc().getX();
    int end_y = end.getLoc().getY();
    //List of Visited Nodes
    FastNodeList visited = new FastNodeList(800);//TODO! Add limit to cfg

    // List of Nodes to Visit
    BinaryNodeHeap to_visit = new BinaryNodeHeap(800);
    to_visit.add(start);

    int i = 0;
    while (i < 800)//TODO! Add limit to cfg
    {
      Node node;
      try
      {
         node = to_visit.removeFirst();
      }
      catch (Exception e)
      {
        // No Path found
        return null;
      }
      if (node.equals(end)) //path found!
        return constructPath(node);
     
      visited.add(node);
      node.attacheNeighbors();
      for (Node n : node.getNeighbors())
      {
        if (!visited.contains(n) && !to_visit.contains(n))
        {
          i++;
          n.setParent(node);
          n.setCost(Math.abs(start_x - n.getLoc().getNodeX())+Math.abs(start_y - n.getLoc().getNodeY())
              +Math.abs(end_x - n.getLoc().getNodeX())+Math.abs(end_y - n.getLoc().getNodeY()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.