Here is a pure C implementation of a Mersenne Twister: https://github.com/ESultanik/mtwister?tab=readme-ov-file We should use this rather than rand and srand in the code.