-
-
Notifications
You must be signed in to change notification settings - Fork 917
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Jax Cliffwalking Env #407
Jax Cliffwalking Env #407
Conversation
@@ -17,7 +17,7 @@ | |||
from gymnasium.wrappers import HumanRendering | |||
|
|||
|
|||
RenderStateType = Tuple["pygame.Surface"] # type: ignore # noqa: F821 | |||
RenderStateType = Tuple["pygame.Surface", Tuple[int, int], int, Tuple[int, int], "numpy.ndarray", Tuple["pygame.Surface", "pygame.Surface", "pygame.Surface", "pygame.Surface"], "pygame.Surface", "pygame.Surface", Tuple[str, str], Tuple["pygame.surface", "pygame.surface"], Tuple[str, str], Tuple["pygame.surface", "pygame.surface"], "pygame.surface"] # type: ignore # noqa: F821 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we want the RenderStateType to be a NamedTuple?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, and I think close to being merged. Thanks for your hard work.
I was able to get the type issue solved using from __future__ import annotations
and if TYPE_CHECKING: import pygame
from __future__ import annotations
from os import path
from typing import TYPE_CHECKING, NamedTuple
import jax
import jax.numpy as jnp
import numpy as np
from jax.random import PRNGKey
from gymnasium import spaces
from gymnasium.error import DependencyNotInstalled
from gymnasium.experimental.functional import ActType, FuncEnv, StateType
from gymnasium.experimental.functional_jax_env import FunctionalJaxEnv
from gymnasium.utils import EzPickle
from gymnasium.wrappers import HumanRendering
if TYPE_CHECKING:
import pygame
class RenderStateType(NamedTuple):
"""A named tuple which contains the full render state of the Cliffwalking Env. This is static during the episode."""
screen: pygame.surface
shape: tuple[int, int]
nS: int
cell_size: tuple[int, int]
cliff: np.ndarray
elf_images: tuple[pygame.Surface, pygame.Surface, pygame.Surface, pygame.Surface]
start_img: pygame.Surface
goal_img: pygame.Surface
bg_imgs: tuple[str, str]
mountain_bg_img: tuple[pygame.Surface, pygame.Surface]
near_cliff_imgs: tuple[str, str]
near_cliff_img: tuple[pygame.Surface, pygame.Surface]
cliff_img: pygame.Surface
added that typing fix |
Description
This adds a
CliffWalkingJaxEnv
to thetabular
environment suite, as well as the underlyingFuncEnv
subclassCliffWalkingFunctional
.CliffWalkingJaxEnv
is registered with the name"Jax-CliffWalking-v0"
This PR still needs a bit of polish work, but you can try it out for yourself in GUI mode withType of change
Please delete options that are not relevant.
Checklist:
pre-commit
checks withpre-commit run --all-files
(seeCONTRIBUTING.md
instructions to set it up)