Skip to content

Commit

Permalink
Merge pull request #26 from CarperAI/puf07-nmmomg
Browse files Browse the repository at this point in the history
Integrate winner solutions, puffer 0.7, and syllabus
  • Loading branch information
jsuarez5341 authored Jul 29, 2024
2 parents 23093bd + 0fe4872 commit 0b2819a
Show file tree
Hide file tree
Showing 90 changed files with 12,100 additions and 3,967 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/pylint-test.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: tox
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
py: ["3.8", "3.9", "3.10"]
steps:
- name: Setup python for test ${{ matrix.py }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
- uses: actions/checkout@v3
- name: Upgrade pip
run: python -m pip install -U pip setuptools wheel cython
- name: Install
run: python -m pip install -e '.[dev]'
- name: Check formatting
run: ruff format .
- name: Check lint
run: ruff check .
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.2
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
36 changes: 0 additions & 36 deletions .pylintrc

This file was deleted.

63 changes: 62 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,69 @@

# ![icon](https://neuralmmo.github.io/_build/html/_images/icon.png) Welcome to the Platform!

[Documentation](https://neuralmmo.github.io "Neural MMO Documentation") is hosted by github.io.
[![PyPI version](https://badge.fury.io/py/nmmo.svg)](https://badge.fury.io/py/nmmo)
[![](https://dcbadge.vercel.app/api/server/BkMmFUC?style=plastic)](https://discord.gg/BkMmFUC)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Follow%20%40jsuarez5341)](https://twitter.com/jsuarez5341)

Baselines repository for Neural MMO. New users should treat this as a starter project. [Documentation](https://neuralmmo.github.io "Neural MMO Documentation") is hosted by github.io.
## Installation

After cloning this repo, run:

```
pip install -e .[dev]
```

## Training

To test if the installation was successful (with the `--debug` mode), run the following command:

```
python train.py --debug --no-track
```

To log the training process, edit the wandb section in `config.yaml` and remove `--no-track` from the command line. The `config.yaml` file contains various configuration settings for the project.

### Agent zoo and your custom policy

This baseline comes with four different models under the `agent_zoo` directory: `neurips23_start_kit`, `yaofeng`, `takeru`, and `hybrid`. You can use any of these models by specifying the `-a` argument.

```
python train.py -a hybrid
```

You can also create your own policy by creating a new module under the `agent_zoo` directory, which should contain `Policy`, `Recurrent`, and `RewardWrapper` classes.

### Curriculum Learning using Syllabus

The training script supports automatic curriculum learning using the [Syllabus](https://github.com/RyanNavillus/Syllabus) library. To use it, add `--syllabus` to the command line.

```
python train.py --syllabus
```

## Replay generation

The `policies` directory contains a set of trained policies. For your models, create a directory and copy the checkpoint files to it. To generate a replay, run the following command:

```
python train.py -m replay -p policies
```

The replay file ends with `.replay.lzma`. You can view the replay using the [web viewer](https://kywch.github.io/nmmo-client/).

## Evaluation

The evaluation script supports the pvp and pve modes. The pve mode spawns all agents using only one policy. The pvp mode spawns groups of agents, each controlled by a different policy.

To evaluate models in the `policies` directory, run the following command:

```
python evaluate.py policies pvp -r 10
```

This generates 10 results json files in the same directory (by using `-r 10`), each of which contains the results from 200 episodes. Then the task completion metrics can be viewed using:

```
python analysis/proc_eval_result.py policies
```
Empty file added agent_zoo/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions agent_zoo/hybrid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# ruff: noqa
from .takeru import Policy
from .takeru import Recurrent
from .yaofeng import RewardWrapper
3 changes: 3 additions & 0 deletions agent_zoo/neurips23_start_kit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .baseline_policy import Baseline as Policy
from .baseline_policy import Recurrent
from .reward_wrapper import RewardWrapper
Loading

0 comments on commit 0b2819a

Please sign in to comment.