def manual_control(**kwargs):
    from .knights_archers_zombies import env as _env
    env = _env(**kwargs)
    env.reset()
    done = False
    cur_agent = 0
    frame_count = 0
    quit_game = 0
    while (not done):
        agents = env.agents
        frame_count += 1
        actions = [5 for x in range(len(env.agents))]
        for event in pygame.event.get():
            if (event.type == pygame.KEYDOWN):
                if (event.key == pygame.K_ESCAPE):
                    quit_game = 1
                    break
                if (event.key == pygame.K_BACKSPACE):
                    env.reset()
                if (event.key == pygame.K_a):
                    cur_agent -= 1
                    if (cur_agent < 0):
                        cur_agent = (len(agents) - 1)
                if (event.key == pygame.K_d):
                    cur_agent += 1
                    if (cur_agent > (len(agents) - 1)):
                        cur_agent = 0
                if (event.key == pygame.K_q):
                    actions[cur_agent] = 2
                if (event.key == pygame.K_e):
                    actions[cur_agent] = 3
                if (event.key == pygame.K_w):
                    actions[cur_agent] = 0
                if (event.key == pygame.K_s):
                    actions[cur_agent] = 1
                if (event.key == pygame.K_f):
                    actions[cur_agent] = 4
        if quit_game:
            break
        for a in actions:
            env.step(a)
        env.render()
        done = any(env.dones.values())
    env.close()
def manual_control(**kwargs):
    from .knights_archers_zombies import env as _env
    env = _env(**kwargs)
    env.reset()
    done = False
    cur_agent = 0
    frame_count = 0
    quit_game = 0
    while (not done):
        agents = env.agents
        frame_count += 1
        actions = [5 for x in range(len(env.agents))]
        for event in pygame.event.get():
            if (event.type == pygame.KEYDOWN):
                if (event.key == pygame.K_ESCAPE):
                    quit_game = 1
                    break
                if (event.key == pygame.K_BACKSPACE):
                    env.reset()
                if (event.key == pygame.K_a):
                    cur_agent -= 1
                    if (cur_agent < 0):
                        cur_agent = (len(agents) - 1)
                if (event.key == pygame.K_d):
                    cur_agent += 1
                    if (cur_agent > (len(agents) - 1)):
                        cur_agent = 0
                if (event.key == pygame.K_q):
                    actions[cur_agent] = 2
                if (event.key == pygame.K_e):
                    actions[cur_agent] = 3
                if (event.key == pygame.K_w):
                    actions[cur_agent] = 0
                if (event.key == pygame.K_s):
                    actions[cur_agent] = 1
                if (event.key == pygame.K_f):
                    actions[cur_agent] = 4
        if quit_game:
            break
        for a in actions:
            env.step(a)
        env.render()
        done = any(env.dones.values())
    env.close()