Commit ae85876e authored by Siddhartha Laghuvarapu's avatar Siddhartha Laghuvarapu
Browse files

Initial commit

parents
from utils.base_agent import NeuralMMOAgent
class RandomNeuralMMOAgent(NeuralMMOAgent):
def __init__(self):
pass
def register_reset(self, observations):
action = self.agent.compute_actions(observations)
return action
def compute_action(self, observations, info=None):
action = self.agent.compute_actions(observations)
return action
def get_action(observations):
return {}
\ No newline at end of file
# Define agents that will be used for evaluation.
# Agents need to implement abstract class NeuralMMOAgent.
# Agents will be located in agents/
# Max number of opponent agents is 127
player_agent:
file: random_agent
agent_class: RandomNeuralMMOAgent
opponent_agents:
agent_1:
file: random_agent
agent_class: RandomNeuralMMOAgent
start_sequence: 1
end_sequence: 50
agent_2:
file: random_agent
agent_class: RandomNeuralMMOAgent
start_sequence: 51
end_sequence: 100
agent_3:
file: random_agent
agent_class: RandomNeuralMMOAgent
start_sequence: 101
end_sequence: 127
import gym
import yaml
def get_agent(agent_dict):
def load_agents(agents_config):
with open(agents_config, 'r') as stream:
data = yaml.safe_load(stream)
player_agent = get_agent(data['player_agent'])
opponent_agents = []
for agent in data['opponent_agents']:
opponent_agents.append(get_agent(agent))
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)
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)
if __name__ == "__main__":
main()
\ No newline at end of file
python ./rollout.py
\ No newline at end of file
from abc import ABC, abstractmethod
class NeuralMMOAgent(ABC):
@abstractmethod
def register_reset(self, observations):
pass
@abstractmethod
def compute_action(self,observations,info):
pass
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