Search the Community
Showing results for tags 'random'.
-
Hello, I am trying to add gaussian randoms to my script. I started using: int dynamicReturn = (int) ((rand.nextGaussian()*deviation)+mean); but the issue with that is the Gaussian random will not always stay within the deviation variable. To fix this I did: int dynamicReturn; do { dynamicReturn = (int) ((rand.nextGaussian()*deviation)+mean); }while(dynamicReturn < (mean-deviation) || dynamicReturn > (mean+deviation)); which works but because that would make it skip generated numbers outside of the range, I'm wondering if that would throw off my gaussian distribution? If so, what would be a better approach to use that would still lock all the values within my deviation?
-
How much would an account like this be worth if I got the smithing level to 85? It has no bans. It has cooking gloves as well
-
This is a class containing the 'what would have been' gRandom's replacement that was mostly created by @Alek following my bug report. I figured I'd share it as a snippet so it's easier to find in case people need it, since Alek just announced a new release in which it is deprecated because of it not functioning correctly and too many dependencies on it to fix. Code: Usage:
-
This post is mostly intented for scripters I suppose. So anways I just started scripting again after a long break, and thought of the following while making my script: If Jagex can monitor mouse movements, what would be the easiest way to detect bots? For instance take magic; high alching. Thinking about making a script like that I'm sure I would have used sleep(random(min, max)) between mouse clicks until now. Let's take sleep(random(500, 700)) and see what Jagex would see if they're monitoring the time between the clicks for let's say 10k alchs, by using this snippet: int[] numbers = new int[750]; for (int i = 0; i < 10000; i++) { numbers[MethodProvider.random(500, 700) - 1]++; } int i = 0; for (int n : numbers) { if (i++ < 450) { continue; } System.out.println("" + i + ", " + n + ""); } Entering the output in a scatter plot produces the following data visualisation: I'm sure that you would realize that no human could ever hit so perfectly random between 500 and 700, but never go below or past those respectively. So I started digging into this and found out there is a common method which is used for this sort of thing, called standard deviation. It turns out that OSBot already has this in their API at MethodProvider#gRandom, so you can already use this. I had already made my own snippet for it though: public static void main(String[] args) { int[] numbers = new int[750]; for (int i = 0; i < 10000; i++) { numbers[rand(500, 700) - 1]++; } int i = 0; for (int n : numbers) { if (i++ < 450) { continue; } System.out.println("" + i + ", " + n + ""); } } public static int rand(int min, int max) { return rand(min, max, (max - min) / 8); } public static int rand(int min, int max, int deviation) { Random r = new Random(); int avg = min + ((max - min) / 2); int rand; do { double val = r.nextGaussian() * deviation + avg; rand = (int) Math.round(val); } while (rand < min || rand > max); return rand; } Now, running the output data through the same scatter plot produces the following image: Which doesn't drop off to zero without ever hitting one past it. It is important to note that when using this, you might want to make your intervals wider...it is kinda unlikely that you'd be as accurate as the above plot. For example 300, 900 produces this, which is what I think would be a lot more human like: Anyways, you do not always need to use this but I strongly recommend it for scripts that use repetitive clicking and such, because it seems very easy to detect botters from Jagex's side if you use regular sleeps in some cases. Thought I'd share since I had never seen sleep used with such a random distribution before and it may prevent some bans Goodluck & hf :p
-
So my wonderful CS teacher has decided he's going to make our class revolve around ease for himself(instead of trying to make his students better at programming).... BUT ANYWAYS....He gives us little info on how the program is to be written, and if we don't write it EXACTLY like he would, we don't get credit. I think I have written a working program(that does what he asks), but the hidden test cases keep failing so I could really use some help. INSTRUCTIONS Write a function that takes an integer “count” and a double “probability" Generate “count” random numbers between 0.0 and 1.0 Print the number of generated random numbers that is less than “probability” Call this new function from main() MY CODE #include <iostream> #include <cstdlib> using namespace std; int newFunction(int count, double probability) { double random; int total = 0; for(int i = 0; i < count; i++) { random = (double) rand() / RAND_MAX; if (random < probability) { cout << random << endl; total++; } } return total; } int main() { cout << "Enter integer for seed: " << endl; int seed; cin >> seed; srand(seed); int c; double p; cout << "Enter the count of numbers to be generated: " << endl; cin >> c; cout << "Enter the probability: " << endl; cin >> p; cout << "Number of generated random numbers less than probability entered is " << newFunction(c, p) << endl; return 0; } PROGRAM INPUT 1 //seed 3 //number of random numbers (count) 0.5 //value for probability MY OUTPUT Enter integer for seed: 1 Enter the count of numbers to be generated: 3 Enter the probability: 0.5 0.394383 Number of generated random numbers less than probability entered is 1 HIS OUTPUT Enter integer for seed: 1 Enter the count of numbers to be generated: 3 Enter the probability: 0.5 0.159812 0.216901 Number of generated random numbers less than probability entered is 2 He gave us this as a skeleton for the code: #include <iostream> #include <cstdlib> using namespace std; int newFunction(int count, double probability); int main() { cout << "Enter integer for seed: " << endl; int seed; cin >> seed; srand(seed); int c; double p; cout << "Enter the count of numbers to be generated: "; cin >> c; cout << "Enter the probability: "; cin >> p; cout << "Number of generated random numbers less than probability entered is " << newFunction(c, p) << endl; return 0; } I don't have a clue as to what I'm doing wrong. He uses an online textbook where he inserts his "key code" then when we run our code it compares the outputs and determines if they are the same. We are using the same compiler, and I am almost positive we are to use rand(). Please, I really need help...Thank you