Examples of BinaryNodeHeap


Examples of com.l2jfrozen.gameserver.geo.pathfinding.utils.BinaryNodeHeap

    int end_y = end.getY();
    //List of Visited Nodes
    L2FastSet<Node> visited = L2Collections.newL2FastSet();//TODO! Add limit to cfg

    // List of Nodes to Visit
    BinaryNodeHeap to_visit = BinaryNodeHeap.newInstance();
    to_visit.add(start);
    try
    {
      int i = 0;
      while(i < 800)//TODO! Add limit to cfg
      {
        if(to_visit.isEmpty())
        {
          // No Path found
          return null;
        }

        Node node;
        try
        {
          node = to_visit.removeFirst();
        }
        catch(Exception e)
        {
          // No Path found
          if(Config.ENABLE_ALL_EXCEPTIONS)
            e.printStackTrace();
         
          return null;
        }
        if(node.equals(end)) //path found!
          return constructPath(node);
        visited.add(node);
        node.attachNeighbors();
        for(Node n : node.getNeighbors())
        {
          if(!visited.contains(n) && !to_visit.contains(n))
          {
            i++;
            n.setParent(node);
            n.setCost(Math.abs(start_x - n.getNodeX())
              + Math.abs(start_y - n.getNodeY()) + Math.abs(end_x - n.getNodeX())
              + Math.abs(end_y - n.getNodeY()));
            to_visit.add(n);
          }
        }
      }
      //No Path found
      return null;
View Full Code Here

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

    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()));
          to_visit.add(n);
        }
      }
    }
    //No Path found
    return null;
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.