Tutorial How, and why, to use the PlayerSense API

Discussion in 'Tutorials & Resources' started by SlashnHax, Feb 28, 2015.

  1. How, and why, to use the PlayerSense API

    What is PlayerSense? (Documentation link)
    PlayerSense is used to prevent accounts from having the same pattern, even when they are running the same bot. By giving each account a different behaviour when it comes to certain things (such as using hotkeys for interfaces, hotkeys for the actionbar, when to enable run and much, much more) we strive to combat against some of the pattern detecting code that Jagex uses to identify bots.​

    How does it work?
    PlayerSense holds all of it's information in a Map, using PlayerSense.put(key, value) to put information into the Map, and PlayerSense.get(key, value) to get information from it. There are two kinds of keys you can use, PlayerSense.Key (Documentation link) or String. When you get the value from PlayerSense, if it's using a PlayerSense.Key, it will get a value from the Generator. I recommend you use these predefined keys as often as possible.​

    How do I use it?
    Depending on the different keys there are different ways to use PlayerSense. Here I have a short snippet of how I've used PlayerSense to determine whether to use the hotkey (space) or click on the interface.
    Code (Text):
    1. public static boolean select(boolean click){
    2.     if(click || !PlayerSense.getAsBoolean(PlayerSense.Key.USE_MISC_HOTKEYS))
    3.         return getCraftButton().click();
    4.     else
    5.         return Keyboard.typeKey(KeyEvent.VK_SPACE);
    6. }

    Why should I use it?
    By using PlayerSense you're adding another layer of security to your script bot, reducing the chances of being detected by Jagex's bot-detection systems.
    When should I use it?
    Whenever it makes sense to, if you have the option of making the bot either use a hotkey or click on the interface, use PlayerSense.getAsBoolean(PlayerSense.Key.USE_MISC_HOTKEYS) to determine which method to use. If there are certain mannerisms you want to reproduce, such as how some people consistently select the first item in their inventory and some just pick a random one, generate a value and put it into PlayerSense, then use that value to choose which one to do. Much of the API already uses PlayerSense, such as ActionBar activating, Chat Dialog option selection, the Camera API, and RegionPath generation.​
    #1 SlashnHax, Feb 28, 2015
    Last edited: Mar 1, 2015
  2. Nice tutorial once again slashie ^^

    You should also mention that some RuneMate Api calls have this already implemented. Ex. the Camera.passivelyTurnTo();
  3. Thanks :D

    I've added some mentions of where the API already uses PlayerSense, thanks for the suggestion :)
    Thunderkill likes this.
  4. It's also used for RegionPath generation. In addition, it's more complicated than a map on the back end but for your explanation it was probably the simplest way to explain it (in reality it stores all values fed to it and creates a value based on that information). It's designed to give consistent values based on it's dataset, and since the dataset various for each individual player (and changes over time) it helps to break larger multi-account patterns.You should go into a bit more detail on how to add your own values to it because that's really powerful too.

    In addition, the following screenshots contain updated javadocs so that may be of use in understanding there function.
    #4 Cloud, Mar 1, 2015
    Last edited: Mar 1, 2015
  5. So if we were to put multiple values for the same String key into PlayerSense, it would store them all and randomly get one when using get instead of overwriting the old value?

    In this case would it be best to feed it randomized values if the key isn't present?
  6. Not quite, it's not a random selection of them. It's a value based on them. If you're feeding it data manually, don't feed it more than one value unless you're really confident in what you're doing.
  7. So don't feed it callables or anything like that either?
  8. @Cloud Are the returned values based on data collected from playing legit in the client?
  9. I think the predefined Keys have a Generator that generates the initial values if they're not already found
  10. Currently a select few of them are however moving forward many more will be.
    Nope, the only things you should feed are perhaps a unique value that you would use to determine when to turn the camera to focus on something and such.
  11. Later this week, I think I'm going to try to make a trainable script bot. Would you be interested in the results? I'm hoping to find a reliable way of correlating clicks and presses to objects, tiles and interfaces. I've noticed how different scripters write scripts bots differently because they play differently, hopefully this should help prevent jagex flagging players who are suddenly playing with a totally different style.
  12. That sounds very interesting, please tag me when you post :)
  13. Do you know how I could generate a new key for storing values? My IDE isn't giving me any suggestions on the use of PlayerSense, I enter PlayerSense. and all it suggests is .Key and nothing else, whatever I'm entering isn't appearing to be valid in my IDE.
  14. Try "PlayerSense.Key key = new PlayerSense.Key();" Though I think standard practice is to have the constructor private for enums.
  15. enums cannot have public constructors therefore that will not work
  16. Just use a String as the key, it accepts both a String or a PlayerSense.Key. PlayerSense.Keys are predefined values in an enum, I'm pretty sure you can't create your own.
  17. @Cloud
    Will this learn from the data I enter?
    I'm trying to add a preference between bankers and bank booths. If at first I simply generate random values for it (boolean) and put a bunch of them into it, at some point I would start only using the PlayerSense value, would the getAsBoolean return the most common one (true or false), or something completely different?

    Is this data remembered between script bot runs?

    Can you give an example of a good use of custom keys for this?
  18. It would return true/false in a similar manner to the distribution in which you fed them. It's remembered not only across script bot runs but across scripts bots, however in the current release it's lost between sessions.

Share This Page