예제 #1
0
 def test_uninit(self):
     testData = [42, 4190403025, 1303704821] + [random.getrandbits(32) for _ in range(10)]
     for seed in testData:
         # extract seed from initial state
         self.assertEqual(mt19937.uninit(mt19937.init(seed)), seed)
         # perform twist, then untwist and then extract seed
         self.assertEqual(mt19937.uninit(mt19937.untwist(mt19937.twist(mt19937.init(seed)))), seed)
         # if state is not initial None is returned
         self.assertIsNone(mt19937.uninit(mt19937.twist(mt19937.init(seed))))
예제 #2
0
 def test_uninit(self):
     testData = [42, 4190403025, 1303704821
                 ] + [random.getrandbits(32) for _ in range(10)]
     for seed in testData:
         # extract seed from initial state
         self.assertEqual(mt19937.uninit(mt19937.init(seed)), seed)
         # perform twist, then untwist and then extract seed
         self.assertEqual(
             mt19937.uninit(
                 mt19937.untwist(mt19937.twist(mt19937.init(seed)))), seed)
         # if state is not initial None is returned
         self.assertIsNone(mt19937.uninit(mt19937.twist(
             mt19937.init(seed))))
예제 #3
0
 def findSeed(self, pg):
     rn = [0] * 624
     tm = [0] * 624
     for i in range(624):
         rn[i] = pg.getNumber()
         tm[i] = mt19937.unextract_number(rn[i], i)
     mt = mt19937.untwist(tm)
     seed = mt19937.uninit(mt)
     return seed
예제 #4
0
 def findSeed(self, pg):
     rn = [0] * 624
     tm = [0] * 624
     for i in range(624):
         rn[i] = pg.getNumber()
         tm[i] = mt19937.unextract_number(rn[i], i)
     mt = mt19937.untwist(tm)
     seed = mt19937.uninit(mt)
     return seed