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

Update gym imports to gymnasium (since openai/gym isn't maintained) #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion vgdl/interfaces/gym/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from gym.envs.registration import register
from gymnasium.envs.registration import register
from .env import VGDLEnv
from .register_samples import register_sample_games

Expand Down
4 changes: 2 additions & 2 deletions vgdl/interfaces/gym/env.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from collections import OrderedDict
import gym
from gym import spaces
import gymnasium as gym
from gymnasium import spaces
import vgdl
from vgdl.state import StateObserver
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion vgdl/interfaces/gym/list_space.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from gym import Space
from gymnasium import Space

class list_space(Space):
def __init__(self, basespace):
Expand Down
4 changes: 2 additions & 2 deletions vgdl/interfaces/gym/register_samples.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gym
from gym.envs.registration import register
import gymnasium as gym
from gymnasium.envs.registration import register
from vgdl.interfaces.gym import VGDLEnv
import os

Expand Down
4 changes: 2 additions & 2 deletions vgdl/util/humanplay/human.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
logger = logging.getLogger(__name__)

import gym
import gymnasium as gym


class HumanController:
Expand All @@ -18,7 +18,7 @@ def __init__(self, env_name, trace_path=None, fps=15):
from .wrappers import AtariObservationWrapper
self.env = AtariObservationWrapper(self.env)
if trace_path is not None and importlib.util.find_spec('gym_recording') is not None:
from gym_recording.wrappers import TraceRecordingWrapper
from gymnasium_recording.wrappers import TraceRecordingWrapper
self.env = TraceRecordingWrapper(self.env, trace_path)
elif trace_path is not None:
logger.warn('trace_path provided but could not find the gym_recording package')
Expand Down
2 changes: 1 addition & 1 deletion vgdl/util/humanplay/list_envs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

def list_envs():
import gym
import gymnasium as gym
import gym_vgdl
env_names = list(gym.envs.registry.env_specs.keys())
return env_names
Expand Down
4 changes: 2 additions & 2 deletions vgdl/util/humanplay/play_vgdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import argparse
import logging

import gym
import gymnasium as gym

import vgdl.interfaces.gym
from .human import HumanVGDLController

THIS_DIR = os.path.dirname(os.path.abspath(__file__))

def register_vgdl_env(domain_file, level_file, observer=None, blocksize=None):
from gym.envs.registration import register, registry
from gymnasium.envs.registration import register, registry
level_name = '.'.join(os.path.basename(level_file).split('.')[:-1])
env_name = 'vgdl_{}-v0'.format(level_name)

Expand Down