Created
August 27, 2014 00:18
-
-
Save woolsweater/4050f463010da9d57e90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import Random | |
class IndependentRepeatableRandom(object): | |
def __init__(self): | |
self.randgen = Random() | |
self.origstate = self.randgen.getstate() | |
def random(self, val): | |
self.randgen.jumpahead(int(val)) | |
retval = self.randgen.random() | |
self.randgen.setstate(self.origstate) | |
return retval |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment