Implement state seeds, closes issue #798

As per the discussion in issue #798, this is an improvement to the way the replay system works that accounts for the differences between recording a single state (which requires the seed that generated that state) and recording the whole game (which requires the global seed).

Please do not merge yet; I would like to do some tests, but I wanted to put it up for review so others could see it.