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

get_screen, get_automap, etc. Utility functions #16

Open
Islandman93 opened this issue Mar 27, 2021 · 0 comments
Open

get_screen, get_automap, etc. Utility functions #16

Islandman93 opened this issue Mar 27, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Islandman93
Copy link
Collaborator

Islandman93 commented Mar 27, 2021

Currently get_screen_buffer returns a pointer to the UInt8 vector which is flat (ie length == width*height*channels).

This presents 2 problems:

  1. The fact that this is a pointer to shared memory can be confusing if the user is unaware:
obs = get_screen_buffer(game)
make_action(game)
new_obs = get_screen_buffer(game)
# obs & new_obs now hold the same data
  1. I assume the most common use case will be operating on the image (IE: Array{UInt8, 3}) where the dimensions are channel, height, width defined by Julia's column-major ordering & common in the Images.jl package or for use with Flux.jl conv operators.

I think a utility function that copies the data, reverses it, and returns a correctly shaped array with a name like get_screen would make users lives easier when using this package.

http://www.cplusplus.com/reference/algorithm/reverse_copy/ would handle this functionality well, I think it's possible to set the size for ArrayRef on the c++ side which would prevent back and forth Julia->C++ to get the reversed & copied buffer then Julia->C++ to get the screen sizes for a reshape. If not, then a get_screen_buffer_reverse_copy to the c++ side which returns an ArrayRef & the buffer sizes (for convenience) and get_screen which calls that & reshapes it on the Julia end would work.

Once working, this function should also apply to get_automap and get_depth. get_labels will require issue #15 to be figured out first.

@Islandman93 Islandman93 added the enhancement New feature or request label Mar 27, 2021
@Islandman93 Islandman93 self-assigned this Mar 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant