Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Tutorial What Varps and Varbits are, and how to work with them

Joined
Aug 23, 2015
Messages
1,961
Why are Varps and Varbits important at RM:
Varps and Varbits hold tons of information that will be necessary for nearly any advanced bot you would want to make. Depending on the gamemode you're coding for, they could hold information about slayer tasks, quest progression, farming patch status, whether or not a potion effect is active, and many, many more things.

Tools Used in this Tutorial:
Open Varp Explorer
Open Varbit Explorer

Numerical systems:
  • Decimal: The numerical system you're used to. It is sometimes referred to as base-10.
  • Hexadecimal: Another numeral system where numerical values are represented using 0-9 and A-F.
  • Binary: The binary numeral system is a system used to represent conventional (base 10) numerical values using only 1s and 0s. In the real world, this translates to discrete voltage levels, typically 0V and 5V, which represent an off (0) or on (1) state. This is the concept that modern electronics operate on at a transistor level.
Bit: The basic unit of information for computers: a single 1 or 0.
Ex) 1

Nibble: A cluster of four bits.
Ex) 1 0 1 1

Byte: A cluster of eight bits, or two nibbles. This is THE unit of storage everyone is familiar with (A 500GB or Giga-Byte Hard Drive, for example).
Ex) 1 0 1 0 0 1 1 1

Word: A cluster of thirty-two bits, four bytes, or eight nibbles.
Ex) 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1

Bitwise operations: Much like you can use AND/OR statements in the condition of an IF statement, you can use AND/OR statements to manipulate individual bits of a binary number. You can also use XOR, but you don't need to know about that for this application. Bitwise operations compare the bits in the same position, perform the designated action on those bits, and produce the appropriate result.

For example:
Bitwise AND
...1 1 0 0
+ 1 0 1 0
= 1 0 0 0

Bitwise OR
...1 1 0 0
+ 1 0 1 0
= 1 1 1 0

Bit Masking: Using bitwise operations to get rid of unnecessary information.
For example, if we only care about the last three bits of a byte, we use a Bitwise AND:
...1 0 1 1 0 0 1 0 <-- We want the last three bits
+ 0 0 0 0 0 1 1 1 <-- Mask
= 0 0 0 0 0 0 1 0 <-- Masked information

For more information, check out the Wikipedia pages for each numerical system. What I provided is probably more than you'll need for Runemate.

Understanding Varps:
As stated in the Runemate Jdocs:
"local player variables" - Varps are known to contain data related to questing, farming, and other local player data.

My explanation: A Varp is a cluser of 32 bits (a word) used to represent various information about your player. A full Varp typically holds much more information than you need, and in order to utilize it you need to figure out what the Varp value means, and where in the 32 bits the information you need is kept. When using Slashnhax's Varp Explorer, you may notice that the displayed Varps are only displayed as 31 bits if you're particularly observant. This is because the 32nd bit is always a 0 to signify that the Varp is positive, so there is no need to display that information.

I have a suspicion they are a full word in length, but Slashnhax's Open Varp Explorer shows them at 31 bits long so I will assume that is correct.

Example of Varps: Rune pouches
76htvD9.png


This is a picture of the output log of Open Varp Explorer as I did the following actions:
  1. Fill a small rune pouch
  2. Empty a small rune pouch
  3. Fill a medium rune pouch
  4. Empty a medium rune pouch
  5. Fill a small rune pouch
  6. Fill a medium rune pouch
I have labelled each action in the image to make it easier to understand, as it can be quite overwhelming at first.

Understanding the Open Varp Explorer Interface:
  • Time: The time at which the change occured
  • Index: The location of the Varp that is changing
  • Binary new: The updated Varp value, after the change occured
  • Binary old: The previous Varp value, before the change occured
  • Decimal new/old: The binary value of the Varp converted to Base 10 (decimal)
  • Hex new/old: The binary value of the Varp converted to Hexadecimal
Understanding the data:
The first step is figuring out which Varp you will be using. In some cases, only one Varp will change, and that makes things easy. In this case, two Varps changed: Index 486 and Index 720. To figure out which Varp you want to use, look for patterns relating to the information you want. In our case, it is crucial to know that a small pouch can hold 0-3 essence, and a medium pouch can hold 0-6 essence.

Let's take a look at the first Varp change: Index 486 at 17:55:01. As we fill the pouch, our decimal value equivalent increases by three. That's an indication that this may be the Varp we want - the pouch has 3 more essence in it, and the decimal equivalent of our Varp increased by three.

As we continue to look at Varp 486, we can identify the pattern: the decimal value of the varp is changing by the number of essence we have stored in pouches. We empty the small pouch and it decreases by three. We fill the medium pouch, and it increases by 6. We empty the medium pouch, and it decreases by 6. We fill the small pouch -> increase of three -> fill medium pouch -> increase of six = Total increase of 9. We have 9 stored essence. This is the Varp we want.

Now that we have identified the Varp and it's patterns, we can determine where the data we want is stored, and manipulate the Varp to obtain the data we want. Typically, this manipulation involves taking the bits of the Varp and masking out the useless information. I won't be showing an example of this since someone who is doing something that requires this won't be needing a tutorial to show them how.

As you probably now realize, using a Varp to get the data you want can be very tricky and time consuming. Luckily for us, we have Varbits to use instead!



Understanding Varbits:
As stated in the Runemate Jdocs:

My explanation: A Varbit is like a heavily condensed version of a Varp. It contains information about your player, but in an easily accessible and understandable format. Think of it as a piece of a Varp that has already been bit-wise manipulated to save you time, effort, and frustration. It's better to view it as a piece of a Varp instead of the entire thing since Varps typically hold the data of multiple Varbits in them. A full Varp is a word in length - plenty of room for data storage.

Example of Varbits: Rune pouches
BeceQgl.png


This is a picture of the output log of Open Varbit Explorer as I did the following actions:
  1. Fill a small rune pouch
  2. Empty a small rune pouch
  3. Fill a medium rune pouch
  4. Empty a medium rune pouch
  5. Fill a small rune pouch
  6. Fill a medium rune pouch
I have labelled each action in the image to make it easier to understand, as it can be quite overwhelming at first.

Understanding the Open Varbit Explorer Interface:
  • Time: The time at which the change occured
  • Index: The location of the Varbit that is changing
  • Binary new: The updated Varbit value, after the change occured
  • Binary old: The previous Varbit value, before the change occured
  • Decimal new/old: The binary value of the Varbit converted to Base 10 (decimal)
  • Hex new/old: The binary value of the Varbit converted to Hexadecimal
Understanding the data:
The first step is figuring out which Varbit you will be using. In some cases, only one Varbit will change, and that makes things easy. In this case, four varbits changed: Indexes 603, 2088, 604, 2089. To figure out which Varbit you want to use, look for patterns relating to the information you want.

Like before, a pattern that jumps out at us is the decimal equivalent changing by the number of rune essence we are adding or removing. This is shown to us in Varbits 603 and 604. When we fill or empty the small pouch, varbit 603 changes by +/- decimal 3. When we fill or empty the medium pouch, varbit 604 changes by +/- decimal 6.

One change you should notice is that when we fill or empty one pouch, the varbit for the other does not change. This is a HUGE benefit of using varbits instead of varps. While the varps may include all of the data you need in one index location, you have to figure out how the information is all merged together into those 31 bits of data.

Coding with Varbits:
Now that we have found the varbit we will be using, and have found how it changes with the information we want, we can write the code to utilize what we have found.

I'll show code that can be used to determine the contents of a small runecrafting pouch:
Code:
    private boolean smallPouchFull() {
        Varbit varbit = Varbits.load(603);
        if(varbit == null) {
            System.out.println("Varbit smallpouch was null");
            return false;
        } else {
            return varbit.getValue() > 0;
        }
    }

Stop for a moment, and think about what this code is doing, why each part is important, and what could be improved.

Code:
    public boolean smallPouchFull() { //creates a method to call in the class that will return a boolean
        Varbit varbit = Varbits.load(603); //creates a variable named "varbit" of the "Varbit" type, and assigns the varbit in index 603 to it
        if(varbit == null) { //checks if the data we loaded into our varbit variable exists
            System.out.println("Varbit smallpouch was null"); //if it doesn't let us know and return false
            return false;
        } else { //if the data does exist
            return varbit.getValue() > 0; //tell us if the value of the varbit is > 0 (contained ess is > 0)
        }
    }

As for possible improvements, I'll let you be creative and think of those on your own.


Go figure out what the Varp and Varbits that I skipped over during this tutorial represent ;)
 
Last edited:
s̶c̶r̶i̶p̶t̶ bot*
Joined
Aug 23, 2015
Messages
2,223
Damn Paul

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.
 
Go check out new bots and give helpful feedback.
Joined
Jan 31, 2016
Messages
5,413
Why are Varps and Varbits important at RM:
Varps and Varbits hold tons of information that will be necessary for nearly any advanced bot you would want to make. Depending on the gamemode you're coding for, they could hold information about slayer tasks, quest progression, farming patch status, whether or not a potion effect is active, and many, many more things.

Tools Used in this Tutorial:
Open Varp Explorer
Open Varbit Explorer

Numerical systems:
  • Decimal: The numerical system you're used to. It is sometimes referred to as base-10.
  • Hexadecimal: Another numeral system where numerical values are represented using 0-9 and A-F.
  • Binary: The binary numeral system is a system used to represent conventional (base 10) numerical values using only 1s and 0s. In the real world, this translates to discrete voltage levels, typically 0V and 5V, which represent an off (0) or on (1) state. This is the concept that modern electronics operate on at a transistor level.
