Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ray 2.0.6 #141

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ dmypy.json

envs/unity/
logs/
logs.*/
dump/
tmp/
Packaging Python Projects — Python Packaging User Guide_files/
Expand Down
6 changes: 3 additions & 3 deletions docs/ADV_CLEAN_RL.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ You can read more about CleanRL in their [technical paper](https://arxiv.org/abs

# Installation
```bash
pip install godot-rl[clean-rl]
pip install godot-rl[cleanrl]
```

While the default options for clean-rl work reasonably well. You may be interested in changing the hyperparameters.
We recommend taking the [clean-rl example](https://github.com/edbeeching/godot_rl_agents/blob/main/examples/clean_rl_example.py) and modifying to match your needs.
While the default options for cleanrl work reasonably well. You may be interested in changing the hyperparameters.
We recommend taking the [cleanrl example](https://github.com/edbeeching/godot_rl_agents/blob/main/examples/clean_rl_example.py) and modifying to match your needs.

```python
parser.add_argument("--gae-lambda", type=float, default=0.95,
Expand Down
2 changes: 2 additions & 0 deletions docs/ADV_RLLIB.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## Installation

If you want to train with rllib, create a new environment e.g.: `python -m venv venv.rllib` as rllib's dependencies can conflict with those of sb3 and other libraries.

```bash
# remove sb3 installation with pip uninstall godot-rl[sb3]
pip install godot-rl[rllib]
Expand Down
19 changes: 12 additions & 7 deletions godot_rl/wrappers/ray_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,35 @@ def __init__(
show_window=show_window,
framerate=framerate,
action_repeat=action_repeat,
)
)
super().__init__(
observation_space=self._env.observation_space,
action_space=self._env.action_space,
num_envs=self._env.num_envs,
)

def vector_reset(self) -> List[EnvObsType]:
def vector_reset(self, seeds = None, options = None) -> List[EnvObsType]:
obs, info = self._env.reset()
return obs
return obs, ([info] * self.num_envs)

def vector_step(
self, actions: List[EnvActionType]
) -> Tuple[List[EnvObsType], List[float], List[bool], List[EnvInfoDict]]:
actions = np.array(actions)
actions = np.array(actions, dtype=np.dtype(object))
self.obs, reward, term, trunc, info = self._env.step(actions, order_ij=True)
return self.obs, reward, term, info
return self.obs, reward, term, trunc, info

def get_unwrapped(self):
return [self._env]

def reset_at(self, index: Optional[int]) -> EnvObsType:
def reset_at(self, index: Optional[int], seed = None, options = None) -> EnvObsType:
# the env is reset automatically, no need to reset it
return self.obs[index]
if hasattr(self, "obs"):
return self.obs[index], {}
else:
# First Reset
obs, info = self._env.reset()
return obs[index], info


def register_env():
Expand Down
12 changes: 2 additions & 10 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,9 @@ sf =
sample-factory

rllib =
numpy==1.23.5
ray==2.2.0
gymnasium==0.26.3
ray[rllib]
tensorflow_probability

clean-rl =
cleanrl =
wandb

all =
numpy==1.23.5
sample-factory
ray==2.2.0
ray[rllib]
tensorflow_probability