Create RAM Object
ram.init.RdUses a game ROM object to create a RAM object, which stores all dynamic data of the game. As ram.run() runs the game, the RAM is updated and read.
Arguments
- ROM
ROM object containing game code.
Value
A RAM object contains the following elements.
$ROM | | ROM object the game is run with. |
$ticks | Number of ticks the game has processed. | |
$time | Time of the latest frame reached by the RAM. | |
$rng | Local RNG state for the RAM; see ram.set_rng | |
$seed | Integer used to set the rng during ram.init. Random by default. | |
$objects | List of game-related objects; dynamic game data should generally be stored here. Objects in this list which have a $spritename are drawn in render.ram(). | |
$inputs | List of all inputs the game has received, matching inputs.csv. See inputs.process(). | |
$actions | List of all game actions that are currently active. | |
$n_inputs | Number of inputs from inputs.csv the RAM has read. Used to determine which are new. | |
$backup | Copy of RAM from a couple seconds ago, excluding $ROM, $inputs, $debug, $backup, and $intermediate (since these shouldn't be rolled back). See ram.rollback | |
$intermediate | Same as $backup, but more recent. Used in ram.tick() to update $backup on a rolling basis. | |
$began | Vector of c(time,tick) indicating when ram.run was last run, used for timing inputs. | |
$paused | Boolean; is the game allowed to tick? | |
$debug | Collection of info about the current game session; see ram.debug. |
Notes
Custom game code (in RAM$ROM$custom) should typically only modify RAM$objects. This makes inspecting and handling the RAM more consistent across games.
Examples
if (FALSE) { # \dontrun{
RAM = ram.init(Snake)
View(RAM)
} # }