Bit: The basic unit of information for computers: a single 1 or 0.
Ex) 1

Nibble: A cluster of four bits.
Ex) 1 0 1 1

Byte: A cluster of eight bits, or two nibbles. This is THE unit of storage everyone is familiar with (A 500GB or Giga-Byte Hard Drive, for example).
Ex) 1 0 1 0 0 1 1 1

Word: A cluster of thirty-two bits, four bytes, or eight nibbles.
Ex) 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1

Bitwise operations: Much like you can use AND/OR statements in the condition of an IF statement, you can use AND/OR statements to manipulate individual bits of a binary number. You can also use XOR, but you don't need to know about that for this application. Bitwise operations compare the bits in the same position, perform the designated action on those bits, and produce the appropriate result.

For example:
Bitwise AND
...1 1 0 0
+ 1 0 1 0
= 1 0 0 0

Bitwise OR
...1 1 0 0
+ 1 0 1 0
= 1 1 1 0

Bit Masking: Using bitwise operations to get rid of unnecessary information.
For example, if we only care about the last three bits of a byte, we use a Bitwise AND:
...1 0 1 1 0 0 1 0 <-- We want the last three bits
+ 0 0 0 0 0 1 1 1 <-- Mask
= 0 0 0 0 0 0 1 0 <-- Masked information

For more information, check out the Wikipedia pages for each numerical system. What I provided is probably more than you'll need for Runemate.

Understanding Varps:
As stated in the Runemate Jdocs:
"local player variables" - Varps are known to contain data related to questing, farming, and other local player data.

My explanation: A Varp is a 31 character string of bits used to represent various information about your player. A full Varp typically holds much more information than you need, and in order to utilize it you need to figure out what the Varp value means, and where in the 31 bits the information you need is kept.

I have a suspicion they are a full word in length, but Slashnhax's Open Varp Explorer shows them at 31 bits long so I will assume that is correct.

Example of Varps: Rune pouches
76htvD9.png


This is a picture of the output log of Open Varp Explorer as I did the following actions:
  1. Fill a small rune pouch
  2. Empty a small rune pouch
  3. Fill a medium rune pouch
  4. Empty a medium rune pouch
  5. Fill a small rune pouch
  6. Fill a medium rune pouch
I have labelled each action in the image to make it easier to understand, as it can be quite overwhelming at first.

Understanding the Open Varp Explorer Interface:
  • Time: The time at which the change occured
  • Index: The location of the Varp that is changing
  • Binary new: The updated Varp value, after the change occured
  • Binary old: The previous Varp value, before the change occured
  • Decimal new/old: The binary value of the Varp converted to Base 10 (decimal)
  • Hex new/old: The binary value of the Varp converted to Hexadecimal
Understanding the data:
The first step is figuring out which Varp you will be using. In some cases, only one Varp will change, and that makes things easy. In this case, two Varps changed: Index 486 and Index 720. To figure out which Varp you want to use, look for patterns relating to the information you want. In our case, it is crucial to know that a small pouch can hold 0-3 essence, and a medium pouch can hold 0-6 essence.

Let's take a look at the first Varp change: Index 486 at 17:55:01. As we fill the pouch, our decimal value equivalent increases by three. That's an indication that this may be the Varp we want - the pouch has 3 more essence in it, and the decimal equivalent of our Varp increased by three.

As we continue to look at Varp 486, we can identify the pattern: the decimal value of the varp is changing by the number of essence we have stored in pouches. We empty the small pouch and it decreases by three. We fill the medium pouch, and it increases by 6. We empty the medium pouch, and it decreases by 6. We fill the small pouch -> increase of three -> fill medium pouch -> increase of six = Total increase of 9. We have 9 stored essence. This is the Varp we want.

Now that we have identified the Varp and it's patterns, we can determine where the data we want is stored, and manipulate the Varp to obtain the data we want. Typically, this manipulation involves taking the bits of the Varp and masking out the useless information. I won't be showing an example of this since someone who is doing something that requires this won't be needing a tutorial to show them how.

As you probably now realize, using a Varp to get the data you want can be very tricky and time consuming. Luckily for us, we have Varbits to use instead!



Understanding Varbits:
As stated in the Runemate Jdocs:

My explanation: A Varbit is like a heavily condensed version of a Varp. It contains information about your player, but in an easily accessible and understandable format. Think of it as a Varp that has already been bit-wise manipulated to save you time, effort, and frustration.

Example of Varbits: Rune pouches
BeceQgl.png


