Example #1
0
 def setup_method(self):
     self.env = GridWorldEnv(desc='4x4')
     self.policy = ScriptedPolicy(
         scripted_actions=[2, 2, 1, 0, 3, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1])
     self.algo = Mock(env_spec=self.env.spec,
                      policy=self.policy,
                      max_episode_length=16)
Example #2
0
def other_envs():
    descs = [
        ['SFFF', 'FFFF', 'FFFF', 'FFFF'],
        ['FFSF', 'FFFH', 'FHFH', 'HFFG'],
        ['FHSF', 'FFFH', 'FHFH', 'HFFG'],
        ['FHSF', 'FGFH', 'FHFH', 'HFFH'],
        ['SHFF', 'HHFF', 'FFFF', 'FFFF'],
    ]
    return [GridWorldEnv(desc=desc) for desc in descs]
Example #3
0
def envs():
    descs = [
        ['SFFF', 'FHFH', 'FFFH', 'HFFG'],
        ['SFFF', 'FFFH', 'FHFH', 'HFFG'],
        ['SFFF', 'FFFH', 'FHFH', 'FFFG'],
        ['SFFF', 'FFFF', 'FFFF', 'FFFF'],
        ['SHFF', 'HHFF', 'FFFF', 'FFFF'],
    ]
    return [GarageEnv(GridWorldEnv(desc=desc)) for desc in descs]
Example #4
0
def other_envs():
    descs = [
        ['FFFS', 'FHFH', 'FFFH', 'HFFG'],
        ['FFSF', 'FFFH', 'FHFH', 'HFFG'],
        ['FFFF', 'FFSH', 'FHFH', 'FFFG'],
        ['FFFF', 'FFFF', 'FSFF', 'FFFF'],
        ['HHFF', 'HHHF', 'HSHF', 'HHHF'],
    ]
    return [GarageEnv(GridWorldEnv(desc=desc)) for desc in descs]
Example #5
0
class TestRaySamplerTF():
    """
    Uses mock policy for 4x4 gridworldenv
    '4x4': [
        'SFFF',
        'FHFH',
        'FFFH',
        'HFFG'
    ]
    0: left
    1: down
    2: right
    3: up
    -1: no move
    'S' : starting point
    'F' or '.': free space
    'W' or 'x': wall
    'H' or 'o': hole (terminates episode)
    'G' : goal
    [2,2,1,0,3,1,1,1,2,2,1,1,1,2,2,1]
    """
    def setup_method(self):
        self.env = GridWorldEnv(desc='4x4')
        self.policy = ScriptedPolicy(
            scripted_actions=[2, 2, 1, 0, 3, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1])
        self.algo = Mock(env_spec=self.env.spec,
                         policy=self.policy,
                         max_episode_length=16)

    def teardown_method(self):
        self.env.close()

    def test_ray_batch_sampler(self, ray_local_session_fixture):
        del ray_local_session_fixture
        assert ray.is_initialized()
        workers = WorkerFactory(
            seed=100, max_episode_length=self.algo.max_episode_length)
        sampler1 = RaySampler(workers, self.policy, self.env)
        sampler1.start_worker()
        sampler1.shutdown_worker()
Example #6
0
def env():
    return GridWorldEnv(desc='4x4')
Example #7
0
def env():
    return GarageEnv(GridWorldEnv(desc='4x4'))