From cf4851dc96b8354eff1d2f699ede2c6e121dae77 Mon Sep 17 00:00:00 2001 From: Benjamin Piwowarski Date: Fri, 6 Sep 2024 13:46:03 +0200 Subject: [PATCH] Fix numpy bug (in pystk2 0.3.8) --- pyproject.toml | 2 +- src/pystk2_gymnasium/pystk_process.py | 8 +++++--- tests/test_envs.py | 4 +--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 565d725..f8480b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,5 +23,5 @@ format-jinja = "{% if distance == 0 %}{{ base }}{% else %}{{ base }}+{{ distance [tool.poetry.dependencies] python = "^3.8" -PySuperTuxKart2 = ">=0.3.7" +PySuperTuxKart2 = ">=0.3.8" gymnasium = ">0.29.0" diff --git a/src/pystk2_gymnasium/pystk_process.py b/src/pystk2_gymnasium/pystk_process.py index 82fa2f3..16c3980 100644 --- a/src/pystk2_gymnasium/pystk_process.py +++ b/src/pystk2_gymnasium/pystk_process.py @@ -6,6 +6,8 @@ from typing import List, Optional import pystk2 +logger = logging.getLogger("pystk2_gymnasium.mp") + class PySTKRemoteProcess: world: Optional[pystk2.WorldState] = None @@ -61,8 +63,7 @@ def warmup_race(self, config) -> pystk2.Track: # Start race self.race.start() self.world = pystk2.WorldState() - self.track = pystk2.Track() - self.track.update() + track = pystk2.Track() while True: self.race.step() @@ -70,7 +71,8 @@ def warmup_race(self, config) -> pystk2.Track: if self.world.phase == pystk2.WorldState.Phase.GO_PHASE: break - return self.track + track.update() + return track def get_world(self): if self.world is None: diff --git a/tests/test_envs.py b/tests/test_envs.py index c29fab4..e5a5e54 100644 --- a/tests/test_envs.py +++ b/tests/test_envs.py @@ -21,6 +21,7 @@ def test_env(name, use_ai): ix = 0 done = False state, *_ = env.reset() + logging.exception("Running with environment %s", env.unwrapped.current_track) for _ in range(10): ix += 1 @@ -30,9 +31,6 @@ def test_env(name, use_ai): done = truncated or terminated if done: break - except Exception: - logging.exception("with environment %s", env.current_track) - raise finally: if env is not None: env.close()