Commit 5a57e9f3 authored by Siddhartha Laghuvarapu's avatar Siddhartha Laghuvarapu
Browse files

Add env

parent ae85876e
Metadata-Version: 1.0
Name: gym-neuralmmo
Version: 0.0.1
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN
setup.py
gym_neuralmmo.egg-info/PKG-INFO
gym_neuralmmo.egg-info/SOURCES.txt
gym_neuralmmo.egg-info/dependency_links.txt
gym_neuralmmo.egg-info/requires.txt
gym_neuralmmo.egg-info/top_level.txt
\ No newline at end of file
from gym.envs.registration import register
register(
id='neuralmmo-v0',
entry_point='gym_neuralmmo.envs:NeuralMMOEval',
)
register(
id='neuralmmo-v1',
entry_point='gym_neuralmmo.envs:NeuralMMOTrain',
)
\ No newline at end of file
from gym_neuralmmo.envs.neuralmmo_eval import NeuralMMOEval
from gym_neuralmmo.envs.neuralmmo_train import NeuralMMOTrain
import gym
from gym import error, spaces, utils
from gym.utils import seeding
from forge.blade.systems import ai
from forge.trinity import env
import projekt
class NeuralMMOEval(gym.Env):
def __init__(self):
config = projekt.config.SmallMaps()
self.env = env.Env(config)
self.agents_in_play = {}
self.available_agents = []
self.alive_agents = []
def reset(self):
self.observations = env.reset()
self.alive_agents = list(self.observations.keys())
self.agents_in_play[self.alive_agents[0]] = self.player_agent
self.available_agents = self.eval_agents
self.assign_agents()
return self.observations
def get_available_agent(self):
try:
return self.available_agents.pop()
except:
return self.get_default_agent()
def assign_agents(self):
for agent in self.alive_agents:
if agent not in self.agents_in_play:
self.agents_in_play[agent] = self.get_available_agent()
def get_agent_actions(self):
actions = {}
for agent in self.observations:
actions[agent] = self.alive_agents[agent].compute_action(self.observations[agent])
return actions
def step(self):
self.actions = self.get_agent_actions(self.observations)
self.observations,dones,rewards,_ = env.step(self.actions)
self.alive_agents = list(obs.keys())
self.assign_agents()
return self.parse_observations(self,self.observations,dones,rewards,_)
def set_player_agent(self,player_agent):
self.player_agent = player_agent
def set_eval_agents(self,eval_agents):
self.eval_agents = eval_agents
def get_default_agent(self):
raise NotImplementedError
def parse_observations(self):
raise NotImplementedError
import gym
from gym import error, spaces, utils
from gym.utils import seeding
from forge.blade.systems import ai
from forge.trinity import env
import projekt
class NeuralMMOTrain(gym.Env, env.Env):
def __init__(self):
config = projekt.config.SmallMaps()
super().__init__(config)
from setuptools import setup
setup(name='gym_neuralmmo',
version='0.0.1',
install_requires=['gym']
)
../neural-mmo/forge
\ No newline at end of file
../neural-mmo/projekt
\ 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