Tutorial A guide to RuneMate's traversal system

Discussion in 'Tutorials & Resources' started by Savior, Jan 7, 2016.

  1. Since I recognized especially new bot authors struggle a little to find a good way to get into RuneMate's many pathing and traversing techniques, I've decided to finally write a basic introduction for all of them.

    First, you need to find out which pathing system fits your needs in order to make your bot function properly. This depends on the distance your bot has to travel, and whether or not it needs to open doors or walk past certain buildings and stuff like that.



    Option 1: WebPath
    WebPath requires a given web of vertices in order to build a path based on it. You can see the web as a big field of coordinates, which are linked to each other.

    Coordinate A is linked to coordinate B if B is reachable from A. Using this system the web's pathbuilder can calculate a path along those links to your desired location.

    The big advantage of it is that it can potentially go everywhere, as it supports obstacles like doors or shortcuts or even teleportations, assuming that your web supports those.

    You can use RuneMate's default web (accessible through Traversal.getDefaultWeb()), or you can build your own using a web builder from the bot store (or write your own web builder). The default web covers the most common areas of the RuneScape surface, but is, afaik, not supporting shortcuts etc. yet.

    To see if the default web manages to build a path to your desired location, you should test it yourself. If you want to use your own web, you need to load it from a file.


    Use this pathing system if you need to travel a larger distance and/or if obstacles are in your way.

    Code (Text):
    1. public class Walking extends Task {
    2.  
    3.     private final static Coordinate bankCoord = new Coordinate(x, y);
    4.     private Web web; // Custom web, gets loaded in constructor
    5.  
    6.     public Walking() {
    7.         try {
    8.             web = FileWeb.fromByteArray(Resources.getAsByteArray("path/to/webfile")); // load the web with the Resources class, make sure to address this resource in your manifest
    9.         } catch (Exception e) {
    10.             e.printStackTrace();
    11.             web = null;
    12.         }
    13.     }
    14.  
    15.     @Override
    16.     public void execute() {
    17.         //Use this if you use the default web:
    18.             final WebPath path = Traversal.getDefaultWeb().getPathBuilder().buildTo(bankCoord);
    19.        
    20.         //Or this if you use your own web
    21.             final WebPath path = null;
    22.             if (web != null) { // Make sure the web got loaded properly
    23.                 path = web.getPathBuilder().buildTo(bankCoord);
    24.             }
    25.        
    26.         if (path != null) { // IMPORTANT: if the path should be null, the pathbuilder could not manage to build a path with the given web, so always nullcheck!
    27.             path.step();
    28.         }
    29.     }
    30.  
    31.     @Override
    32.     public boolean validate() {
    33.         //validate
    34.     }
    35.  
    36. }

    Option 2: RegionPath
    RegionPath acts similiar to WebPath, it builds a path based on a web, though in this case, the web represents the currently loaded region. Notice that just like WebPath, the pathbuilder can't generate any path to a coordinate which is not part of the web, so make sure your destination is located in your loaded region and is reachable (no doors shut or obstacles you have to climb over).

    You may ask now, what is a region? A region is just a small area of the RuneScape world loaded into your RAM, once you enter another region, the game has to load the next region into the RAM, which causes the loading times during traversal you may know. RuneScape does this because it would be impossible to load the whole world at once.

    [​IMG]

    So you can use this method if you are positive that your destination is within the loaded region and you just travel a short distance.

    Code (Text):
    1. public class Walking extends Task {
    2.  
    3.     private final static Coordinate bankCoord = new Coordinate(x, y);
    4.  
    5.     @Override
    6.     public void execute() {
    7.         final RegionPath path = RegionPath.buildTo(bankCoord);
    8.  
    9.         if (path != null) { // IMPORTANT: if the path should be null, the pathbuilder could not manage to build a path with the given region, so always nullcheck!
    10.             path.step();
    11.         }
    12.     }
    13.  
    14.     @Override
    15.     public boolean validate() {
    16.         //validate
    17.     }
    18.  
    19. }

    Option 3: BresenhamPath
    If you google up "Bresenham Path" you can guess very well what this does. It just draws a straight line from Coordinate A to Coordinate B, not giving a fuck whether it is even reachable or not. So pay attention if you use this method, even because most players won't travel in one accurate line, increasing the chance of a ban.

    The advantage of this method is that it is more lightweight than building a path over and over, calculating multiple things etc.

    Use this method only if the path you want to take is very short and hast little to no obstacles in between.

    Code (Text):
    1. public class Walking extends Task {
    2.  
    3.     private final static Coordinate bankCoord = new Coordinate(x, y);
    4.  
    5.     @Override
    6.     public void execute() {
    7.         final BresenhamPath path = BresenhamPath.buildTo(bankCoord);
    8.  
    9.         if (path != null) { // Although BresenhamPath technically always builds a path, it is recommended to nullcheck rather than having the bot crash
    10.             path.step();
    11.         }
    12.     }
    13.  
    14.     @Override
    15.     public boolean validate() {
    16.         //validate
    17.     }
    18.  
    19. }

    Option 4: PredefinedPath
    As the name says, PredefinedPath takes predefined coordinates in order to traverse along them. This method can be good if you need to take a very special route across the landscape in order to avoid getting attacked by monsters for example.

    There are tools on the internet (which are a bit old though) which can help you generate an array of coordinates. Alternatively you can find out the coordinates the path should be ingame using the devkit.

    Code (Text):
    1. public class Walking extends Task {
    2.  
    3.     private final static Coordinate[] pathCoords = {new Coordinate(x, y), new Coordinate(x, y), new Coordinate(x, y)};
    4.  
    5.     @Override
    6.     public void execute() {
    7.         PredefinedPath.create(pathCoords).step();
    8.     }
    9.  
    10.     @Override
    11.     public boolean validate() {
    12.         //validate
    13.     }
    14.  
    15. }


    Additional: ViewportPath
    ViewportPath takes a given path in order to traverse it, with the difference that all other traversing methods use the minimap to walk, while ViewportPath uses the coordinates in your viewport (aka 3d world) to walk.

    This is pretty useful for accurate walking and a good way to make your bot act more humanlike.

    Note that it is not required to use BresenhamPath, ViewportPath.convert(path)takes any kind of path.
    Code (Text):
    1. public class Walking extends Task {
    2.  
    3.     private final static Coordinate bankCoord = new Coordinate(x, y);
    4.  
    5.     @Override
    6.     public void execute() {
    7.         final BresenhamPath path = BresenhamPath.buildTo(bankCoord);
    8.  
    9.         if (path != null) { // Although BresenhamPath technically always builds a path, it is recommended to nullcheck rather than having the bot crash
    10.             if (bankCoord.distanceTo(Players.getLocal()) >= 8 || !ViewportPath.convert(path).step()) {  // this will attempt to walk with the viewport if the distance to the destination is < 8
    11.                 path.step();                                                                            // if it cant walk with viewport (camera not correclty set for example), step() will return false,
    12.                                                                                                         // causing the bot to walk with the minimap
    13.             }
    14.         }
    15.     }
    16.  
    17.     @Override
    18.     public boolean validate() {
    19.         //validate
    20.     }
    21.  
    22. }



    You also can combine those methods to ensure a good traversal, for example, let the bot generate a path with RegionPath, and nullcheck it in order to see if it is valid. If it is, you can let it walk, if not, attempt to build a WebPath, or BresenhamPath as a last resort.
     
    creativeself, Serene, TheVTM and 6 others like this.
  2. I see this guide opening up many paths for new developers.
     
    Derk and Arbiter like this.
  3. Why are you doing this on my thread
     
  4. He's just saying that this thread could be a route to bot-writing success.
     
    Derk likes this.
  5. I feel as though this thread can point a developer in the right direction.
     
  6. staff please close this thread forever
     
    Furor likes this.
  7. That would represent a deeply sinister new direction for the RuneMate forum, intelligent and helpful discourse ought to always be encouraged in order to promote a wide range of potential destinations for emerging developers.
     
    LucasSousa likes this.
  8. Too late, I already used that first line.
     

Share This Page

Loading...