Skip to content

Commit

Permalink
Rename SimpleFastFiz to FastFiz
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsSR committed May 16, 2024
1 parent f16af6a commit 19c4709
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Use the environment for training a reinforcement learning agent:
from stable_baselines3 import PPO
from fastfiz_env import DefaultReward, make

env = make("SimpleFastFiz-v0", reward_function=DefaultReward, num_balls=2)
env = make("FastFiz-v0", reward_function=DefaultReward, num_balls=2)

model = PPO("MlpPolicy", env)

Expand Down
6 changes: 3 additions & 3 deletions src/fastfiz_env/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Gymnasium environments for pool, using FastFiz to simulate the physics of the game.
Avaliable environments:
- `SimpleFastFiz-v0`: Observes the position of the balls.
- `FastFiz-v0`: Observes the position of the balls.
- `PocketsFastFiz-v0`: Observes the position of the balls and in play state. Pocketed balls position always corresponds to given pocket center.
Expand Down Expand Up @@ -49,8 +49,8 @@


register(
id="SimpleFastFiz-v0",
entry_point="fastfiz_env.envs:SimpleFastFiz",
id="FastFiz-v0",
entry_point="fastfiz_env.envs:FastFiz",
additional_wrappers=(wrappers.TimeLimitInjectionWrapper.wrapper_spec(),),
)

Expand Down
6 changes: 2 additions & 4 deletions src/fastfiz_env/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
"""

from . import utils
from .simple_fastfiz import SimpleFastFiz
from .frames_fastfiz import FramesFastFiz
from .fastfiz import FastFiz
from .pockets_fastfiz import PocketsFastFiz

__all__ = [
"utils",
"SimpleFastFiz",
"FramesFastFiz",
"FastFiz",
"PocketsFastFiz",
]
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ..reward_functions import RewardFunction, DefaultReward


class SimpleFastFiz(gym.Env):
class FastFiz(gym.Env):
"""FastFiz environment for using different action spaces."""

TOTAL_BALLS = 16
Expand Down
8 changes: 4 additions & 4 deletions src/tests/envs/test_envs.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import unittest
from fastfiz_env.envs import SimpleFastFiz
from fastfiz_env.envs import FastFiz
from fastfiz_env.reward_functions.common import ConstantReward
from fastfiz_env.wrappers import TimeLimitInjectionWrapper


class TestSimpleFastFiz(unittest.TestCase):
def test_init(self):
num_balls = 16
env = SimpleFastFiz(num_balls=num_balls)
env = FastFiz(num_balls=num_balls)
env = TimeLimitInjectionWrapper(env)
self.assertEqual(env.observation_space.shape, (16, 2))
self.assertEqual(env.action_space.shape, (3,))

def test_reset(self):
num_balls = 16
env = SimpleFastFiz(num_balls=num_balls)
env = FastFiz(num_balls=num_balls)
env = TimeLimitInjectionWrapper(env)
obs, info = env.reset()
self.assertEqual(obs.shape, (16, 2))
self.assertEqual(info, {"is_success": False})

def test_step(self):
num_balls = 16
env = SimpleFastFiz(num_balls=num_balls, reward_function=ConstantReward())
env = FastFiz(num_balls=num_balls, reward_function=ConstantReward())
env = TimeLimitInjectionWrapper(env)
env.reset()
action = [0, 0, 60, 0, 0]
Expand Down

0 comments on commit 19c4709

Please sign in to comment.