From bd507c37c34ed566e8fef24eb9f18395c12f4e2d Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Fri, 31 May 2024 13:11:09 +0200 Subject: [PATCH] native support for fancy_gym --- README.md | 2 +- fancy_rl/on_policy.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e20693..462b097 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Fancy RL provides two main components: ppo.train() ``` - For environments, you can pass any gymnasium environment ID as a string, a function returning a gymnasium environment, or an already instantiated gymnasium environment. Future plans include supporting other torchrl environments. + For environments, you can pass any [gymnasium](https://gymnasium.farama.org/) or [Fancy Gym](https://alrhub.github.io/fancy_gym/) environment ID as a string, a function returning a gymnasium environment, or an already instantiated gymnasium environment. Future plans include supporting other torchrl environments. Check 'example/example.py' for a more complete usage example. 2. **Additional Modules for TRPL**: Designed to integrate with torchrl's primitives-first approach, these modules are ideal for building custom algorithms with precise trust region projections. diff --git a/fancy_rl/on_policy.py b/fancy_rl/on_policy.py index eeb22ac..6093e29 100644 --- a/fancy_rl/on_policy.py +++ b/fancy_rl/on_policy.py @@ -9,6 +9,10 @@ from torchrl.envs import ExplorationType, set_exploration_type from torchrl.envs.libs.gym import GymWrapper from torchrl.record import VideoRecorder import gymnasium as gym +try: + import fancy_gym +except ImportError: + pass class OnPolicy(ABC): def __init__(