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]
def seed(self, seed=None): self.np_random, seed = seeding.np_random(seed) return [seed]
def seed(self, seed=None): """Seed the PRNG of this space. """ self.np_random, seed = seeding.np_random(seed) return [seed]