Beispiel #1
0
def initialize():
    np.random.seed(1)
    torch.manual_seed(1)
    return EpsGreedy(Parameter(1)), GridWorld(2, 2, start=(0, 0), goal=(1, 1)),\
           Gym(name='MountainCar-v0', horizon=np.inf, gamma=1.)
Beispiel #2
0
def test_grid_world():
    np.random.seed(1)
    mdp = GridWorld(start=(0, 0), goal=(2, 2), height=3, width=3)
    mdp.reset()
    mdp.render()
    for i in range(10):
        ns, r, ab, _ = mdp.step([np.random.randint(mdp.info.action_space.n)])
    mdp.render()

    assert ns == 5

    np.random.seed(1)
    mdp = GridWorldVanHasselt()
    mdp.reset()
    for i in range(10):
        ns, r, ab, _ = mdp.step([np.random.randint(mdp.info.action_space.n)])

    assert ns == 2

    np.random.seed(5)
    mdp = generate_grid_world('tests/environments/grid.txt', .9, 1, -1)
    mdp.reset()
    for i in range(10):
        ns, r, ab, _ = mdp.step([np.random.randint(mdp.info.action_space.n)])

    assert ns == 4