Ejemplo n.º 1
0
def test_invalid_seeds():
    for seed in [-1, 'test']:
        try:
            seeding.np_random(seed)
        except error.Error:
            pass
        else:
            assert False, 'Invalid seed {} passed validation'.format(seed)
Ejemplo n.º 2
0
 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]
Ejemplo n.º 3
0
    def _seed(self, seed=None):
        self.np_random, seed = seeding.np_random(seed)

        # Update the random policy if needed
        if isinstance(self.opponent, str):
            if self.opponent == 'random':
                self.opponent_policy = make_random_policy(self.np_random)
            else:
                raise error.Error('Unrecognized opponent policy {}'.format(
                    self.opponent))
        else:
            self.opponent_policy = self.opponent

        return [seed]
Ejemplo n.º 4
0
def test_valid_seeds():
    for seed in [0, 1]:
        random, seed1 = seeding.np_random(seed)
        assert seed == seed1
 def _seed(self, seed=None):
     self.np_random, seed = seeding.np_random(seed)
     return [seed]
Ejemplo n.º 6
0
 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
     pachi_py.pachi_srand(seed2)
     return [seed1, seed2]