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

delete rllib_requirements

parent a88bde13
......@@ -35,3 +35,6 @@ neural-mmo/forge/embyr/UnityClient/Assets/Lava/Lava[[:space:]]shader/
neural-mmo/forge/embyr/.git/objects/pack/pack-5c1cfbdf3b08a40d55a16c96a08b0703d8c45d06.pack filter=lfs diff=lfs merge=lfs -text
neural-mmo/.git/objects/pack/pack-761b342ca629338a5b6f4a437e2cb3b00764032a.pack filter=lfs diff=lfs merge=lfs -text
neural-mmo/baselines/models/CompetitionRound1/checkpoint filter=lfs diff=lfs merge=lfs -text
neuralmmo/baselines/models/CompetitionRound1/checkpoint filter=lfs diff=lfs merge=lfs -text
.git/objects/86/dea2a1e66382a85833663350ccdf3e6f80df37 filter=lfs diff=lfs merge=lfs -text
.git/lfs/objects/2c/d4/2cd453319c09516a158bf133370d7b879474962c9ae2a4c1bbd7c962f3ae0a45 filter=lfs diff=lfs merge=lfs -text
'''Main file for the neural-mmo/projekt demo
/projeckt contains all necessary RLlib wrappers to train and
evaluate capable policies on Neural MMO as well as rendering,
logging, and visualization tools.
Associated docs and tutorials are hosted on'''
from pdb import set_trace as T
import numpy as np
from fire import Fire
import projekt
from neural_mmo.forge.blade.core import terrain
from neural_mmo.forge.trinity.scripted import baselines
from neural_mmo.forge.trinity.visualize import BokehServer
from neural_mmo.forge.trinity.evaluator import Evaluator
def createPolicies(config, mapPolicy):
'''Generate RLlib policies'''
obs = wrapper.observationSpace(config)
atns = wrapper.actionSpace(config)
policies = {}
for i in range(config.NPOLICIES):
params = {
"agent_id": i,
"obs_space_dict": obs,
"act_space_dict": atns}
key = mapPolicy(i)
policies[key] = (None, obs, atns, params)
return policies
def loadTrainer(config):
'''Create monolithic RLlib trainer object'''
#Register custom env
lambda config: wrapper.RLlibEnv(config))
#Create policies
rllib.models.ModelCatalog.register_custom_model('godsword', wrapper.RLlibPolicy)
mapPolicy = lambda agentID: 'policy_{}'.format(agentID % config.NPOLICIES)
policies = createPolicies(config, mapPolicy)
#Instantiate monolithic RLlib Trainer object.
return wrapper.SanePPOTrainer(config={
'num_workers': config.NUM_WORKERS,
'num_gpus_per_worker': config.NUM_GPUS_PER_WORKER,
'num_gpus': config.NUM_GPUS,
'num_envs_per_worker': 1,
'train_batch_size': config.TRAIN_BATCH_SIZE // 2,
'rollout_fragment_length': config.ROLLOUT_FRAGMENT_LENGTH,
'sgd_minibatch_size': config.SGD_MINIBATCH_SIZE,
'num_sgd_iter': config.NUM_SGD_ITER,
'framework': 'torch',
'horizon': np.inf,
'soft_horizon': False,
'no_done_at_end': False,
'callbacks': wrapper.RLlibLogCallbacks,
'env_config': {
'config': config
'multiagent': {
'policies': policies,
'policy_mapping_fn': mapPolicy,
'count_steps_by': 'env_steps'
'model': {
'custom_model': 'godsword',
'custom_model_config': {'config': config},
'max_seq_len': config.LSTM_BPTT_HORIZON
def loadEvaluator(config):
'''Create test/render evaluator'''
if config.SCRIPTED:
return Evaluator(config, getattr(baselines, config.SCRIPTED))
return wrapper.RLlibEvaluator(config, loadModel(config))
def loadModel(config):
'''Load NN weights and optimizer state'''
trainer = loadTrainer(config)
if config.LOAD:
return trainer
class Anvil():
'''Neural MMO CLI powered by Google Fire
Main file for the RLlib demo included with Neural MMO.
python <COMMAND> --config=<CONFIG> --ARG1=<ARG1> ...
The User API documents core env flags. Additional config options specific
to this demo are available in projekt/
The --config flag may be used to load an entire group of options at once.
The Debug, SmallMaps, and LargeMaps options are included in this demo with
the latter being the default -- or write your own in projekt/
def __init__(self, **kwargs):
if 'help' in kwargs:
if 'config' in kwargs:
config = kwargs.pop('config')
config = getattr(projekt.config, config)()
config = projekt.config.LargeMaps()
self.config = config
if not config.SCRIPTED:
global torch, ray, rllib, wrapper, utils
from neural_mmo.forge.ethyr.torch import utils
import torch
import ray
from ray import rllib
from projekt import rllib_wrapper as wrapper
def train(self, **kwargs):
'''Train a model starting with the current value of --MODEL'''
def evaluate(self, **kwargs):
'''Evaluate a model on --EVAL_MAPS maps'''
self.config.EVALUATE = True
def render(self, **kwargs):
'''Start a WebSocket server that autoconnects to the 3D Unity client'''
self.config.RENDER = True
def generate(self, **kwargs):
'''Generate game maps for the current --config setting'''
def visualize(self, **kwargs):
'''Training/Evaluation results Web dashboard'''
def main():
def Display(lines, out):
text = "\n".join(lines) + "\n"
from fire import core
core.Display = Display
if __name__ == "__main__":
#Resources directory
......@@ -3,6 +3,7 @@ from pdb import set_trace as T
from neural_mmo.forge.blade import core
from neural_mmo.forge.blade.core import config
import os
class RLlibConfig:
'''Base config for RLlib Models
......@@ -78,6 +79,9 @@ class SmallMaps(config.SmallMaps, RLlibConfig, config.AllGameSystems):
#Maps Path
PATH_MAPS = os.path.join(os.getcwd(),'neuralmmo/resource')
class Debug(SmallMaps, config.AllGameSystems):
'''Debug Neural MMO training setting
___ ___ ___ ___
/__/\ /__/\ /__/\ / /\
\ \:\ | |::\ | |::\ / /::\ An open source
\ \:\ | |:|:\ | |:|:\ / /:/\:\ project originally
_____\__\:\ __|__|:|\:\ __|__|:|\:\ / /:/ \:\ founded by Joseph Suarez
/__/::::::::\ /__/::::| \:\ /__/::::| \:\ /__/:/ \__\:\ and formalized at OpenAI
\ \:\~~\~~\/ \ \:\~~\__\/ \ \:\~~\__\/ \ \:\ / /:/
\ \:\ ~~~ \ \:\ \ \:\ \ \:\ /:/ Now developed and
\ \:\ \ \:\ \ \:\ \ \:\/:/ maintained at MIT in
\ \:\ \ \:\ \ \:\ \ \::/ Phillip Isola's lab
\__\/ \__\/ \__\/ \__\/
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