The forums have permanently moved to
forum.kirupa.com. This forum will be kept around in read-only mode for
archival purposes. To learn how to continue using your existing account on the new forums,
check out
this thread.

[JAVA] random number generator is repeating?

How often will Java's random number generator repeat its sequence of random numbers? Here, I'm shooting 5,000 random photons out of a light source for indirect lighting using only one Random object. It looks like there are only a few dozen distinct places where the photons have landed.

If you change gen.nextInt() to gen.nextInt(3), or something, then you will probably notice that you get many more repeating subsets, since you are only dealing with a few integers as opposed to INT_MAX_VALUE, or whatever it's called in Java.

Ok. So I think there is nothing wrong with the random number generation now. It was just that I was shooting the photons too randomly. Here I've hardcoded the Y direction of the photon to be -0.5 and chose random values for X and Y. Now most of the photons are directed toward my scene rather than going off in space.