1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Tutorial Understanding Runemate's Pathing Systems, and Utilizing Them

Discussion in 'Tutorials & Resources' started by Snufalufugus, Dec 25, 2017.

  1. Snufalufugus

    Joined:
    Aug 23, 2015
    Messages:
    1,961
    Likes Received:
    757
    Why Pathing is Important:
    Runemate's pathing systems are what allow bots to move between locations in-game. Any bot in the store that moves more than a screen distance away utilizes some sort of pathing.

    Types of Paths available:
    Bresenham Path:
    Builds a direct line between two points.

    Region Path: Generates a path constricted to the currently loaded in-game region (104x104). The generated path is based on the regions collision flags (these detect you can't walk through, and some other things) to allow you to walk around obstacles such as buildings or trees.

    Predefined Path: A path defined by you (the author), consisting of a set of coordinates that are traversed in order.

    Viewport Path: A path that clicks on in-game tiles to walk. To create a viewport path, generate a Coordinate Path (AKA a Bresenham, Region, or Predefined path), and convert to viewport.

    (Default) Webpath: Uses Runemate's default web to generate a path. This path can handle most obstacles such as doors and staircases, will utilize Normal/Lunar/Ancient teleports, jewelry teleports, spirit trees, and gnome gliders. Usage is recommended only when traversing past obstacles or over significant distances.

    Advantages/Disadvantages of Paths:
    Each of these examples is in the form of a TreeTask, which is the "Leaf" of a treebot.

    Bresenham Path: Doesn't navigate around objects. Bresenham paths are best used in large open areas for basic walking. Reliable generation as long as no obstacles, such as doors, block the path generation.

    Region Path: Paths go around objects, but cannot pass obstacles such as doors or agility shortcuts. Path will generate null if you try to walk to a different in-game region.

    Predefined Path: Very reliable since the path is supplied by the author instead of generated, but restrictive and repetitive by nature. Usage is discouraged. Cannot traverse obstacles such as doors.

    Viewport Path: Clicks on in-game tiles to walk, which allows for greater precision when you need to walk to a specific tile. Can be more human-like in certain situations.

    (Default) Webpath: Can traverse obstacles such as doors, staircases, and ladders (Aka can move between in-game planes). Utilizes many teleports without significant implementation efforts by the authors. Has one disadvantage - If the webpath doesn't work properly, or doesn't generate, the author must rely on Runemate staff for the problem to be fixed.

    Coding with Paths:
    Bresenham Path:
    Code (Text):
    1. public class Walk extends LeafTask {
    2.  
    3.     private Coordinate destination = new Coordinate(3013, 5608, 0);
    4.  
    5.     @Override
    6.     public void execute() {
    7.         BresenhamPath bresPath = BresenhamPath.buildTo(destination);
    8.         if(bresPath != null){
    9.             bresPath.step();
    10.         } else {
    11.             getLogger().warn("bresPath was null in Walk");
    12.         }
    13.     }
    14.  
    15. }

    Region Path:
    Code (Text):
    1. public class Walk extends LeafTask {
    2.  
    3.     private Coordinate destination = new Coordinate(3013, 5608, 0);
    4.  
    5.     @Override
    6.     public void execute() {
    7.         RegionPath regionPath = RegionPath.buildTo(destination);
    8.         if(regionPath != null){
    9.             regionPath.step();
    10.         } else {
    11.             getLogger().warn("regionPath was null in Walk");
    12.         }
    13.     }
    14.  
    15. }

    Predefined Path:
    Code (Text):
    1. public class Walk extends LeafTask {
    2.  
    3.     private PredefinedPath predefined = PredefinedPath.create(new Coordinate(3016, 5627, 0), new Coordinate(3015, 5624, 0), new Coordinate(3015, 5622, 0),
    4.             new Coordinate(3014, 5619, 0), new Coordinate(3013, 5616, 0), new Coordinate(3013, 5613, 0), new Coordinate(3013, 5611, 0),
    5.             new Coordinate(3013, 5608, 0));
    6.  
    7.     @Override
    8.     public void execute() {
    9.         if(predefined != null){
    10.             predefined.step();
    11.         } else {
    12.             getLogger().warn("predefined was null in Walk");
    13.         }
    14.     }
    15.  
    16. }

    Viewport Path:
    Code (Text):
    1. public class Walk extends LeafTask {
    2.  
    3.     private PredefinedPath predefined = PredefinedPath.create(new Coordinate(3016, 5627, 0), new Coordinate(3015, 5624, 0), new Coordinate(3015, 5622, 0),
    4.             new Coordinate(3014, 5619, 0), new Coordinate(3013, 5616, 0), new Coordinate(3013, 5613, 0), new Coordinate(3013, 5611, 0),
    5.             new Coordinate(3013, 5608, 0));
    6.  
    7.     @Override
    8.     public void execute() {
    9.         if(predefined != null){
    10.             ViewportPath viewport = ViewportPath.convert(predefined);
    11.             //viewport won't ever be null, so no need to null check it
    12.             Coordinate nextStep = viewport.getNext();
    13.             if(nextStep != null){
    14.                 if(nextStep.isVisible()){
    15.                     viewport.step();
    16.                 } else {
    17.                     Camera.concurrentlyTurnTo(nextStep);
    18.                 }
    19.             } else {
    20.                 getLogger().warn("Could not get next step of viewport");
    21.             }
    22.         } else {
    23.             getLogger().warn("predefined was null in Walk");
    24.         }
    25.     }
    26.  
    27. }

    (Default) Webpath:
    Code (Text):
    1. public class Walk extends LeafTask {
    2.  
    3.     private Coordinate destination = new Coordinate(3013, 5608, 0);
    4.  
    5.     @Override
    6.     public void execute() {
    7.         WebPath webPath = Traversal.getDefaultWeb().getPathBuilder().buildTo(destination);
    8.         if(webPath != null){
    9.             webPath.step();
    10.         } else {
    11.             getLogger().warn("Could not generate webPath in Walk");
    12.         }
    13.     }
    14.  
    15. }
    An Extra: TraversalOptions

    All types of paths can also take an argument of Traversal Options when calling .step()

    Traversal options as of 12/25/2017 are:
    MANAGE_DISTANCE_BETWEEN_STEPS
    MANAGE_RUN (turning it on if it runs out and re-generates)
    MANAGE_STAMINA_ENHANCERS (stamina potions, terrorbird scrolls, etc)

    All types of paths default to managing these things if not specified by the author. They can all be disabled using .step(false), or individually enabled using .step(TraversalOptions you want to enable).

    Code (Text):
    1. public class Walk extends LeafTask {
    2.  
    3.     @Override
    4.     public void execute() {
    5.         WebPath webPath = Traversal.getDefaultWeb().getPathBuilder().buildTo(new Coordinate(3013, 5608, 0));
    6.         if(webPath != null){
    7.             webPath.step(Path.TraversalOption.MANAGE_DISTANCE_BETWEEN_STEPS, Path.TraversalOption.MANAGE_RUN);
    8.         } else {
    9.             getLogger().warn("Could not generate webPath in Walk");
    10.         }
    11.     }
    12.  
    13. }
     
    #1 Snufalufugus, Dec 25, 2017
    Last edited: Dec 25, 2017
    TYG123, proxi, awesome123man and 3 others like this.
  2. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    Pretty solid guide covering the basic usages and situations for each type of path.
     
    awesome123man likes this.
  3. Jux7apose

    Joined:
    Mar 28, 2017
    Messages:
    286
    Likes Received:
    58
    Does a viewport handle obstacles such as doors?

    Also, for the paths you mentioned that cannot handle doors, would it be possible to modify the path ourselves, and add a BasicObjectVertex for the door? Or do you think it'd be better if we use #interact instead of messing with the list of vertexs.

    EDIT: Also, do we have to take care of the camera for all paths, or does RM handle it for us? ie viewport path -> if (!path.getNextStep.isVisible) -> turnCamera
     
  4. Snufalufugus

    Joined:
    Aug 23, 2015
    Messages:
    1,961
    Likes Received:
    757
    • Viewport is a converted Predefined, bres, or region path, and these paths do not handle obstacles. By extension, viewport does not.
    • BasicObjectVertex is part of making a web, not part of traditional pathing. Walk near the door, interact with it normally, and then path again.
    • Camera is irrelevant for Coordinate paths (Bres, region, predefined) since they use the minimap. Viewport has an example in the guide.
     
  5. Jux7apose

    Joined:
    Mar 28, 2017
    Messages:
    286
    Likes Received:
    58
    Okay I see, my bad didn't read the code example for Viewport :x But that you for clarifying for the rest
     
    Snufalufugus likes this.
  6. Sanfax

    Joined:
    Jan 17, 2018
    Messages:
    10
    Likes Received:
    2
    Does a web path automatically open doors/gates or is there code needed to specify what to open/when? If it does need to be specified would you mind giving me an example? I'm attempting to write my first bot so this information would be much appreciated :)
     
  7. Snufalufugus

    Joined:
    Aug 23, 2015
    Messages:
    1,961
    Likes Received:
    757
    Web paths can traverse obstacles all on their own.
     
  8. MaskedMouse

    Joined:
    Feb 21, 2016
    Messages:
    60
    Likes Received:
    11
    Would you store a webpath into a variable and use that until it cannot step / is at the end of the destination? Or is it ok to generate a path every time the leaf task is called?
     
  9. Snufalufugus

    Joined:
    Aug 23, 2015
    Messages:
    1,961
    Likes Received:
    757
    You can do that if you or users are having trouble with the speed of the web pathing, but you may encounter scenarios where it will get stuck endlessly traversing an obstacle back and forth if you don't regenerate after the obstacle.
     

Share This Page

Loading...