def run_agent(join_token, agent_id):
    """
        Where agent_id is an integral number starting from 0
        In case, you have requested GPUs, then the agent_id will match 
        the GPU device id assigneed to this agent.
    """
    env = marlo.init(join_token)
    observation = env.reset()
    done = False
    count = 0
    while not done:
        _action = env.action_space.sample()
        obs, reward, done, info = env.step(_action)
        print("reward:", reward)
        print("done:", done)
        print("info", info)

    # It is important to do this env.close()   
    env.close()
Example #2
0
out_dir_logs = out_dir + '/logging'
if not os.path.exists(out_dir_logs):
    os.makedirs(out_dir_logs)
if save_dir and not os.path.exists(save_dir):
    os.makedirs(save_dir)

experiments.set_log_base_dir(out_dir)

# Ensure that you have a minecraft-client running with : marlo-server --port 10000
# "MarLo-FindTheGoal-v0"
# 'MarLo-CatchTheMob-v0'
join_tokens = marlo.make("MarLo-FindTheGoal-v0",
                         params=dict(allowContinuousMovement=["move", "turn"],
                                     videoResolution=[84, 84],
                                     kill_clients_after_num_rounds=500))
env = marlo.init(join_tokens[0])

obs = env.reset()
env.render(mode="rgb_array")
print('initial observation:', obs)

action = env.action_space.sample()
obs, r, done, info = env.step(action)
print('next observation:', obs)
print('reward:', r)
print('done:', done)
print('info:', info)

print('actions:', str(env.action_space))
print('sample action:', str(env.action_space.sample))
Example #3
0
#!/usr/bin/env python
# Please ensure that you have a Minecraft client running on port 10000
# by doing :
# $MALMO_MINECRAFT_ROOT/launchClient.sh -port 10000

import marlo

client_pool = [('127.0.0.1', 10000)]
join_tokens = marlo.make('MarLo-MazeRunner-v0',
                         params={"client_pool": client_pool})
# As this is a single agent scenario,
# there will just be a single token
assert len(join_tokens) == 1
join_token = join_tokens[0]

env = marlo.init(join_token)

observation = env.reset()

done = False
while not done:
    _action = env.action_space.sample()
    obs, reward, done, info = env.step(_action)
    print("reward:", reward)
    print("done:", done)
    print("info", info)
env.close()
Example #4
0
def env_creator(env_config):
    return marlo.init(join_token)