Skip to content

Commit

Permalink
Merge pull request #42 from Farama-Foundation/feature/cleanup_experim…
Browse files Browse the repository at this point in the history
…ental_script

Experimental launch script
  • Loading branch information
ffelten authored Feb 20, 2024
2 parents 425091b + 513c7be commit 0c5621d
Show file tree
Hide file tree
Showing 14 changed files with 513 additions and 276 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ For details on multi-objective multi-agent RL definitions, see [Multi-Objective
You can also check more examples in this colab notebook! [![MOMAland Demo in Collab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Farama-Foundation/momaland/blob/doc/notebook/momaland_demo.ipynb)
<!-- end snippet-usage -->

## Learning Algorithms
<!-- start learning-algorithms -->
We provide a set of learning algorithms that are compatible with the MOMAland environments. The learning algorithms are implemented in the [learning/](https://github.com/Farama-Foundation/momaland/tree/main/momaland/learning) directory. To keep everything as self-contained as possible, each algorithm is implemented as a single-file (close to [cleanRL's philosophy](https://github.com/vwxyzjn/cleanrl/tree/master)).

Nevertheless, we reuse tools provided by other libraries, like multi-objective evaluations and performance indicators from [MORL-Baselines](https://github.com/LucasAlegre/morl-baselines).

Here is a list of algorithms that are currently implemented:

| **Name** | Single/Multi-policy | Reward | Utility | Observation space | Action space | Paper |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------|--------|---------------|-------------------|--------------|-------|
| MOMAPPO (OLS) [continuous](https://github.com/Farama-Foundation/momaland/blob/main/momaland/learning/continuous/cooperative_momappo.py),<br/> [discrete](https://github.com/Farama-Foundation/momaland/blob/main/momaland/learning/discrete/cooperative_momappo.py) | Multi | Team | Team / Linear | Any | Any | |


<!-- end learning-algorithms -->

## Environment Versioning
MOMAland keeps strict versioning for reproducibility reasons. All environments end in a suffix like "_v0". When changes are made to environments that might impact learning results, the number is increased by one to prevent potential confusion.

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ environments/all-envs
:caption: Tutorials
tutorials/custom_env
tutorials/training
tutorials/learning_algorithms
```

```{toctree}
Expand Down
9 changes: 9 additions & 0 deletions docs/tutorials/learning_algorithms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Learning algorithms
---

# Learning algorithms
```{include} ../../README.md
:start-after: <!-- start learning-algorithms -->
:end-before: <!-- end learning-algorithms -->
```
6 changes: 0 additions & 6 deletions docs/tutorials/training.md

This file was deleted.

1 change: 1 addition & 0 deletions momaland/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Export everything in the repo for import from other libraries."""

import momaland.envs
import momaland.learning
import momaland.utils


Expand Down
75 changes: 38 additions & 37 deletions momaland/envs/crazyrl/crazyRL_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,8 @@
import numpy.typing as npt
import pygame
from gymnasium import spaces
from OpenGL.GL import (
GL_AMBIENT,
GL_AMBIENT_AND_DIFFUSE,
GL_BLEND,
GL_COLOR_BUFFER_BIT,
GL_COLOR_MATERIAL,
GL_DEPTH_BUFFER_BIT,
GL_DEPTH_TEST,
GL_DIFFUSE,
GL_FRONT_AND_BACK,
GL_LIGHT0,
GL_LIGHTING,
GL_MODELVIEW,
GL_MODELVIEW_MATRIX,
GL_ONE_MINUS_SRC_ALPHA,
GL_POSITION,
GL_PROJECTION,
GL_SMOOTH,
GL_SRC_ALPHA,
glBlendFunc,
glClear,
glColor4f,
glColorMaterial,
glEnable,
glGetFloatv,
glLight,
glLightfv,
glLineWidth,
glLoadIdentity,
glMatrixMode,
glMultMatrixf,
glPopMatrix,
glPushMatrix,
glShadeModel,
)
from OpenGL.raw.GLU import gluLookAt, gluPerspective
from pygame import DOUBLEBUF, OPENGL

from momaland.envs.crazyrl.gl_utils import axes, field, point, target_point
from momaland.utils.env import MOParallelEnv


Expand Down Expand Up @@ -313,6 +276,44 @@ def step(self, actions):
@override
def render(self):
"""Renders the current frame of the environment. Only works in human rendering mode."""
from OpenGL.GL import (
GL_AMBIENT,
GL_AMBIENT_AND_DIFFUSE,
GL_BLEND,
GL_COLOR_BUFFER_BIT,
GL_COLOR_MATERIAL,
GL_DEPTH_BUFFER_BIT,
GL_DEPTH_TEST,
GL_DIFFUSE,
GL_FRONT_AND_BACK,
GL_LIGHT0,
GL_LIGHTING,
GL_MODELVIEW,
GL_MODELVIEW_MATRIX,
GL_ONE_MINUS_SRC_ALPHA,
GL_POSITION,
GL_PROJECTION,
GL_SMOOTH,
GL_SRC_ALPHA,
glBlendFunc,
glClear,
glColor4f,
glColorMaterial,
glEnable,
glGetFloatv,
glLight,
glLightfv,
glLineWidth,
glLoadIdentity,
glMatrixMode,
glMultMatrixf,
glPopMatrix,
glPushMatrix,
glShadeModel,
)
from OpenGL.raw.GLU import gluLookAt, gluPerspective

from momaland.envs.crazyrl.gl_utils import axes, field, point, target_point

def init_window():
"""Initializes the PyGame window."""
Expand Down
1 change: 1 addition & 0 deletions momaland/learning/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Learning module for momaland."""
1 change: 1 addition & 0 deletions momaland/learning/cooperative_momappo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Cooperative MOMAPPO."""
Loading

0 comments on commit 0c5621d

Please sign in to comment.