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.

Picking A Random Action

Featured Replies

Noob here still working on my first few scripts. Wondering the best way to choose a random action. 

 

for example, choosing between using a bank deposit box and the bank function. Right now i have it written as such: 

if(inventory.isFull() && random(100,200)%2 == 0 ){
       return State.DEPOSITBOX;
else
      return State.BANK;
}

is this a good practice? (using more actions and mods?)

 

I've seen some talk about using https://en.wikipedia.org/wiki/Random_seed .. if that's the way to do it would someone mind providing an example (using a timer?) I imagine you don't want your bot to uniformly distribute the "random" options over time..

 

Appreciate any input. 

  • Author

that code will aggressively switch between states and make you go back and forth between the deposit box state and the bank state

 

Sorry wasn't using my actual script. Just trying to get the general idea across.. using a mod to determine the action?

You don't have to worry about using a seed if you use:

import java.util.concurrent.ThreadLocalRandom;
ThreadLocalRandom.current().nextInt(min, max + 1);

And the way you set up the modulus it does give a 50% chance.

 

You can also try a % chance by doing something like if(random(0, 101) <= 75)) [psuedocode] for 75% (or 76% I forget if it's inclusive or not, xD) chance for example.

 

One thing to note if you do it this way is you only want to generate the random number once. Otherwise you have a potentially different chance for each task.

Edited by Trees

You don't have to worry about using a seed if you use:

import java.util.concurrent.ThreadLocalRandom;
ThreadLocalRandom.current().nextInt(min, max + 1);

And the way you set up the modulus it does give a 50% chance.

 

You can also try a % chance by doing something like if(random(0, 101) <= 75)) [psuedocode] for 75% (or 76% I forget if it's inclusive or not, xD) chance for example.

 

One thing to note if you do it this way is you only want to generate the random number once. Otherwise you have a potentially different chance for each task.

 

Why would you worry about using a seed for this in the first place boge.png

 

Can agree that random(100, 200) % 2 seems a bit silly tho; might aswell go for random(2) == 0

 

Edited by FrostBug

Why would you worry about using a seed for this in the first place boge.png

 

Can agree that random(100, 200) % 2 seems a bit silly tho; might aswell go for random(2) == 0

 

 

Indeed, why would you use a mod for that.

Looks like you're trying to use a 50/50 chance, don't over complicate it with useless calculations. Also check your brackets, looks like you're giving it an entirely different meaning. As far as making something "random", you can always figure out the bounds by gathering enough input. 

 

Still, better of an attempt than simply moving your mouse/camera around randomly. 

Indeed, why would you use a mod for that.

 

In terms of randomness, it makes the distribution larger. Of course it'd be more useful if you were using a value other than 2, but still.

 

And as far as a seed goes it's probably not needed for this anyways.

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.