facebookresearch / nle

The NetHack Learning Environment
Other
940 stars 114 forks source link

Don't allow set_buffers to be called after reset. #305

Closed heiner closed 2 years ago

heiner commented 2 years ago

This guarantees we write to the buffer from before and therefore need to only update the delta, saving us a few memcopies potentially.

Fixes #133.

cdmatters commented 2 years ago

This guarantees we write to the buffer from before and therefore need to only update the delta, saving us a few memcopies potentially.

Fixes #133.

Note for posterity - we do this in the tty observations where the callback from the virtual terminal on updating part of the screen involves writing to the observation. (cf - https://github.com/facebookresearch/nle/blob/main/src/nle.c#L69-L118)

heiner commented 2 years ago

Note for posterity - we do this in the tty observations where the callback from the virtual terminal on updating part of the screen involves writing to the observation. (cf - https://github.com/facebookresearch/nle/blob/main/src/nle.c#L69-L118)

Yes -- and specifically for the tty_chars observation it makes a lot of sense to only update the actually changed characters, like the actual tty would do. We also only write tty_cursor if it changed. Calling set_buffers after reset() was always broken in those cases (but also never part of our API anyway).