Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Random Pathwalking and more help?

Featured Replies

Hello all,

I'd like to know if anybody could help me to make something like a random pathwalking system.

I was thinking about my script to go from point A to B with random paths, so it won't walk the same path for hours straight. How would I do this?

Also, I was thinking about making a failsafe in the walking, if the player isn't at point A or B, the walking should continue and it should NOT go into another state like WAIT.

Every help is appreciated!

-Ragfr00b

Hello all,

I'd like to know if anybody could help me to make something like a random pathwalking system.

I was thinking about my script to go from point A to B with random paths, so it won't walk the same path for hours straight. How would I do this?

Also, I was thinking about making a failsafe in the walking, if the player isn't at point A or B, the walking should continue and it should NOT go into another state like WAIT.

Every help is appreciated!

-Ragfr00b

You can easily make it so you randomise each position when you plan on walking the preset path. Each time you call that position just randomise the x and y by 1 or more depending on the surrounding space you plan on walking through.

If you want to take a completely different route either make a fair amount of pre set paths in an array, select a random number and walk that path in the array.

The first one is the easiest one to do as you don't have to collect loads of data.

The final way would be to retrieve the flags in the loaded region and use A* to calculate a path using the flags and checking if they are walkable. This should only be done if you have a good knowledge of how A* algorithm works and how to plement it into java.

But you can load the flags 52 rules in every direction, so if you path is longer than this, use preset paths and randomise each position like I said above.

I hope this helped and if you have anymore question feel free to ask ^_^

  • Author

You can easily make it so you randomise each position when you plan on walking the preset path. Each time you call that position just randomise the x and y by 1 or more depending on the surrounding space you plan on walking through.

If you want to take a completely different route either make a fair amount of pre set paths in an array, select a random number and walk that path in the array.

The first one is the easiest one to do as you don't have to collect loads of data.

The final way would be to retrieve the flags in the loaded region and use A* to calculate a path using the flags and checking if they are walkable. This should only be done if you have a good knowledge of how A* algorithm works and how to plement it into java.

But you can load the flags 52 rules in every direction, so if you path is longer than this, use preset paths and randomise each position like I said above.

I hope this helped and if you have anymore question feel free to ask happy.png

 

Thinking about doing the first option, randomizing the x & y from 1 - 3 .

How would I implement this in my script?

 

I'll past the walking method and path connected to it in pastebin. http://pastebin.com/j7nupvms

Could you tell me what to change/add to make this randomizing method?

Thinking about doing the first option, randomizing the x & y from 1 - 3 .

How would I implement this in my script?

 

I'll past the walking method and path connected to it in pastebin. http://pastebin.com/j7nupvms

Could you tell me what to change/add to make this randomizing method?

 

Ah i see the issue you are having. you can only do this if you make your own method.

 

how i would make my own method? 

 

i would make a method which is called getNextPositionOnPath(Path path) 

 

this should return the next position in the array which is walkable.

 

i would make a for loop which goes from path.length-1 to 0 to find which finds which position is closest to you and return it.

 

once you get the getNextPositionOnPath(Path path) assign it to a variable called nextPosition, make a new variable called newPosition= new Position(nextPosition.getX() + ***RANDOM NUMBER***, nextPosition.getY() + ***DIFFERENT RANDOM NUMBER***, nextPosition.getZ())

 

then make another method called walkPath which walks to the next position, once the distance < random number, getnextPosition and walk to it etc.

Ah i see the issue you are having. you can only do this if you make your own method.

 

how i would make my own method? 

 

i would make a method which is called getNextPositionOnPath(Path path) 

 

this should return the next position in the array which is walkable.

 

i would make a for loop which goes from path.length-1 to 0 to find which finds which position is closest to you and return it.

 

once you get the getNextPositionOnPath(Path path) assign it to a variable called nextPosition, make a new variable called newPosition= new Position(nextPosition.getX() + ***RANDOM NUMBER***, nextPosition.getY() + ***DIFFERENT RANDOM NUMBER***, nextPosition.getZ())

 

then make another method called walkPath which walks to the next position, once the distance < random number, getnextPosition and walk to it etc.

 

Some ugly pseudo-code, I wrote this in the reply box off top so I can't guarantee it'll work but it should give you some sort of idea on how to do what he suggested. Basically what the method does is take an array of positions, find the one closest to you and then reconstructs a randomized new path and returns it as a new array of positions. It does not modify the given array, and the returned array holds no references to the given one... because that obviously wouldn't work out too well.

public Position[] getRandomizedPath(Position[] path) {

    // local fields
    Position player = myPlayer().getPosition();
    int index = 0;
    int dist = Integer.MAX_VALUE;

    // get index closest to player
    for(int i = 0; i < path.length; i++) {
        int amount = path[i].distance(player);
        if(amount < dist) {
            dist = amount;
            index = i;
        }
    }

    // filter positions and randomize them
    List<Position> list = new LinkedList<>();
    for(int i = 0; i < path.length; i++) {
        if(i >= index) {
            list.add(new Position(path[i].getX() + MethodProvider.random(5), path[i].getY() + MethodProvider.random(5));
        }
    }

    // return filtered and randomized positions
    return list.toArray(new Position[list.size()]);
}
private static final Position[] PATH = { ... }

public void ... () {
    ...

    localWalker.walk(getRandomizedPath(PATH));    

    ...
}

Edited by lare96

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.