In OCaml 4.14.1 I get this:
# Random.init 2;;
- : unit = ()
# Random.int 100 ;;
- : int = 69
But in OCaml 5.0.0 I get this:
# Random.init 2;;
- : unit = ()
# Random.int 100 ;;
- : int = 89
This is obviously not great. Is there any way to get the same random numbers across all versions of OCaml?
Edit: I just noticed that they do actually call this out in the docs (though sadly not right at the top in huge bold red letters like it should be).
Before 5.0.0 used a different algorithm (affects all the following functions)
A compatibility library, stdlib-random
, has been published that includes all the PRNG implementations from 3.07 to 5.0, so that you can pick and choose which you want. It will work on every version of OCaml since 4.08.