예제 #1
0
def get_current_state_test():
    w = World(5, 5, [(1, 1, 3), (2, 2, 4)], [(3, 3, 3), (4, 4, 4)], -1, 13, 13)
    a = Agent(0, 0)

    assert(get_current_state(w, a) == (0, 0, False, True, True, True, True))

    a._set_position(3, 3)
    w.pick_up(1, 1)
    w.pick_up(1, 1)
    w.pick_up(1, 1)

    assert(get_current_state(w, a) == (3, 3, False, False, True, True, True))
def p_random_test():
    agent = Agent(3, 3)
    world = World(5, 5, [(1, 1, 3)], [(1, 2, 3)], -1, 13, 13)
    q = QTable(world)

    assert (p_random(agent, world, q) in ["north", "south", "east", "west"])

    world = World(5, 5, [(4, 3, 3)], [(1, 1, 3)], -1, 13, 13)

    assert (p_random(agent, world, q) == "east")

    agent.pick_up()
    agent._set_position(1, 2)
    assert (p_random(agent, world, q) == "north")