Recording Buffers

Game-state recording buffers for debugging and analysis.

class BaseRecordBuffer

Bases: object

For type-checking.

frames: ndarray | DummyArray
features: ndarray | DummyArray
rewards: ndarray | DummyArray
actions: ndarray | DummyArray
class RecordBuffer(res: tuple[int, int] = (240, 320), ch_num: int = 3, size: int = 40000, dtypes: list[dtype] | None = None)

Bases: object

Store game frames and associated scalars in a fixed-size circular buffer.

A class for recording game states.

Parameters:
  • res (tuple[int, int], optional) – resolution in form of (height, width). Defaults to (240, 320).

  • ch_num (int) – number of colour channels. Defaults to 3.

  • size (int) – maximum size, starts deleting old memories after maximum reached. Defaults to 40000.

  • dtypes (list[object]) – data type of frame, reward and (if any) features, datatype for features

  • [np.uint8 (should be passed in as strings like "np.uint8" or "bool". Defaults to)

  • np.float32].

add(frame: ndarray[integer], reward: floating, action: uint8, features: tuple = None)

Add a single state into memory.

add_filled(frame: ndarray[integer], reward: floating, action: uint8, features: tuple)

Add a single state into memory.

class FramelessRecordBuffer(*args, **kwargs)

Bases: BaseRecordBuffer

A dummy RecordBuffer that does not record actual game frames.

Wrap a RecordBuffer that stores rewards and actions only.

Parameters:
  • *args – Positional arguments forwarded to RecordBuffer.

  • **kwargs – Keyword arguments forwarded to RecordBuffer`. res and ch_num are ignored because frames are not stored.

add(_, *args, **kwargs) None

Record a transition while discarding the frame argument.

class DummyRecordBuffer

Bases: BaseRecordBuffer

A dummy RecordBuffer that does not record anything.

Initialize counters and dummy array placeholders.

add(*args, **kwargs) None

Increment the pointer without storing data.

Classes

RecordBuffer([res, ch_num, size, dtypes])

Store game frames and associated scalars in a fixed-size circular buffer.

FramelessRecordBuffer(*args, **kwargs)

A dummy RecordBuffer that does not record actual game frames.

DummyRecordBuffer()

A dummy RecordBuffer that does not record anything.

BaseRecordBuffer()

For type-checking.

Implementation modules

Circular buffer for frames, rewards, actions, and optional features.

class RecordBuffer(res: tuple[int, int] = (240, 320), ch_num: int = 3, size: int = 40000, dtypes: list[dtype] | None = None)

Bases: object

Store game frames and associated scalars in a fixed-size circular buffer.

A class for recording game states.

Parameters:
  • res (tuple[int, int], optional) – resolution in form of (height, width). Defaults to (240, 320).

  • ch_num (int) – number of colour channels. Defaults to 3.

  • size (int) – maximum size, starts deleting old memories after maximum reached. Defaults to 40000.

  • dtypes (list[object]) – data type of frame, reward and (if any) features, datatype for features

  • [np.uint8 (should be passed in as strings like "np.uint8" or "bool". Defaults to)

  • np.float32].

add(frame: ndarray[integer], reward: floating, action: uint8, features: tuple = None)

Add a single state into memory.

add_filled(frame: ndarray[integer], reward: floating, action: uint8, features: tuple)

Add a single state into memory.

No-op record buffers that skip or minimize frame storage.

class DummyRecordBuffer

Bases: BaseRecordBuffer

A dummy RecordBuffer that does not record anything.

Initialize counters and dummy array placeholders.

add(*args, **kwargs) None

Increment the pointer without storing data.

class FramelessRecordBuffer(*args, **kwargs)

Bases: BaseRecordBuffer

A dummy RecordBuffer that does not record actual game frames.

Wrap a RecordBuffer that stores rewards and actions only.

Parameters:
  • *args – Positional arguments forwarded to RecordBuffer.

  • **kwargs – Keyword arguments forwarded to RecordBuffer`. res and ch_num are ignored because frames are not stored.

add(_, *args, **kwargs) None

Record a transition while discarding the frame argument.

Base types for record buffers and no-op array stubs.

class DummyArray

Bases: object

A dummy array with NumPy-like interfaces.

transpose(*args, **kwargs) None

Ignore transpose calls.

fill(*args, **kwargs) None

Ignore fill calls.

class BaseRecordBuffer

Bases: object

For type-checking.