Skip to content

Commit

Permalink
Merge pull request #73 from CarperAI/2.0
Browse files Browse the repository at this point in the history
2.0
  • Loading branch information
jsuarez5341 committed May 16, 2023
2 parents 6a54713 + 8fe21c6 commit af52303
Show file tree
Hide file tree
Showing 110 changed files with 9,937 additions and 6,331 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/pylint-test.yml
@@ -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
8 changes: 8 additions & 0 deletions .gitignore
@@ -1,6 +1,14 @@
# Game maps
maps/
*.swp
runs/*
wandb/*

# local replay file from tests/test_deterministic_replay.py, test_render_save.py
tests/replay_local*.pickle
replay*

.vscode

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
31 changes: 31 additions & 0 deletions .pylintrc
@@ -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
48 changes: 22 additions & 26 deletions nmmo/__init__.py
@@ -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')
4 changes: 0 additions & 4 deletions nmmo/core/__init__.py
@@ -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
42 changes: 14 additions & 28 deletions nmmo/core/agent.py
@@ -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
'''

0 comments on commit af52303

Please sign in to comment.