Edit: This issue has been resolved. If you want to help solve another problem, go to Java Random Numbers in a three-dimensional array .
I make a multiplication game, so I select 2 numbers from 0 to 12 inclusive. If I do this:
int num1 = (int)(Math.random() * 13); int num2 = (int)(Math.random() * 13);
squares (0x0,1x1,2x2, etc.) are selected halfway (because 1x2 is the same as 2x1). How can I make all combinations selected on the same frequency? There are 91 possible combinations (n ββ(n + 1) / 2). If that helps, here is a 13 by 13 triangular array:
{{0}, {0,0}, {0,0,0}, {0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0}};
I tried to choose the first number and give the second number a 50% chance of becoming the first. This did not work. I tried to give the second number 1/91 a chance to become the first. This led to the fact that smaller numbers were chosen much more times (about 7/91 of the time, this is a smooth, curved increase). I was thinking about having one random number: int roll = random.next(91) , and then breaking it into 2 entries (for example, the coordinate (x, y)), but I could not figure out how to separate it.