Description
Currently get_screen_buffer returns a pointer to the UInt8 vector which is flat (ie length == width*height*channels
).
This presents 2 problems:
- 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
- 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.