本文整理匯總了Python中gym.utils.seeding.hash_seed方法的典型用法代碼示例。如果您正苦於以下問題:Python seeding.hash_seed方法的具體用法?Python seeding.hash_seed怎麽用?Python seeding.hash_seed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gym.utils.seeding
的用法示例。
在下文中一共展示了seeding.hash_seed方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: seed
# 需要導入模塊: from gym.utils import seeding [as 別名]
# 或者: from gym.utils.seeding import hash_seed [as 別名]
def seed(self, seed=None):
self.np_random, seed1 = seeding.np_random(seed)
# Derive a random seed. This gets passed as a uint, but gets
# checked as an int elsewhere, so we need to keep it below
# 2**31.
seed2 = seeding.hash_seed(seed1 + 1) % 2**31
# Empirically, we need to seed before loading the ROM.
self.ale.setInt(b'random_seed', seed2)
self.ale.loadROM(self.game_path)
return [seed1, seed2]
示例2: _seed
# 需要導入模塊: from gym.utils import seeding [as 別名]
# 或者: from gym.utils.seeding import hash_seed [as 別名]
def _seed(self, seed=None):
self.np_random, seed1 = seeding.np_random(seed)
# Derive a random seed.
seed2 = seeding.hash_seed(seed1 + 1) % 2**32
return [seed1, seed2]
示例3: seed
# 需要導入模塊: from gym.utils import seeding [as 別名]
# 或者: from gym.utils.seeding import hash_seed [as 別名]
def seed(self, n):
self.np_random, seed1 = seeding.np_random(n)
seed2 = seeding.hash_seed(seed1 + 1) % 2 ** 31
return [seed1, seed2]
示例4: seed
# 需要導入模塊: from gym.utils import seeding [as 別名]
# 或者: from gym.utils.seeding import hash_seed [as 別名]
def seed(self, seed=None):
self.curr_seed = seeding.hash_seed(seed, max_bytes=4)
self.rng, _ = seeding.np_random(seed=self.curr_seed)
return [self.curr_seed, self.rng]
示例5: seed
# 需要導入模塊: from gym.utils import seeding [as 別名]
# 或者: from gym.utils.seeding import hash_seed [as 別名]
def seed(self, seed=None):
self.np_random, seed1 = seeding.np_random(seed)
# Derive a random seed. This gets passed as a uint, but gets
# checked as an int elsewhere, so we need to keep it below
# 2**31.
seed2 = seeding.hash_seed(seed1 + 1) % 2**31
# Empirically, we need to seed before loading the ROM.
self.ale.setInt(b'random_seed', seed2)
self.ale.loadROM(self.game_path)
if self.game_mode is not None:
modes = self.ale.getAvailableModes()
assert self.game_mode in modes, (
"Invalid game mode \"{}\" for game {}.\nAvailable modes are: {}"
).format(self.game_mode, self.game, modes)
self.ale.setMode(self.game_mode)
if self.game_difficulty is not None:
difficulties = self.ale.getAvailableDifficulties()
assert self.game_difficulty in difficulties, (
"Invalid game difficulty \"{}\" for game {}.\nAvailable difficulties are: {}"
).format(self.game_difficulty, self.game, difficulties)
self.ale.setDifficulty(self.game_difficulty)
return [seed1, seed2]
示例6: _seed
# 需要導入模塊: from gym.utils import seeding [as 別名]
# 或者: from gym.utils.seeding import hash_seed [as 別名]
def _seed(self, seed=None):
self.np_random, seed1 = seeding.np_random(seed=seed)
# Derive a random seed. This gets passed as a uint, but gets
# checked as an int elsewhere, so we need to keep it below
# 2**31.
seed2 = seeding.hash_seed(seed1 + 1) % 2**31
seed3 = seeding.hash_seed(seed2 + 1) % 2**31
return [seed1, seed2, seed3]
示例7: seed
# 需要導入模塊: from gym.utils import seeding [as 別名]
# 或者: from gym.utils.seeding import hash_seed [as 別名]
def seed(self, seed=None):
self.np_random, seed1 = seeding.np_random(seed)
seed2 = seeding.hash_seed(seed1 + 1) % 2 ** 31
return [seed1, seed2]