Gymnasium wrapper for PySTK2
Project description
PySuperTuxKart gymnasium wrapper
warning: pystk2-gymnasium is in alpha stage - the environments might change abruptly!
Install
The PySuperKart2 gymnasium wrapper is a Python package, so installing is fairly easy
pip install pystk2-gymnasium
Note that during the first run, SuperTuxKart assets are downloaded in the cache directory.
Environments
Warning only one SuperTuxKart environment can be created for now. Moreover, no graphics information is available for now.
After importing pystk2_gymnasium
, the following environments are available:
supertuxkart-v0
is the main environment containing complete observations, with the following options:render_mode
can be None orhuman
track
defines the SuperTuxKart track to use (None for random). The full list can be found inSTKRaceEnv.TRACKS
after initialization withinitialize.initialize(with_graphics: bool)
has been called.num_kart
defines the number of karts on the track (3 by default)rank_start
defines the starting position (None for random, which is the default)use_ai
flag (False by default) to ignore actions and use a SuperTuxKart botmax_paths
the maximum number of the (nearest) paths (a track is made of paths) to consider in the observation statelaps
is the number of laps (1 by default)difficulty
is the difficulty of the other bots (0 to 2, default to 2)
supertuxkart-simple-v0
is a simplified environment with fixed number of observations for paths (controlled bystate_paths
, default 5), items (state_items
, default 5), karts (state_karts
, default 5)supertuxkart-flattened-v0
has observation and action spaces simplified at the maximum (onlydiscrete
andcontinuous
keys)supertuxkart-flattened-continuous-actions-v0
removes discrete actions (default to 0) so this is steer/acceleration only in the continuous domainsupertuxkart-flattened-multidiscrete-v0
is like the previous one, but with fully multi-discrete actions.acceleration_steps
andsteer_steps
(default to 5) control the number of discrete values for acceleration and steering respectively.supertuxkart-flattened-discrete-v0
is like the previous one, but with fully discretized actions
The reward is the distance traveled.
Example
import gymnasium as gym
import pystk2_gymnasium
# Use a a flattened version of the observation and action spaces
# In both case, this corresponds to a dictionary with two keys:
# - `continuous` is a vector corresponding to the continuous observations
# - `discrete` is a vector (of integers) corresponding to discrete observations
env = gym.make("supertuxkart-flattened-v0", render_mode="human", use_ai=False)
ix = 0
done = False
state, *_ = env.reset()
while not done:
ix += 1
action = env.action_space.sample()
state, reward, terminated, truncated, _ = env.step(action)
done = truncated or terminated
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pystk2_gymnasium-0.3.2.tar.gz
(21.4 kB
view hashes)
Built Distribution
Close
Hashes for pystk2_gymnasium-0.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 030eeb1fcadddac6b59dc996ec2b4ad5850fa1daedb563593482c98f4a836219 |
|
MD5 | 3f1b9a00712a6296448ce7eacb4bc487 |
|
BLAKE2b-256 | 72899b9c8ddfb57474cba5ceec5fc9479e702742614542377e62c2e8fe6ac6b5 |