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

Modify vec_gym_env to be compatible with latest version of Gymnasium #1515

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

s-casci
Copy link
Contributor

@s-casci s-casci commented Jan 2, 2024

This code modifies vec_gym_env.rs to handle the new step API, like it was done for gym_env.rs. It also makes significant changes to atari_wrappers.py.

In particular, atari_wrappers.py now uses Gymnasium's Vector API, through AsyncVectorEnv, and handles the preprocessing for Atari environments with the AtariPreprocessing wrapper.

The changes were tested with Gymnasium version 0.29.1.

Example usage:

let env = VecGymEnv::new("SpaceInvadersNoFrameskip-v4", 4, Some("/tmp"))?;
env.reset(rng.gen::<u64>())?;
let step = env.step(vec![0i64; 4])?;

where step is now of the following type:

pub struct Step<A> {
    pub states: Vec<Tensor>,
    pub actions: Vec<A>,
    pub rewards: Vec<f64>,
    pub terminated: Vec<bool>,
    pub truncated: Vec<bool>,
}

It might be worth considering modifying vec_gym_env.rs further to allow for non-Atari environments in the future.

@s-casci s-casci changed the title Modify vec_gym_env to be compatible with latest version of Gymnasium Modify vec_gym_env to be compatible with latest version of Gymnasium Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant