forked from openai/neural-mmo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from CarperAI/2.0
2.0
- Loading branch information
Showing
110 changed files
with
9,937 additions
and
6,331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: pylint-test | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip setuptools wheel | ||
pip install . | ||
- name: Running unit tests | ||
run: pytest | ||
- name: Analysing the code with pylint | ||
run: pylint --recursive=y nmmo tests | ||
- name: Looking for xcxc, just in case | ||
run: | | ||
if grep -r --include='*.py' 'xcxc'; then | ||
echo "Found xcxc in the code. Please check the file." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[MESSAGES CONTROL] | ||
|
||
disable=W0511, # TODO/FIXME | ||
W0105, # string is used as a statement | ||
C0114, # missing module docstring | ||
C0115, # missing class docstring | ||
C0116, # missing function docstring | ||
W0221, # arguments differ from overridden method | ||
C0415, # import outside toplevel | ||
E0611, # no name in module | ||
R0901, # too many ancestors | ||
R0902, # too many instance attributes | ||
R0903, # too few public methods | ||
R0911, # too many return statements | ||
R0912, # too many branches | ||
R0913, # too many arguments | ||
R0914, # too many local variables | ||
R0914, # too many local variables | ||
R0915, # too many statements | ||
R0401, # cyclic import | ||
|
||
[INDENTATION] | ||
indent-string=' ' | ||
|
||
[MASTER] | ||
good-names-rgxs=^[_a-zA-Z][_a-z0-9]?$ # whitelist short variables | ||
known-third-party=ordered_set,numpy,gym,pettingzoo,vec_noise,imageio,scipy,tqdm | ||
load-plugins=pylint.extensions.bad_builtin | ||
|
||
[BASIC] | ||
bad-functions=print # checks if these functions are used |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,34 @@ | ||
from .version import __version__ | ||
import logging | ||
|
||
import os | ||
motd = r''' ___ ___ ___ ___ | ||
/__/\ /__/\ /__/\ / /\ Version {:<8} | ||
\ \:\ | |::\ | |::\ / /::\ | ||
\ \:\ | |:|:\ | |:|:\ / /:/\:\ An open source | ||
_____\__\:\ __|__|:|\:\ __|__|:|\:\ / /:/ \:\ project originally | ||
/__/::::::::\ /__/::::| \:\ /__/::::| \:\ /__/:/ \__\:\ founded by Joseph Suarez | ||
\ \:\~~\~~\/ \ \:\~~\__\/ \ \:\~~\__\/ \ \:\ / /:/ and formalized at OpenAI | ||
\ \:\ ~~~ \ \:\ \ \:\ \ \:\ /:/ | ||
\ \:\ \ \:\ \ \:\ \ \:\/:/ Now developed and | ||
\ \:\ \ \:\ \ \:\ \ \::/ maintained at MIT in | ||
\__\/ \__\/ \__\/ \__\/ Phillip Isola's lab '''.format(__version__) | ||
from .version import __version__ | ||
|
||
from . import scripting | ||
from .lib import material, spawn | ||
from .overlay import Overlay, OverlayRegistry | ||
from .render.overlay import Overlay, OverlayRegistry | ||
from .io import action | ||
from .io.stimulus import Serialized | ||
from .io.action import Action | ||
from .core import config, agent | ||
from .core.agent import Agent | ||
from .core.env import Env, Replay | ||
from . import scripting, emulation, integrations | ||
from .core.env import Env | ||
from .systems.achievement import Task | ||
from .core.terrain import MapGenerator, Terrain | ||
|
||
__all__ = ['Env', 'config', 'scripting', 'emulation', 'integrations', 'agent', 'Agent', 'MapGenerator', 'Terrain', | ||
'Serialized', 'action', 'Action', 'scripting', 'material', 'spawn', | ||
'Task', 'Overlay', 'OverlayRegistry', 'Replay'] | ||
MOTD = rf''' ___ ___ ___ ___ | ||
/__/\ /__/\ /__/\ / /\ Version {__version__:<8} | ||
\ \:\ | |::\ | |::\ / /::\ | ||
\ \:\ | |:|:\ | |:|:\ / /:/\:\ An open source | ||
_____\__\:\ __|__|:|\:\ __|__|:|\:\ / /:/ \:\ project originally | ||
/__/::::::::\ /__/::::| \:\ /__/::::| \:\ /__/:/ \__\:\ founded by Joseph Suarez | ||
\ \:\~~\~~\/ \ \:\~~\__\/ \ \:\~~\__\/ \ \:\ / /:/ and formalized at OpenAI | ||
\ \:\ ~~~ \ \:\ \ \:\ \ \:\ /:/ | ||
\ \:\ \ \:\ \ \:\ \ \:\/:/ Now developed and | ||
\ \:\ \ \:\ \ \:\ \ \::/ maintained at MIT in | ||
\__\/ \__\/ \__\/ \__\/ Phillip Isola's lab ''' | ||
|
||
__all__ = ['Env', 'config', 'agent', 'Agent', 'MapGenerator', 'Terrain', | ||
'action', 'Action', 'material', 'spawn', | ||
'Task', 'Overlay', 'OverlayRegistry'] | ||
|
||
try: | ||
import openskill | ||
from .lib.rating import OpenSkillRating | ||
__all__.append('OpenSkillRating') | ||
except: | ||
print('Warning: OpenSkill not installed. Ignore if you do not need this feature') | ||
__all__.append('OpenSkillRating') | ||
except RuntimeError: | ||
logging.error('Warning: OpenSkill not installed. Ignore if you do not need this feature') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +0,0 @@ | ||
from nmmo.core.map import Map | ||
from nmmo.core.realm import Realm | ||
from nmmo.core.tile import Tile | ||
from nmmo.core.config import Config | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,20 @@ | ||
from pdb import set_trace as T | ||
|
||
from nmmo.lib import colors | ||
|
||
class Agent: | ||
scripted = False | ||
policy = 'Neural' | ||
|
||
color = colors.Neon.CYAN | ||
pop = 0 | ||
|
||
def __init__(self, config, idx): | ||
'''Base class for agents | ||
policy = 'Neural' | ||
|
||
Args: | ||
config: A Config object | ||
idx: Unique AgentID int | ||
''' | ||
self.config = config | ||
self.iden = idx | ||
self.pop = Agent.pop | ||
def __init__(self, config, idx): | ||
'''Base class for agents | ||
def __call__(self, obs): | ||
'''Used by scripted agents to compute actions. Override in subclasses. | ||
Args: | ||
config: A Config object | ||
idx: Unique AgentID int | ||
''' | ||
self.config = config | ||
self.iden = idx | ||
|
||
Args: | ||
obs: Agent observation provided by the environment | ||
''' | ||
pass | ||
def __call__(self, obs): | ||
'''Used by scripted agents to compute actions. Override in subclasses. | ||
class Random(Agent): | ||
'''Moves randomly, including bumping into things and falling into lava''' | ||
def __call__(self, obs): | ||
return {Action.Move: {Action.Direction: rand.choice(Action.Direction.edges)}} | ||
Args: | ||
obs: Agent observation provided by the environment | ||
''' |
Oops, something went wrong.