Skip to content

encode_unsafe_actions ​

python
encode_unsafe_actions(actions: Sequence[UnsafeAction], *, supports_reset_parameters: bool) -> bytearray

Pack action records into one buffer for MultiEnvironment.UnsafeEnqueueAction.

Initial-state and action-index payloads cross as pointer/length pairs, so the payload bytes objects must stay alive until OakEmu has copied them out (it does so during the enqueue call). The reset-parameter bitmask + values section is appended to each record only on builds that support it; supplying reset parameters on other builds is an encoder precondition violation.

Parameters:

  • actions (Sequence[UnsafeAction]) – The packed action tuples.
  • supports_reset_parameters (bool) – Whether the OakEmu build reads a reset-parameter section.

Returns:

  • bytearray – The packed buffer.

Raises:

  • RuntimeError – If a record carries a reset-parameter mask but the build does not support one.

Source