lundi 22 février 2016

Randomly choosing a position from a matrix based on the value in that position

I have an XxY matrix (so it's 2D) filled with values based on the this formula with f being 200 for now:

randomGenerator((f*10)+(f/2))+1

RandomGenerator is a random number generator from the Java.util.Random class

I want to randomly pick a position from the matrix like [2;6] and show that output to the user but I want the randomness to depend on the value of the position. If the value is higher, so is the chance it gets picked to show. Now it just shows a random position.

How can I achieve this?




Aucun commentaire:

Enregistrer un commentaire