|
@@ -3,6 +3,7 @@ import argparse
|
|
|
import sys
|
|
|
import random
|
|
|
import numpy
|
|
|
+import hashlib
|
|
|
|
|
|
from ID2TLib.Controller import Controller
|
|
|
|
|
@@ -92,9 +93,10 @@ class CLI(object):
|
|
|
def seed_rng(self, seed):
|
|
|
try: # try to convert the seed to int
|
|
|
seed = int(seed)
|
|
|
- except:
|
|
|
- seed = hash(seed) # otherwise use the strings hash
|
|
|
-
|
|
|
+ except: # otherwise use the strings hash
|
|
|
+ hashed_seed = hashlib.sha1(seed.encode()).digest()
|
|
|
+ seed = int.from_bytes(hashed_seed, byteorder="little") & 0xffffffff # convert hash to 32-bit integer
|
|
|
+
|
|
|
random.seed(seed)
|
|
|
numpy.random.seed(seed)
|
|
|
|