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

is_terminated return type is unexpected in multi_threaded_env #901

Open
Graeme22 opened this issue Jun 9, 2023 · 1 comment
Open

is_terminated return type is unexpected in multi_threaded_env #901

Graeme22 opened this issue Jun 9, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@Graeme22
Copy link

Graeme22 commented Jun 9, 2023

MultiThreadEnv has a property called terminals which is a BitArray{1} containing the termination information for all of the wrapped environments.

However, the is_terminated function behaves in an unexpected way:

function RLBase.is_terminated(env::MultiThreadEnv)
    env.terminals .= is_terminated.(env.envs)
    env.terminals
end

The function implements the same is_terminated required for any AbstractEnv; however, instead of returning a Bool as the name and typical usage of the function would imply, it returns the env.terminals property which is a BitArray.

The problem with this is that it breaks any code that expects an is_terminated call to return a Bool, such as the StopAfterEpisode hook. I propose changing the function to the following:

function RLBase.is_terminated(env::MultiThreadEnv)
    env.terminals .= is_terminated.(env.envs)
    env.terminals == trues(size(env.terminals))
end

This way, the function will behave as expected in the majority of cases, and anyone who needs the termination status of individual wrapped envs can still access that with env.terminals.

@HenriDeh
Copy link
Member

Sounds good to me

@jeremiahpslewis jeremiahpslewis added the bug Something isn't working label Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants