Replays a solution's input sequence and caches per-step state for navigation.
More...
|
| | Playback (Runner &runner) |
| | Constructs the playback over a runner and caches state sizes.
|
| |
| void | initialize (const std::vector< std::string > &inputSequence) |
| | Replays the input sequence, recording one cached step per input (plus a trailing end-of-sequence step).
|
| |
| | ~Playback () |
| | Frees the game and renderer state memory allocated during initialization.
|
| |
| std::string | getStateInputString (const size_t currentStep) const |
| | Returns the input string of the given step.
|
| |
| jaffarPlus::InputSet::inputIndex_t | getStateInputIndex (const size_t currentStep) const |
| | Returns the input index of the given step.
|
| |
| void * | getStateData (const size_t currentStep) const |
| | Returns the serialized game state data of the given step.
|
| |
| const std::vector< size_t > | getStateRepeatedHashSteps (const size_t currentStep) const |
| | Returns the earlier steps (ascending) sharing the given step's hash.
|
| |
| jaffarCommon::hash::hash_t | getStateHash (const size_t currentStep) const |
| | Returns the state hash of the given step.
|
| |
| bool | isInputAllowed (const size_t currentStep) const |
| | Returns whether the input of the given step is allowed by the current move set.
|
| |
| ssize_t | getFirstWinStep () const |
| | Returns the first step (number of inputs applied) at which the solution reaches a win state, or -1 if it never does.
|
| |
| ssize_t | getFirstFailStep () const |
| | Returns the first step (number of inputs applied) at which the solution reaches a fail state, or -1 if it never does.
|
| |
| void | renderFrame (const size_t currentStep) |
| | Renders the cached frame for the given step into the emulator window.
|
| |
| void | loadStepData (const size_t stepId) |
| | Loads the cached game state of the given step back into the runner.
|
| |
| void | printInfo () const |
| | Prints runner, game, and emulator information.
|
| |
|
| Runner * | _runner |
| | Pointer to the runner used for playback.
|
| |
| size_t | _gameStateSize |
| | Size, in bytes, of a serialized game state.
|
| |
| size_t | _rendererStateSize |
| | Size, in bytes, of a serialized renderer state.
|
| |
| std::vector< step_t > | _sequence |
| | The recorded sequence of playback steps.
|
| |
| std::unordered_map< jaffarCommon::hash::hash_t, std::vector< size_t >, hashHasher_t > | _hashOccurrences |
| | Maps each state hash to the steps (ascending) at which it occurred, used to detect the repeated states the engine would have deduplicated.
|
| |
| ssize_t | _firstWinStep = -1 |
| | First step (inputs applied) reaching a win state; -1 until/unless one is seen.
|
| |
| ssize_t | _firstFailStep = -1 |
| | First step (inputs applied) reaching a fail state; -1 until/unless one is seen.
|
| |
Replays a solution's input sequence and caches per-step state for navigation.
Built from a Runner, initialize applies each input in order, recording for every step its input, allowance, serialized game and renderer state, state hash, and any earlier steps sharing that hash, as well as the first win/fail step. Cached steps can then be queried and re-loaded/rendered out of order by the player tool.
Definition at line 29 of file playback.hpp.
| void jaffarPlus::Playback::initialize |
( |
const std::vector< std::string > & |
inputSequence | ) |
|
|
inline |
Replays the input sequence, recording one cached step per input (plus a trailing end-of-sequence step).
For each step, registers/looks up the input, computes its allowance and state hash, records earlier steps sharing that hash, serializes the game and renderer state, advances the runner, evaluates rules, updates the game state type and reward, and records the first win/fail step.
- Parameters
-
| inputSequence | The ordered list of input strings to replay. |
Definition at line 81 of file playback.hpp.