Exemplo n.º 1
0
def test_nogui_agent(agent_pos=None, coin_pos=None):
    '''
    Testing of the agent training with no gui of the game board
    :return:
    '''
    world = get_fake_world(
    ) if not agent_pos and not coin_pos else get_fake_world(
        agent_pos, coin_pos)
    qagent.setup(world)
    plt.ioff()

    for episode in range(settings['n_rounds']):
        print('EPISODE: ', episode)
        for step in range(100):
            try:
                print('STEP: ', step)
                qagent.act(world)
                next_action = world.next_action
                new_world = fake_environment_step(world, next_action)
                qagent.reward_update(new_world)
                world = new_world
            except:
                print(traceback.format_exc())
                print('ERRROROR    error happened!!!!!!')
        qagent.end_of_episode(world)
        world = fake_environment_reset(
            world
        ) if not agent_pos and not coin_pos else fake_environment_reset(
            world, agent_pos=agent_pos, coin_pos=coin_pos)
Exemplo n.º 2
0
def test_gui_agent(agent_pos=None, coin_pos=None):
    '''
    Testing of the agente training with gui of the game board
    :return:
    '''
    plt.ion()

    world = get_fake_world(
    ) if not agent_pos and not coin_pos else get_fake_world(
        agent_pos, coin_pos)
    qagent.setup(world)
    screen = RealWorld(world)

    for episode in range(10):
        print('EPISODE: ', episode)
        for step in range(100):
            print('STEP: ', step)
            qagent.act(world)
            next_action = world.next_action
            new_world = fake_environment_step(world, next_action)
            screen.animate(new_world)
            time.sleep(0.01)
            qagent.reward_update(new_world)
            world = new_world
        qagent.end_of_episode(world)
        world = fake_environment_reset(
            world
        ) if not agent_pos and not coin_pos else fake_environment_reset(
            world, agent_pos=agent_pos, coin_pos=coin_pos)
Exemplo n.º 3
0
def test_coin_zone_gen():
    '''
    Test of the coin zone generation and the states from it.
    :return:
    '''
    world =get_fake_world()
    qagent.setup(world)
    qagent.act(world)
    qagent.reward_update(world)
    agent_world = world.game_wrapper.agent.game_abstraction
    print('agenst world arena')
    print(agent_world.map)
    print('position of the robot: ')
    print(world.game_state['self'])
Exemplo n.º 4
0
def test_nogui_agent():
    '''
    Testing of the agent training with no gui of the game board
    :return:
    '''
    world = get_fake_world()
    qagent.setup(world)

    for episode in range(settings['n_rounds']):
        print('EPISODE: ', episode)
        for step in range(100):
            print('STEP: ', step)
            qagent.act(world)
            next_action = world.next_action
            new_world = fake_environment_step(world,next_action)
            qagent.reward_update(new_world)
            world = new_world
        qagent.end_of_episode(world)
        world = fake_environment_reset(world)