Checking in code from the weekend - finished the basic simulation but it looks like there's a bug, still debugging