![]() |
JaffarPlus
High-performance best-first search optimizer for tool-assisted speedruns
|
Parallel state-space search engine. More...
#include <engine.hpp>
Classes | |
| struct | manualSaveSolution_t |
| A manually saved solution: its input path, reward, serialized state, and triggering rule index. More... | |
| struct | stateInfo_t |
| A reward value paired with a serialized state buffer. More... | |
| struct | threadAccumulator_t |
| Per-thread accumulator for timing and counters. More... | |
Public Member Functions | |
| Engine (const nlohmann::json &emulatorConfig, const nlohmann::json &gameConfig, const nlohmann::json &runnerConfig, const nlohmann::json &engineConfig) | |
| Constructs the engine, building one runner per worker thread and the state/hash databases. | |
| void | initialize () |
| Resets execution back to step zero and clears all databases and counters. | |
| void | runStep () |
| Runs a single search step: expands all current base states in parallel and advances the databases. | |
| ~Engine () | |
| Frees the best-win and manual-save state buffers allocated in initialize. | |
| auto & | getStateDb () const |
| Returns a reference to the owned state database. | |
| auto | getStepBestWinState () const |
| Returns a copy of the best win state recorded in the current step. | |
| size_t | getWinCollectedCount () |
| Number of distinct win solutions collected so far (see setWinStateCollection). | |
| bool | isWinCollectionFull () |
| Whether win collection is enabled and has reached its Max Files cap. | |
| bool | isWinCollectionEnabled () const |
| Whether win collection is enabled. | |
| size_t | getWinCollectionMax () const |
| Win collection Max Files cap. | |
| void | setWinStateCollection (const std::vector< std::string > &dedupProps, const std::string &pathPrefix, const size_t maxFiles) |
| Enables win-state collection: every win state's solution is saved to pathPrefix + hex(dedup property bytes) + ".sol", first-seen per key. | |
| bool | isReferencePruneRequested () const |
| Whether "Reference Reward Prune" is enabled in the engine configuration (the driver checks this to know it must supply the reference trace). | |
| void | setReferencePruneTrace (const std::vector< float > &trace) |
| Arms reference-reward pruning with the per-depth trace: every produced non-win state whose floor reward falls below the trace at its depth (beyond the configured Tolerance) is dropped instead of stored. | |
| auto | getManualSaveSolution () const |
| Returns a copy of the most recent manually saved solution. | |
| auto | getWinStatesFound () const |
| Returns the cumulative number of win states found so far. | |
| auto | getStateCount () const |
| Returns the number of states currently held in the state database. | |
| size_t | getInputHistoryMaxMemoryBytes () const |
| Hard memory ceiling (bytes) of the shared input-history backing; 0 for None/Raw (no ceiling). | |
| size_t | getInputHistoryApproxMemoryBytes () const |
| Current (approximate) live memory (bytes) of the shared input-history backing; 0 for None/Raw. | |
| bool | isInputHistoryExhausted () const |
| True if the shared input-history backing (the Trie) has hit its hard node-storage ceiling. | |
| void | printInfo () |
| Logs engine status: timing breakdown, throughput, state counts, checkpoints, databases, and detected candidate inputs. | |
| size_t | getStateSizeInDatabase () const |
| Returns the size, in bytes, of a single state as stored in the database. | |
| size_t | getFullStateSize () const |
| Full self-contained state size ([hot]+[history]); for standalone snapshots outside the slabs. | |
| jaffarCommon::hash::hash_t | computeStateHash (Runner &r) |
| Supplies per-depth serialized reference states for exact pin verification, and computes the volatile-byte mask: driver-side captures carry different instance residue (unrestored buffer bytes) than worker-produced states, so the mask is built empirically by re-producing a few reference states through a WORKER runner and diffing. | |
| const std::vector< std::vector< uint8_t > > & | getRefStates () const |
| Audit accessors: the per-depth canonical reference states and the volatile-byte mask (instance-dependent audio-ring residue) captured at floor initialization. | |
| const std::vector< uint8_t > & | getRefVolatileMask () const |
| Audit accessor: per-byte volatile mask (1 = instance-dependent byte) over the reference states. | |
| void | setReferenceStates (std::vector< std::vector< uint8_t > > &&states, const std::vector< std::string > &refInputs) |
| Installs the per-depth canonical reference states (from the driver's floor replay) and derives the volatile-byte mask by re-simulating probe depths and diffing the round-trips. | |
Private Types | |
| enum | inputResult_t { repeated , droppedNoStorage , droppedFailedSerialization , droppedCheckpoint , droppedBelowReference , failed , normal , win } |
| Outcome of running a single input on a base state. More... | |
Private Member Functions | |
| void | workerFunction () |
| Worker body executed in parallel by every thread during a step. | |
| inputResult_t | runNewInput (Runner &r, const void *baseStateData, const InputSet::inputIndex_t input, threadAccumulator_t &acc, const size_t threadId) |
| Re-loads the base state, runs a single input, updates per-outcome counters and checkpoint tracking. | |
| inputResult_t | runInput (Runner &r, const void *baseStateData, const InputSet::inputIndex_t input, threadAccumulator_t &acc, const size_t threadId) |
| Advances the runner by one input and classifies/stores the resulting state. | |
Private Attributes | |
| bool | _winCollectEnabled = false |
| Whether win-state collection is enabled (see setWinStateCollection). | |
| std::vector< std::string > | _winDedupPropNames |
| Names of the game properties whose bytes form the win-collection dedup key. | |
| std::string | _winCollectPrefix |
| Path prefix for saved win-collection .sol files and the manifest. | |
| size_t | _winCollectMax = 1000 |
| Maximum number of distinct win solutions to collect before terminating. | |
| std::set< std::string > | _winKeysSeen |
| Dedup keys of the win solutions collected so far. | |
| std::mutex | _winCollectLock |
| Guards _winKeysSeen and the win-collection file writes across worker threads. | |
| bool | _refPruneRequested = false |
| Whether "Reference Reward Prune" was enabled in the engine configuration. | |
| bool | _refPruneEnabled = false |
| Whether reference-reward pruning is armed (requested AND trace supplied). | |
| std::vector< float > | _refPruneTrace |
| Per-depth floor-reward trace of the reference solution for pruning. | |
| float | _refPruneTolerance = 0.0f |
| Allowed slack below the reference trace before a state is pruned. | |
| size_t | _refPruneStepGrace = 0 |
| Prune each state vs the reference this many steps earlier (transient-wait allowance) | |
| jaffarCommon::concurrent::HashMap_t< jaffarCommon::hash::hash_t, jaffarCommon::concurrent::HashSet_t< InputSet::inputIndex_t > > | _candidateInputsDetected |
| Per-base-state-input-hash set of candidate inputs already detected, used to dedup candidate-input probing. | |
| size_t | _currentStep = 0 |
| Counter for the current step. | |
| std::vector< std::unique_ptr< Runner > > | _runners |
| Collection of runners for the workers to use (one per thread). | |
| std::unique_ptr< jaffarPlus::StateDb > | _stateDb |
| Thread-safe state database holding the current and next step's states. | |
| std::shared_ptr< void > | _inputHistoryBacking |
| The one shared input-history backing (e.g. | |
| bool | _hashDbEnabled |
| Whether hashing is enabled. Games that cannot loop skip the hash DB to save memory and computation. | |
| size_t | _baseStateBatch |
| Active base-state pull batch size ("Base State Batch Size"). | |
| size_t | _hashLookahead = 0 |
| N null-advances before hashing (see "Hash Lookahead"); 0 = hash the current state. | |
| bool | _refPinEnabled = false |
| Whether reference pinning is active. | |
| bool | _refPinExactVerify = true |
| Whether hash-matched pin candidates are byte-verified against captured reference states. | |
| float | _refPinBonus = 0.0f |
| Reward bonus for matching the reference at the state's own depth. | |
| size_t | _refPinLookahead = 0 |
| How many future depths to also match (being ahead). | |
| float | _refPinLookaheadBonus = 0.0f |
| Extra bonus per frame ahead of the reference. | |
| std::vector< jaffarCommon::hash::hash_t > | _refPinHashes |
| Reference state hash at each search depth. | |
| std::atomic< size_t > | _refPinHits {0} |
| Cumulative reference-pin hits (diagnostic). | |
| bool | _compactLog = false |
| "Log Verbosity": "Compact" collapses the per-step engine block to essentials. | |
| std::atomic< size_t > | _refPinMaxDepthHit {0} |
| Deepest reference depth a pin matched (diagnostic). | |
| std::vector< std::vector< uint8_t > > | _refStates |
| Per-depth serialized reference states for EXACT pin verification (empty = hash-only pinning). | |
| std::atomic< size_t > | _refPinSeenPreDedup {0} |
| Reference-depth matches seen (diagnostic). | |
| std::unique_ptr< std::atomic< uint8_t >[]> | _refPinnedAtDepth |
| Per reference depth: claimed(1)/unclaimed(0), so exactly one copy is pinned. | |
| std::vector< uint8_t > | _refVolatileMask |
| 1 = byte is instance-residue (excluded from exact pin verification) | |
| std::unique_ptr< jaffarPlus::HashDb > | _hashDb |
| Thread-safe hash database used to detect repeated states. | |
| size_t | _stateSizeInDatabase |
| Size of a single state as stored in the database, in bytes. | |
| size_t | _fullStateSize |
| Full self-contained serialized state size ([hot]+[history]) for standalone snapshot buffers. | |
| std::mutex | _stepBestWinStateLock |
| Guards updates to _stepBestWinState. | |
| stateInfo_t | _stepBestWinState |
| Best win state (by reward) found during the current step. | |
| float | _bestWinSolutionReward = -std::numeric_limits<float>::infinity() |
| Highest-reward win seen across ALL steps, and the file its input history is written to at detection time (see the win-state handling in computeState). | |
| std::string | _winSolutionPath = "/tmp/jaffar.winsolution.sol" |
| File the best win-state's input history is written to (see _bestWinSolutionReward). | |
| std::mutex | _manualSaveSolutionLock |
| Guards updates to _manualSaveSolution. | |
| manualSaveSolution_t | _manualSaveSolution |
| Best manually saved solution for the current step. | |
| bool | _manualSaveSolutionUpdatedLastRuleId |
| Whether the manual-save last-rule id changed this step. | |
| ssize_t | _manualSaveSolutionActiveLastRuleId |
| Currently active manual-save last-rule id across steps. | |
| std::string | _manualSaveSolutionLastPath = "" |
| Path of the most recently activated manual-save solution. | |
| std::atomic< size_t > | _checkpointLevel |
| Highest checkpoint level reached so far. | |
| std::atomic< size_t > | _checkpointTolerance |
| Tolerance (in steps) associated with the current checkpoint level. | |
| std::atomic< size_t > | _checkpointCutoff |
| Step index after which states below _checkpointLevel are dropped. | |
| std::mutex | _checkpointMutex |
| Serializes checkpoint level rises (rare path). | |
| std::atomic< size_t > | _stepMaxLevelStored |
| States stored this step whose level >= the global checkpoint level. | |
| std::atomic< size_t > | _droppedStatesNoStorage |
| Counter for states dropped due to lack of free states. | |
| std::atomic< size_t > | _droppedStatesFailedSerialization |
| Counter for states dropped due to failed serialization. | |
| std::atomic< size_t > | _droppedStatesCheckpoint |
| Counter for states dropped due to not meeting the checkpoint. | |
| std::atomic< size_t > | _droppedStatesBelowReference |
| Number of states dropped for falling below the reference reward trace (reference pruning). | |
| std::atomic< size_t > | _repeatedStates |
| Counter for repeated states (detected via hash collision). | |
| std::atomic< size_t > | _failedStates |
| Counter for failed states (reached a point in the game considered a loss). | |
| std::atomic< size_t > | _winStates |
| Counter for win states. | |
| std::atomic< size_t > | _normalStates |
| Counter for normal states. | |
| std::atomic< size_t > | _stepBaseStatesProcessed |
| Base states processed during the current step. | |
| std::atomic< size_t > | _totalBaseStatesProcessed |
| Base states processed across all steps so far. | |
| std::atomic< size_t > | _stepNewStatesProcessed |
| New states processed during the current step. | |
| std::atomic< size_t > | _totalNewStatesProcessed |
| New states processed across all steps so far. | |
| size_t | _currentStepTime |
| Overall running time of the current step, in microseconds. | |
| std::vector< size_t > | _threadStepTime |
| Per-thread running time of the current step, in microseconds. | |
| size_t | _maxThreadStepTime |
| Maximum per-thread step time for the current step. | |
| size_t | _maxThreadStepTimeThreadId |
| Id of the thread with the maximum step time. | |
| std::vector< threadAccumulator_t > | _threadAccumulators |
| Per-thread accumulators for hot-loop timing/counters, reduced once per step. | |
| size_t | _totalRunningTime |
| Total running time so far, in microseconds. | |
| std::atomic< size_t > | _runnerStateAdvanceThreadRawTime |
| Summed per-thread runner-advance time for the step. | |
| std::atomic< size_t > | _runnerStateAdvanceAverageTime |
| Per-thread-average runner-advance time for the step. | |
| std::atomic< size_t > | _runnerStateAdvanceAverageCumulativeTime |
| Cumulative per-thread-average runner-advance time. | |
| std::atomic< size_t > | _runnerStateLoadThreadRawTime |
| Summed per-thread state-load time for the step. | |
| std::atomic< size_t > | _runnerStateLoadAverageTime |
| Per-thread-average state-load time for the step. | |
| std::atomic< size_t > | _runnerStateLoadAverageCumulativeTime |
| Cumulative per-thread-average state-load time. | |
| std::atomic< size_t > | _runnerStateSaveThreadRawTime |
| Summed per-thread state-save time for the step. | |
| std::atomic< size_t > | _runnerStateSaveAverageTime |
| Per-thread-average state-save time for the step. | |
| std::atomic< size_t > | _runnerStateSaveAverageCumulativeTime |
| Cumulative per-thread-average state-save time. | |
| std::atomic< size_t > | _calculateHashThreadRawTime |
| Summed per-thread hash-calculation time for the step. | |
| std::atomic< size_t > | _calculateHashAverageTime |
| Per-thread-average hash-calculation time for the step. | |
| std::atomic< size_t > | _calculateHashAverageCumulativeTime |
| Cumulative per-thread-average hash-calculation time. | |
| std::atomic< size_t > | _checkHashThreadRawTime |
| Summed per-thread hash-checking time for the step. | |
| std::atomic< size_t > | _checkHashAverageTime |
| Per-thread-average hash-checking time for the step. | |
| std::atomic< size_t > | _checkHashAverageCumulativeTime |
| Cumulative per-thread-average hash-checking time. | |
| std::atomic< size_t > | _ruleCheckingThreadRawTime |
| Summed per-thread rule-checking time for the step. | |
| std::atomic< size_t > | _ruleCheckingAverageTime |
| Per-thread-average rule-checking time for the step. | |
| std::atomic< size_t > | _ruleCheckingAverageCumulativeTime |
| Cumulative per-thread-average rule-checking time. | |
| std::atomic< size_t > | _getFreeStateThreadRawTime |
| Summed per-thread get-free-state time for the step. | |
| std::atomic< size_t > | _getFreeStateAverageTime |
| Per-thread-average get-free-state time for the step. | |
| std::atomic< size_t > | _getFreeStateAverageCumulativeTime |
| Cumulative per-thread-average get-free-state time. | |
| std::atomic< size_t > | _returnFreeStateThreadRawTime |
| Summed per-thread return-free-state time for the step. | |
| std::atomic< size_t > | _returnFreeStateAverageTime |
| Per-thread-average return-free-state time for the step. | |
| std::atomic< size_t > | _returnFreeStateAverageCumulativeTime |
| Cumulative per-thread-average return-free-state time. | |
| std::atomic< size_t > | _calculateRewardThreadRawTime |
| Summed per-thread reward-calculation time for the step. | |
| std::atomic< size_t > | _calculateRewardAverageTime |
| Per-thread-average reward-calculation time for the step. | |
| std::atomic< size_t > | _calculateRewardAverageCumulativeTime |
| Cumulative per-thread-average reward-calculation time. | |
| std::atomic< size_t > | _getAllowedInputsThreadRawTime |
| Summed per-thread get-allowed-inputs time for the step. | |
| std::atomic< size_t > | _getAllowedInputsAverageTime |
| Per-thread-average get-allowed-inputs time for the step. | |
| std::atomic< size_t > | _getAllowedInputsAverageCumulativeTime |
| Cumulative per-thread-average get-allowed-inputs time. | |
| std::atomic< size_t > | _getCandidateInputsThreadRawTime |
| Summed per-thread get-candidate-inputs time for the step. | |
| std::atomic< size_t > | _getCandidateInputsAverageTime |
| Per-thread-average get-candidate-inputs time for the step. | |
| std::atomic< size_t > | _getCandidateInputsAverageCumulativeTime |
| Cumulative per-thread-average get-candidate-inputs time. | |
| std::atomic< size_t > | _advanceHashDbThreadRawTime |
| Serially-measured hash-DB advance time for the step. | |
| std::atomic< size_t > | _advanceHashDbAverageTime |
| Hash-DB advance time reported for the step. | |
| std::atomic< size_t > | _advanceHashDbAverageCumulativeTime |
| Cumulative hash-DB advance time. | |
| std::atomic< size_t > | _advanceStateDbThreadRawTime |
| Serially-measured state-DB advance time for the step. | |
| std::atomic< size_t > | _advanceStateDbAverageTime |
| State-DB advance time reported for the step. | |
| std::atomic< size_t > | _advanceStateDbAverageCumulativeTime |
| Cumulative state-DB advance time. | |
| std::atomic< size_t > | _popBaseStateDbThreadRawTime |
| Summed per-thread base-state pop time for the step. | |
| std::atomic< size_t > | _popBaseStateDbAverageTime |
| Per-thread-average base-state pop time for the step. | |
| std::atomic< size_t > | _popBaseStateDbAverageCumulativeTime |
| Cumulative per-thread-average base-state pop time. | |
| size_t | _subTotalAverageTime |
| Sum of all per-operation average times for the current step. | |
| size_t | _subTotalAverageCumulativeTime |
| Sum of all per-operation cumulative average times. | |
Static Private Attributes | |
| static constexpr size_t | BASE_STATE_BATCH_MAX = 16 |
| Number of base states a worker pulls from the state-DB queue per lock acquisition (batch size). | |
Parallel state-space search engine.
Owns one Runner per worker thread, a StateDb holding the current and next step's states, and an optional HashDb for detecting repeated states. Each call to runStep expands every base state in the current database by trying its allowed and candidate inputs, evaluating game rules on the resulting states, and pushing the surviving normal states into the next database while recording win states, checkpoints, drop counts, and per-operation timing.
Definition at line 60 of file engine.hpp.
|
private |
Outcome of running a single input on a base state.
Definition at line 927 of file engine.hpp.
|
inline |
Constructs the engine, building one runner per worker thread and the state/hash databases.
| emulatorConfig | Configuration object passed to each runner's emulator. |
| gameConfig | Configuration object passed to each runner's game. |
| runnerConfig | Configuration object passed to each runner. |
| engineConfig | Engine configuration containing the "State Database" and "Hash Database" objects. |
| A | logic error if the configured worker thread count is zero. |
Definition at line 71 of file engine.hpp.
|
inline |
Frees the best-win and manual-save state buffers allocated in initialize.
Definition at line 622 of file engine.hpp.
|
inline |
Supplies per-depth serialized reference states for exact pin verification, and computes the volatile-byte mask: driver-side captures carry different instance residue (unrestored buffer bytes) than worker-produced states, so the mask is built empirically by re-producing a few reference states through a WORKER runner and diffing.
Verification compares outside the mask.
Computes the dedup hash for the runner's current state, honoring "Hash Lookahead": with N > 0, the state is saved, advanced N times with the game's null input, hashed, and restored – so transient input residue is hashed by its RAM consequences.
Definition at line 1529 of file engine.hpp.
|
inline |
Full self-contained state size ([hot]+[history]); for standalone snapshots outside the slabs.
Definition at line 872 of file engine.hpp.
|
inline |
Current (approximate) live memory (bytes) of the shared input-history backing; 0 for None/Raw.
Definition at line 699 of file engine.hpp.
|
inline |
Hard memory ceiling (bytes) of the shared input-history backing; 0 for None/Raw (no ceiling).
Definition at line 697 of file engine.hpp.
|
inline |
Returns a copy of the most recent manually saved solution.
Definition at line 690 of file engine.hpp.
|
inline |
Audit accessors: the per-depth canonical reference states and the volatile-byte mask (instance-dependent audio-ring residue) captured at floor initialization.
Definition at line 1550 of file engine.hpp.
|
inline |
Audit accessor: per-byte volatile mask (1 = instance-dependent byte) over the reference states.
Definition at line 1553 of file engine.hpp.
|
inline |
Returns the number of states currently held in the state database.
Definition at line 694 of file engine.hpp.
|
inline |
Returns a reference to the owned state database.
Definition at line 632 of file engine.hpp.
|
inline |
Returns the size, in bytes, of a single state as stored in the database.
Definition at line 869 of file engine.hpp.
|
inline |
Returns a copy of the best win state recorded in the current step.
Definition at line 634 of file engine.hpp.
|
inline |
Number of distinct win solutions collected so far (see setWinStateCollection).
Definition at line 637 of file engine.hpp.
|
inline |
Win collection Max Files cap.
Definition at line 651 of file engine.hpp.
|
inline |
Returns the cumulative number of win states found so far.
Definition at line 692 of file engine.hpp.
|
inline |
Resets execution back to step zero and clears all databases and counters.
Re-initializes all runners, the state database, and (when enabled) the hash database; evaluates rules, determines the state type, and computes the reward for the initial state; pushes that initial state into the database; allocates the best-win and manual-save state buffers; and inserts the initial state's hash into the hash database.
Definition at line 222 of file engine.hpp.
|
inline |
True if the shared input-history backing (the Trie) has hit its hard node-storage ceiling.
Definition at line 701 of file engine.hpp.
|
inline |
Whether "Reference Reward Prune" is enabled in the engine configuration (the driver checks this to know it must supply the reference trace).
Definition at line 672 of file engine.hpp.
|
inline |
Whether win collection is enabled.
Definition at line 649 of file engine.hpp.
|
inline |
Whether win collection is enabled and has reached its Max Files cap.
Definition at line 643 of file engine.hpp.
|
inline |
Logs engine status: timing breakdown, throughput, state counts, checkpoints, databases, and detected candidate inputs.
Definition at line 706 of file engine.hpp.
|
inlineprivate |
Advances the runner by one input and classifies/stores the resulting state.
Advances the runner with input, computes and (when enabled) checks the resulting hash for repeats, evaluates rules, applies the checkpoint cutoff, and determines the state type. Win states update _stepBestWinState when their reward is higher; normal states are pushed into the state database; failed/repeated/dropped states return the corresponding result. Also updates the manual-save solution when the game requests it and the reward improves.
| r | The runner holding the base state, advanced by this call. |
| baseStateData | Serialized base state the runner was loaded from (re-loaded on retry paths). |
| input | Index of the input to apply. |
| acc | This thread's accumulator, updated with timing measurements. |
| threadId | Calling thread's id, used for state-database free/allocation operations. |
Definition at line 1180 of file engine.hpp.
|
inlineprivate |
Re-loads the base state, runs a single input, updates per-outcome counters and checkpoint tracking.
| r | The runner to load the base state into and advance. |
| baseStateData | Serialized base state to reload before running the input. |
| input | Index of the input to run. |
| acc | This thread's accumulator to update with the outcome counter. |
| threadId | Calling thread's id, used for state-database free/allocation operations. |
Definition at line 1113 of file engine.hpp.
|
inline |
Runs a single search step: expands all current base states in parallel and advances the databases.
Resets the per-thread accumulators and step-best/manual-save state, runs workerFunction across all threads, reduces the per-thread timers and counters into the shared totals, advances the hash and state databases, updates the manual-save last-rule-id tracking, and recomputes per-step and cumulative timing, throughput, and state-count statistics before incrementing the current step.
Definition at line 424 of file engine.hpp.
|
inline |
Arms reference-reward pruning with the per-depth trace: every produced non-win state whose floor reward falls below the trace at its depth (beyond the configured Tolerance) is dropped instead of stored.
A greedy polish mode: only lineages decisively at or above a known solution survive, so the frontier stays small and exploration goes deep. The pinned reference lineage (see setReferenceStates) is exempt so the reference itself always survives at tolerance 0. Called by the driver once the trace exists.
| trace | Per-depth floor-reward trace of the reference solution (index 0 = the seed state). |
Definition at line 683 of file engine.hpp.
|
inline |
Installs the per-depth canonical reference states (from the driver's floor replay) and derives the volatile-byte mask by re-simulating probe depths and diffing the round-trips.
| states | Per-depth serialized reference states (moved in). |
| refInputs | The reference solution's input strings (used to re-simulate probe depths). |
Definition at line 1559 of file engine.hpp.
|
inline |
Enables win-state collection: every win state's solution is saved to pathPrefix + hex(dedup property bytes) + ".sol", first-seen per key.
Configured by the driver ("Win State Collection" in Driver Configuration); capture happens in the engine because the worker runner holds each win state live at the moment it is produced.
| dedupProps | Names of the game properties whose concatenated bytes form the dedup key. |
| pathPrefix | Prefix (path + basename stem) for the saved .sol files and manifest. |
| maxFiles | Stop collecting (and terminate the run) once this many distinct keys are saved. |
Definition at line 662 of file engine.hpp.
|
inlineprivate |
Worker body executed in parallel by every thread during a step.
Repeatedly pops batches of base states from the state database, loads each into the thread's runner, gathers its allowed and candidate inputs, runs each input via runNewInput, deduplicating candidate inputs per base-state input hash, and returns processed base states to the free queue. Records the thread's total step time into _threadStepTime.
Definition at line 1007 of file engine.hpp.
|
private |
Cumulative hash-DB advance time.
Definition at line 1740 of file engine.hpp.
|
private |
Hash-DB advance time reported for the step.
Definition at line 1739 of file engine.hpp.
|
private |
Serially-measured hash-DB advance time for the step.
Definition at line 1738 of file engine.hpp.
|
private |
Cumulative state-DB advance time.
Definition at line 1745 of file engine.hpp.
|
private |
State-DB advance time reported for the step.
Definition at line 1744 of file engine.hpp.
|
private |
Serially-measured state-DB advance time for the step.
Definition at line 1743 of file engine.hpp.
|
private |
Active base-state pull batch size ("Base State Batch Size").
Definition at line 1503 of file engine.hpp.
|
private |
Highest-reward win seen across ALL steps, and the file its input history is written to at detection time (see the win-state handling in computeState).
Reliable even for terminal win states.
Definition at line 1617 of file engine.hpp.
|
private |
Cumulative per-thread-average hash-calculation time.
Definition at line 1700 of file engine.hpp.
|
private |
Per-thread-average hash-calculation time for the step.
Definition at line 1699 of file engine.hpp.
|
private |
Summed per-thread hash-calculation time for the step.
Definition at line 1698 of file engine.hpp.
|
private |
Cumulative per-thread-average reward-calculation time.
Definition at line 1725 of file engine.hpp.
|
private |
Per-thread-average reward-calculation time for the step.
Definition at line 1724 of file engine.hpp.
|
private |
Summed per-thread reward-calculation time for the step.
Definition at line 1723 of file engine.hpp.
|
private |
Per-base-state-input-hash set of candidate inputs already detected, used to dedup candidate-input probing.
Definition at line 1486 of file engine.hpp.
|
private |
Cumulative per-thread-average hash-checking time.
Definition at line 1705 of file engine.hpp.
|
private |
Per-thread-average hash-checking time for the step.
Definition at line 1704 of file engine.hpp.
|
private |
Summed per-thread hash-checking time for the step.
Definition at line 1703 of file engine.hpp.
|
private |
Step index after which states below _checkpointLevel are dropped.
Definition at line 1631 of file engine.hpp.
|
private |
Highest checkpoint level reached so far.
Definition at line 1629 of file engine.hpp.
|
private |
Serializes checkpoint level rises (rare path).
Definition at line 1632 of file engine.hpp.
|
private |
Tolerance (in steps) associated with the current checkpoint level.
Definition at line 1630 of file engine.hpp.
|
private |
"Log Verbosity": "Compact" collapses the per-step engine block to essentials.
Definition at line 1515 of file engine.hpp.
|
private |
Counter for the current step.
Definition at line 1489 of file engine.hpp.
|
private |
Overall running time of the current step, in microseconds.
Definition at line 1670 of file engine.hpp.
|
private |
Number of states dropped for falling below the reference reward trace (reference pruning).
Definition at line 1647 of file engine.hpp.
|
private |
Counter for states dropped due to not meeting the checkpoint.
Definition at line 1644 of file engine.hpp.
|
private |
Counter for states dropped due to failed serialization.
Definition at line 1641 of file engine.hpp.
|
private |
Counter for states dropped due to lack of free states.
Definition at line 1638 of file engine.hpp.
|
private |
Counter for failed states (reached a point in the game considered a loss).
Definition at line 1653 of file engine.hpp.
|
private |
Full self-contained serialized state size ([hot]+[history]) for standalone snapshot buffers.
Definition at line 1611 of file engine.hpp.
|
private |
Cumulative per-thread-average get-allowed-inputs time.
Definition at line 1730 of file engine.hpp.
|
private |
Per-thread-average get-allowed-inputs time for the step.
Definition at line 1729 of file engine.hpp.
|
private |
Summed per-thread get-allowed-inputs time for the step.
Definition at line 1728 of file engine.hpp.
|
private |
Cumulative per-thread-average get-candidate-inputs time.
Definition at line 1735 of file engine.hpp.
|
private |
Per-thread-average get-candidate-inputs time for the step.
Definition at line 1734 of file engine.hpp.
|
private |
Summed per-thread get-candidate-inputs time for the step.
Definition at line 1733 of file engine.hpp.
|
private |
Cumulative per-thread-average get-free-state time.
Definition at line 1715 of file engine.hpp.
|
private |
Per-thread-average get-free-state time for the step.
Definition at line 1714 of file engine.hpp.
|
private |
Summed per-thread get-free-state time for the step.
Definition at line 1713 of file engine.hpp.
|
private |
Thread-safe hash database used to detect repeated states.
Definition at line 1605 of file engine.hpp.
|
private |
Whether hashing is enabled. Games that cannot loop skip the hash DB to save memory and computation.
Definition at line 1502 of file engine.hpp.
|
private |
N null-advances before hashing (see "Hash Lookahead"); 0 = hash the current state.
Definition at line 1507 of file engine.hpp.
|
private |
The one shared input-history backing (e.g.
the trie) shared by all worker runners; an opaque handle owned for the whole search. Null for the raw/none strategies, which have no shared structure.
Definition at line 1499 of file engine.hpp.
|
private |
Best manually saved solution for the current step.
Definition at line 1623 of file engine.hpp.
|
private |
Currently active manual-save last-rule id across steps.
Definition at line 1625 of file engine.hpp.
|
private |
Path of the most recently activated manual-save solution.
Definition at line 1626 of file engine.hpp.
|
private |
Guards updates to _manualSaveSolution.
Definition at line 1622 of file engine.hpp.
|
private |
Whether the manual-save last-rule id changed this step.
Definition at line 1624 of file engine.hpp.
|
private |
Maximum per-thread step time for the current step.
Definition at line 1673 of file engine.hpp.
|
private |
Id of the thread with the maximum step time.
Definition at line 1674 of file engine.hpp.
|
private |
Counter for normal states.
Definition at line 1659 of file engine.hpp.
|
private |
Cumulative per-thread-average base-state pop time.
Definition at line 1750 of file engine.hpp.
|
private |
Per-thread-average base-state pop time for the step.
Definition at line 1749 of file engine.hpp.
|
private |
Summed per-thread base-state pop time for the step.
Definition at line 1748 of file engine.hpp.
|
private |
Reward bonus for matching the reference at the state's own depth.
Definition at line 1510 of file engine.hpp.
|
private |
Whether reference pinning is active.
Definition at line 1508 of file engine.hpp.
|
private |
Whether hash-matched pin candidates are byte-verified against captured reference states.
Definition at line 1509 of file engine.hpp.
|
private |
Reference state hash at each search depth.
Definition at line 1513 of file engine.hpp.
|
private |
Cumulative reference-pin hits (diagnostic).
Definition at line 1514 of file engine.hpp.
|
private |
How many future depths to also match (being ahead).
Definition at line 1511 of file engine.hpp.
|
private |
Extra bonus per frame ahead of the reference.
Definition at line 1512 of file engine.hpp.
|
private |
Deepest reference depth a pin matched (diagnostic).
Definition at line 1516 of file engine.hpp.
|
private |
Per reference depth: claimed(1)/unclaimed(0), so exactly one copy is pinned.
Definition at line 1519 of file engine.hpp.
|
private |
Reference-depth matches seen (diagnostic).
Definition at line 1518 of file engine.hpp.
|
private |
Whether reference-reward pruning is armed (requested AND trace supplied).
Definition at line 897 of file engine.hpp.
|
private |
Whether "Reference Reward Prune" was enabled in the engine configuration.
Definition at line 894 of file engine.hpp.
|
private |
Prune each state vs the reference this many steps earlier (transient-wait allowance)
Definition at line 904 of file engine.hpp.
|
private |
Allowed slack below the reference trace before a state is pruned.
Definition at line 903 of file engine.hpp.
|
private |
Per-depth floor-reward trace of the reference solution for pruning.
Definition at line 900 of file engine.hpp.
|
private |
Per-depth serialized reference states for EXACT pin verification (empty = hash-only pinning).
Definition at line 1517 of file engine.hpp.
|
private |
1 = byte is instance-residue (excluded from exact pin verification)
Definition at line 1602 of file engine.hpp.
|
private |
Counter for repeated states (detected via hash collision).
Definition at line 1650 of file engine.hpp.
|
private |
Cumulative per-thread-average return-free-state time.
Definition at line 1720 of file engine.hpp.
|
private |
Per-thread-average return-free-state time for the step.
Definition at line 1719 of file engine.hpp.
|
private |
Summed per-thread return-free-state time for the step.
Definition at line 1718 of file engine.hpp.
|
private |
Cumulative per-thread-average rule-checking time.
Definition at line 1710 of file engine.hpp.
|
private |
Per-thread-average rule-checking time for the step.
Definition at line 1709 of file engine.hpp.
|
private |
Summed per-thread rule-checking time for the step.
Definition at line 1708 of file engine.hpp.
|
private |
Collection of runners for the workers to use (one per thread).
Definition at line 1492 of file engine.hpp.
|
private |
Cumulative per-thread-average runner-advance time.
Definition at line 1685 of file engine.hpp.
|
private |
Per-thread-average runner-advance time for the step.
Definition at line 1684 of file engine.hpp.
|
private |
Summed per-thread runner-advance time for the step.
Definition at line 1683 of file engine.hpp.
|
private |
Cumulative per-thread-average state-load time.
Definition at line 1690 of file engine.hpp.
|
private |
Per-thread-average state-load time for the step.
Definition at line 1689 of file engine.hpp.
|
private |
Summed per-thread state-load time for the step.
Definition at line 1688 of file engine.hpp.
|
private |
Cumulative per-thread-average state-save time.
Definition at line 1695 of file engine.hpp.
|
private |
Per-thread-average state-save time for the step.
Definition at line 1694 of file engine.hpp.
|
private |
Summed per-thread state-save time for the step.
Definition at line 1693 of file engine.hpp.
|
private |
Thread-safe state database holding the current and next step's states.
Definition at line 1495 of file engine.hpp.
|
private |
Size of a single state as stored in the database, in bytes.
Definition at line 1608 of file engine.hpp.
|
private |
Base states processed during the current step.
Definition at line 1661 of file engine.hpp.
|
private |
Best win state (by reward) found during the current step.
Definition at line 1614 of file engine.hpp.
|
private |
Guards updates to _stepBestWinState.
Definition at line 1613 of file engine.hpp.
|
private |
States stored this step whose level >= the global checkpoint level.
Definition at line 1633 of file engine.hpp.
|
private |
New states processed during the current step.
Definition at line 1664 of file engine.hpp.
|
private |
Sum of all per-operation cumulative average times.
Definition at line 1753 of file engine.hpp.
|
private |
Sum of all per-operation average times for the current step.
Definition at line 1752 of file engine.hpp.
|
private |
Per-thread accumulators for hot-loop timing/counters, reduced once per step.
Definition at line 1677 of file engine.hpp.
|
private |
Per-thread running time of the current step, in microseconds.
Definition at line 1672 of file engine.hpp.
|
private |
Base states processed across all steps so far.
Definition at line 1662 of file engine.hpp.
|
private |
New states processed across all steps so far.
Definition at line 1665 of file engine.hpp.
|
private |
Total running time so far, in microseconds.
Definition at line 1680 of file engine.hpp.
|
private |
Whether win-state collection is enabled (see setWinStateCollection).
Definition at line 876 of file engine.hpp.
|
private |
Guards _winKeysSeen and the win-collection file writes across worker threads.
Definition at line 891 of file engine.hpp.
|
private |
Maximum number of distinct win solutions to collect before terminating.
Definition at line 885 of file engine.hpp.
|
private |
Path prefix for saved win-collection .sol files and the manifest.
Definition at line 882 of file engine.hpp.
|
private |
Names of the game properties whose bytes form the win-collection dedup key.
Definition at line 879 of file engine.hpp.
|
private |
Dedup keys of the win solutions collected so far.
Definition at line 888 of file engine.hpp.
|
private |
File the best win-state's input history is written to (see _bestWinSolutionReward).
Definition at line 1618 of file engine.hpp.
|
private |
Counter for win states.
Definition at line 1656 of file engine.hpp.
|
staticconstexprprivate |
Number of base states a worker pulls from the state-DB queue per lock acquisition (batch size).
Definition at line 924 of file engine.hpp.