I've been working on a program using the Java Robot
class to move my mouse to a random location bound between an area of pixels. As some of you know, the moveMouse
method works as moveMove(x,y)
where x is the horizontal pixel number and y is the vertical pixel number. I would then math a random number generator using math.random to have the program click on a random pixel in a rectangular section on my screen. this line would look like this (the numbers are arbitrary values)
robot.mouseMove(randomNum(350,400),randomNum(350,400)
Where it would pick between pixels 350-400 on the x direction. and 350-400 in the y direction. Although, the problem I am running into is that eventually after a few hundred-1000 iterations, the scattermap of clicks looks... not so random:
So I thought I would solve this problem by then adding 2 arrays that hold the pixel values for the corresponding x and y values that I want, and add weighted RNG by repeating pixel numbers so it would have a higher chance of going to those pixels. But I still end up with an unnatural looking scatter chart. Here is my code:
private static int[] items = new int[]
{/*insert x coord pixels*/ };
private static Random rand = new
Random();
public static int getRandArrayElement()
{
return
items[rand.nextInt(items.length)];
}
private static int[] items2 = new int[]
{/*insery y coord pixels*/};
private static Random rand2 = new
Random();
public static int
getRandArrayElement2(){
return
items2[rand2.nextInt(items2.length)];
}
robot.mouseMove(getRandArrayElement(),getRandArrayElement2());
robot.mousePress(button);
robot.delay(randomNum(11,32));
robot.mouseRelease(button);
robot.delay(randomNum(11,32));
This code still has the same constraint as the last, no matter what, my scatter plot still will resemble a rectangle of some kind. Is there any way I can make a list, where each value has a readable x AND y value, so I can hard code weighted RNG by omitting certain pixels so I can choose what shape the scatter plot will resemble? I'd like to make it look more like this:
More random looking click plot
So if anyone has any helpful info that they'd like to share, I'm all ears. cheers. :)