Moved some code into functions to make  them more modular. Should lead to being able to interact with the sim via the page, rather than the code.
Add game object to control features of the sim.