This is a picture of the output log of Open Varbit Explorer as I did the following actions:
  1. Fill a small rune pouch
  2. Empty a small rune pouch
  3. Fill a medium rune pouch
  4. Empty a medium rune pouch
  5. Fill a small rune pouch
  6. Fill a medium rune pouch
I have labelled each action in the image to make it easier to understand, as it can be quite overwhelming at first.

Understanding the Open Varbit Explorer Interface:
  • Time: The time at which the change occured
  • Index: The location of the Varbit that is changing
  • Binary new: The updated Varbit value, after the change occured
  • Binary old: The previous Varbit value, before the change occured
  • Decimal new/old: The binary value of the Varbit converted to Base 10 (decimal)
  • Hex new/old: The binary value of the Varbit converted to Hexadecimal
Understanding the data:
The first step is figuring out which Varbit you will be using. In some cases, only one Varbit will change, and that makes things easy. In this case, four varbits changed: Indexes 603, 2088, 604, 2089. To figure out which Varbit you want to use, look for patterns relating to the information you want.

Like before, a pattern that jumps out at us is the decimal equivalent changing by the number of rune essence we are adding or removing. This is shown to us in Varbits 603 and 604. When we fill or empty the small pouch, varbit 603 changes by +/- decimal 3. When we fill or empty the medium pouch, varbit 604 changes by +/- decimal 6.

One change you should notice is that when we fill or empty one pouch, the varbit for the other does not change. This is a HUGE benefit of using varbits instead of varps. While the varps may include all of the data you need in one index location, you have to figure out how the information is all merged together into those 31 bits of data.

Coding with Varbits:
Now that we have found the varbit we will be using, and have found how it changes with the information we want, we can write the code to utilize what we have found.

I'll show code that can be used to determine the contents of a small runecrafting pouch:
Code:
    private boolean smallPouchFull() {
        Varbit varbit = Varbits.load(603);
        if(varbit == null) {
            System.out.println("Varbit smallpouch was null");
            return false;
        } else {
            return varbit.getValue() > 0;
        }
    }

Stop for a moment, and think about what this code is doing, why each part is important, and what could be improved.

Code:
    public boolean smallPouchFull() { //creates a method to call in the class that will return a boolean
        Varbit varbit = Varbits.load(603); //creates a variable named "varbit" of the "Varbit" type, and assigns the varbit in index 603 to it
        if(varbit == null) { //checks if the data we loaded into our varbit variable exists
            System.out.println("Varbit smallpouch was null"); //if it doesn't let us know and return false
            return false;
        } else { //if the data does exist
            return varbit.getValue() > 0; //tell us if the value of the varbit is > 0 (contained ess is > 0)
        }
    }

As for possible improvements, I'll let you be creative and think of those on your own.


Go figure out what the Varp and Varbits that I skipped over during this tutorial represent ;)
Great Tutorial! Extremely helpful!
 
Joined
Aug 23, 2015
Messages
1,961
Slightly updated to clarify what a Varbit is along with more info about the length of Varps. Big thanks to Slashnhax for the information!
 
s̶c̶r̶i̶p̶t̶ bot*
Joined
Aug 23, 2015
Messages
2,223
I think you mean to say that 32 bits is a DWord as a Word is only 16 bits!
That's incorrect. A dword is the same bits as a word (32 or 64 bits in modern architectures). Assuming we're on a 32-bit system, the reason it's phrased 'dword' or 'double word' is because it carries an unsigned 32-bit value, with it's max integer value is double the max integer value of a signed 32-bit (a word).

Word (computer architecture) - Wikipedia
 
Joined
Aug 23, 2015
Messages
1,961
I think you mean to say that 32 bits is a DWord as a Word is only 16 bits!

Although according to wikipedia you're technically correct, the only reason that definition of a word is accurate is to maintain backwards comparability with very old systems. Newer ones typically wouldn't use a word size of 16 bits.
 
Java Warlord
Joined
Nov 17, 2014
Messages
4,906
Dang thought they'd might be storing them for some sort of quick caching system and maybe it would of kept track of GE prices for a easy wealth checker script.
Something like that may be implemented at some point for RuneMate. Although the bank would have to be opened at least once when running a bot before you could actually access the cached data.
 
Joined
Aug 23, 2015
Messages
1,961
Tools Used in this Tutorial:
Open Varp Explorer
Open Varbit Explorer


both of these are gone, is there a new tool available that can do all this?
im trying to find some data on the herb sack and gem bag for someone
Just use the dev toolkit
 
Forums won't let me edit OP, so hopefully this will be seen here.

Just to clarify, there is a distinction between varps and varbits. Varbits extract a portion of a varp via binary shifts when multiple values are packed into a single varp. Not all varps have multiple values packed into them though and when that's the case there is no varbit responsible for extracting the value and you must use the varp directly to get the value instead of a varbit. There's both a VarpListener and VarbitListener.
 
Top