Commit 30f949bd authored by Siddhartha Laghuvarapu's avatar Siddhartha Laghuvarapu
Browse files

Update rollout.py and players.yaml

parent 5a57e9f3
......@@ -11,17 +11,14 @@ opponent_agents:
agent_1:
file: random_agent
agent_class: RandomNeuralMMOAgent
start_sequence: 1
end_sequence: 50
num_agents: 50
agent_2:
file: random_agent
agent_class: RandomNeuralMMOAgent
start_sequence: 51
end_sequence: 100
num_agents: 51
agent_3:
file: random_agent
agent_class: RandomNeuralMMOAgent
start_sequence: 101
end_sequence: 127
num_agents: 101
import gym
import sys
import yaml
from tqdm import trange
import importlib
import gym
def get_agent(agent_dict):
sys.path.append('agents/')
module = importlib.import_module(agent_dict['file'])
agent = getattr(module,agent_dict['agent_class'])()
return agent
def load_agents(agents_config):
with open(agents_config, 'r') as stream:
......@@ -15,25 +21,23 @@ def load_agents(agents_config):
return player_agent,
def main():
env = gym.make("neuralmmo-eval")
player_agent, opponent_agents = load_agents()
agent = PlayerAgent()
env.set_eval_agents(get_eval_agents())
obs = env.reset()
action = agent.register_reset(obs)
player_agent, opponent_agents = load_agents('players.yaml')
env.set_player_agent(player_agent)
env.set_eval_agents(opponent_agents)
n_episodes = 100
total_rewards = 0
for _ in trange(100000000):
obs, reward, done, info = env.step(action)
total_rewards += reward
if done:
obs = env.reset()
action = agent.register_reset(obs)
else:
action = agent.compute_action(obs, info)
print("Total reward is ",total_rewards)
for _ in trange(n_episodes):
obs = env.reset()
done = False
while done == False:
obs,dones,rewards,_ = env.step()
total_rewards += rewards['player']
done = dones['player']
print("The total reward is ",total_rewards)
if __name__ == "__main__":
main()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment