As Michael already stated as a comment: use a seeded pseudo random number generator (PRNG) and reuse the same all over your implementation.
In Java, do something like this:
Random workingRandom = new Random(0L);
// Never use Math.random(), always use workingRandom.next*() instead
There are a couple of other things you might need to disable (especially in multi-threaded implementations) to have 100% reproducibility, some of which I discuss in my implementation's docs section 4.4.3.4. REPRODUCIBLE (such as replacing HashMap
by LinkedHashMap
when needed).