RAM extraction mode

RAM Extraction submodule of OCAtari

class ocatari.ram.game_objects.GameObject[source]

The Parent Class of every detected object in the Atari games (RAM Extraction mode)

Variables:
  • category (str) – The Category of class name of the game object (e.g. Player, Ball).

  • x (int) – The x positional coordinate on the image (on the horizontal axis).

  • y (int) – The y positional coordinate on the image (on the vertical axis).

  • w (int) – The width/horizontal size of the object (in pixels).

  • h (int) – The height/vertical size of the object (in pixels).

  • prev_xy ((int, int)) – The positional coordinates x and y of the previous time step in a tuple.

  • xy – Both positional coordinates x and y in a tuple.

  • h_coords ([(int, int), (int, int)]) – History of coordinates, i.e. current (x, y) and previous (x, y) position.

  • dx (int) – The pixel movement corresponding to: current_x - previous_x.

  • dy (int) – The pixel movement corresponding to: current_y - previous_y.

  • xywh ((int, int, int, int)) – The positional and width/height coordinates in a single tuple (x, y, w, h).

  • orientation (int) – The orientation of the object (if available); game specific.

  • center ((int, int)) – The center of the bounding box of the object.

  • hud (bool) – True, if part of the Heads Up Display, and thus not interactable.

Vartype:

(int, int)

closest_object(others)[source]

Returns the closest object from others, based on manathan distance between the center of both objects.

Returns:

(Index, Object) from others

Return type:

int

is_on_top(other)[source]

Returns True if this and another gameobject overlap.

Returns:

True if objects overlap

Return type:

bool

manathan_distance(other)[source]

Returns the manathan distance between the center of both objects.

Returns:

True if objects overlap

Return type:

bool

property properties

All the properties of the object in a list.

Returns:

The properties of the object.

Return type:

list

class ocatari.ram.game_objects.ValueObject[source]

This class represents a game object that incorporates any notion of a value. For example: * the score of the player (or sometimes Enemy). * the level of useable/deployable resources (oxygen bars, ammunition bars, power gauges, etc.) * the clock/timer

Variables:

value (int) – The value of the score.

closest_object(others)

Returns the closest object from others, based on manathan distance between the center of both objects.

Returns:

(Index, Object) from others

Return type:

int

is_on_top(other)

Returns True if this and another gameobject overlap.

Returns:

True if objects overlap

Return type:

bool

manathan_distance(other)

Returns the manathan distance between the center of both objects.

Returns:

True if objects overlap

Return type:

bool

property properties

All the properties of the object in a list.

Returns:

The properties of the object.

Return type:

list

Set of helper methods that are used in multiple Atari games

ocatari.ram._helper_methods.bitfield_to_number(b, flip=False)[source]

Converts an int to a list of 1s and 0s which represent each bit of the input.

Parameters:
  • b (uint8) – The number to be converted

  • flip (bool) – Weter to flip the array or not.

Returns:

The bit list corresponding to this number.

Return type:

list of int

ocatari.ram._helper_methods.get_iou(obj1, obj2)[source]

Computes the intersection over union between two GameObjects. Visual description of IOU

Parameters:
ocatari.ram._helper_methods.number_to_bitfield(n)[source]

Convert number to 8 bit bitfield.

Games like SpaceInvaders or Breakout use the bit representation of the number in the RAM to display or not display the objects. In most cases a 1 means the objects is displayed and a 0 means the object is not displayed. In SpaceInvaders the bit sequence needs to be reversed.

Parameters:

n (uint8) – The number to be converted

Returns:

The number in decimal

Return type:

list of int