Added better randomness and tidied up code.

You can now re-simulate a simulation exactly if you use the same seed.
Also, I tidied up the code to make it a bit more consistent, in particular removing trailing whitespace, making positioning of braces consistent, and restricting the scope and modifiability of fields.