JaffarPlus
High-performance best-first search optimizer for tool-assisted speedruns
Loading...
Searching...
No Matches
jaffarPlus::Engine Class Referencefinal

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).
 

Detailed Description

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.

Member Enumeration Documentation

◆ inputResult_t

Outcome of running a single input on a base state.

Enumerator
repeated 

Resulting state's hash was already seen.

droppedNoStorage 

No free state slot was available to store the new state.

droppedFailedSerialization 

Pushing the state into the database failed (e.g. serialization error).

droppedCheckpoint 

State did not meet the current checkpoint level past the cutoff step.

droppedBelowReference 

State's reward fell below the reference trace at its depth (beyond the prune tolerance).

failed 

Resulting state was classified as a loss.

normal 

Resulting state was a normal state and was stored.

win 

Resulting state was a win state.

Definition at line 927 of file engine.hpp.

Constructor & Destructor Documentation

◆ Engine()

jaffarPlus::Engine::Engine ( const nlohmann::json &  emulatorConfig,
const nlohmann::json &  gameConfig,
const nlohmann::json &  runnerConfig,
const nlohmann::json &  engineConfig 
)
inline

Constructs the engine, building one runner per worker thread and the state/hash databases.

Parameters
emulatorConfigConfiguration object passed to each runner's emulator.
gameConfigConfiguration object passed to each runner's game.
runnerConfigConfiguration object passed to each runner.
engineConfigEngine configuration containing the "State Database" and "Hash Database" objects.
Exceptions
Alogic error if the configured worker thread count is zero.

Definition at line 71 of file engine.hpp.

◆ ~Engine()

jaffarPlus::Engine::~Engine ( )
inline

Frees the best-win and manual-save state buffers allocated in initialize.

Definition at line 622 of file engine.hpp.

Member Function Documentation

◆ computeStateHash()

jaffarCommon::hash::hash_t jaffarPlus::Engine::computeStateHash ( Runner r)
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.

◆ getFullStateSize()

size_t jaffarPlus::Engine::getFullStateSize ( ) const
inline

Full self-contained state size ([hot]+[history]); for standalone snapshots outside the slabs.

Definition at line 872 of file engine.hpp.

◆ getInputHistoryApproxMemoryBytes()

size_t jaffarPlus::Engine::getInputHistoryApproxMemoryBytes ( ) const
inline

Current (approximate) live memory (bytes) of the shared input-history backing; 0 for None/Raw.

Definition at line 699 of file engine.hpp.

◆ getInputHistoryMaxMemoryBytes()

size_t jaffarPlus::Engine::getInputHistoryMaxMemoryBytes ( ) const
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.

◆ getManualSaveSolution()

auto jaffarPlus::Engine::getManualSaveSolution ( ) const
inline

Returns a copy of the most recent manually saved solution.

Definition at line 690 of file engine.hpp.

◆ getRefStates()

const std::vector< std::vector< uint8_t > > & jaffarPlus::Engine::getRefStates ( ) const
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.

◆ getRefVolatileMask()

const std::vector< uint8_t > & jaffarPlus::Engine::getRefVolatileMask ( ) const
inline

Audit accessor: per-byte volatile mask (1 = instance-dependent byte) over the reference states.

Definition at line 1553 of file engine.hpp.

◆ getStateCount()

auto jaffarPlus::Engine::getStateCount ( ) const
inline

Returns the number of states currently held in the state database.

Definition at line 694 of file engine.hpp.

◆ getStateDb()

auto & jaffarPlus::Engine::getStateDb ( ) const
inline

Returns a reference to the owned state database.

Definition at line 632 of file engine.hpp.

◆ getStateSizeInDatabase()

size_t jaffarPlus::Engine::getStateSizeInDatabase ( ) const
inline

Returns the size, in bytes, of a single state as stored in the database.

Definition at line 869 of file engine.hpp.

◆ getStepBestWinState()

auto jaffarPlus::Engine::getStepBestWinState ( ) const
inline

Returns a copy of the best win state recorded in the current step.

Definition at line 634 of file engine.hpp.

◆ getWinCollectedCount()

size_t jaffarPlus::Engine::getWinCollectedCount ( )
inline

Number of distinct win solutions collected so far (see setWinStateCollection).

Definition at line 637 of file engine.hpp.

◆ getWinCollectionMax()

size_t jaffarPlus::Engine::getWinCollectionMax ( ) const
inline

Win collection Max Files cap.

Definition at line 651 of file engine.hpp.

◆ getWinStatesFound()

auto jaffarPlus::Engine::getWinStatesFound ( ) const
inline

Returns the cumulative number of win states found so far.

Definition at line 692 of file engine.hpp.

◆ initialize()

void jaffarPlus::Engine::initialize ( )
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.

◆ isInputHistoryExhausted()

bool jaffarPlus::Engine::isInputHistoryExhausted ( ) const
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.

◆ isReferencePruneRequested()

bool jaffarPlus::Engine::isReferencePruneRequested ( ) const
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.

◆ isWinCollectionEnabled()

bool jaffarPlus::Engine::isWinCollectionEnabled ( ) const
inline

Whether win collection is enabled.

Definition at line 649 of file engine.hpp.

◆ isWinCollectionFull()

bool jaffarPlus::Engine::isWinCollectionFull ( )
inline

Whether win collection is enabled and has reached its Max Files cap.

Definition at line 643 of file engine.hpp.

◆ printInfo()

void jaffarPlus::Engine::printInfo ( )
inline

Logs engine status: timing breakdown, throughput, state counts, checkpoints, databases, and detected candidate inputs.

Definition at line 706 of file engine.hpp.

◆ runInput()

inputResult_t jaffarPlus::Engine::runInput ( Runner r,
const void *  baseStateData,
const InputSet::inputIndex_t  input,
threadAccumulator_t acc,
const size_t  threadId 
)
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.

Parameters
rThe runner holding the base state, advanced by this call.
baseStateDataSerialized base state the runner was loaded from (re-loaded on retry paths).
inputIndex of the input to apply.
accThis thread's accumulator, updated with timing measurements.
threadIdCalling thread's id, used for state-database free/allocation operations.
Returns
The inputResult_t describing the outcome.

Definition at line 1180 of file engine.hpp.

◆ runNewInput()

inputResult_t jaffarPlus::Engine::runNewInput ( Runner r,
const void *  baseStateData,
const InputSet::inputIndex_t  input,
threadAccumulator_t acc,
const size_t  threadId 
)
inlineprivate

Re-loads the base state, runs a single input, updates per-outcome counters and checkpoint tracking.

Parameters
rThe runner to load the base state into and advance.
baseStateDataSerialized base state to reload before running the input.
inputIndex of the input to run.
accThis thread's accumulator to update with the outcome counter.
threadIdCalling thread's id, used for state-database free/allocation operations.
Returns
The inputResult_t describing the outcome of running the input.

Definition at line 1113 of file engine.hpp.

◆ runStep()

void jaffarPlus::Engine::runStep ( )
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.

◆ setReferencePruneTrace()

void jaffarPlus::Engine::setReferencePruneTrace ( const std::vector< float > &  trace)
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.

Parameters
tracePer-depth floor-reward trace of the reference solution (index 0 = the seed state).

Definition at line 683 of file engine.hpp.

◆ setReferenceStates()

void jaffarPlus::Engine::setReferenceStates ( std::vector< std::vector< uint8_t > > &&  states,
const std::vector< std::string > &  refInputs 
)
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.

Parameters
statesPer-depth serialized reference states (moved in).
refInputsThe reference solution's input strings (used to re-simulate probe depths).

Definition at line 1559 of file engine.hpp.

◆ setWinStateCollection()

void jaffarPlus::Engine::setWinStateCollection ( const std::vector< std::string > &  dedupProps,
const std::string &  pathPrefix,
const size_t  maxFiles 
)
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.

Parameters
dedupPropsNames of the game properties whose concatenated bytes form the dedup key.
pathPrefixPrefix (path + basename stem) for the saved .sol files and manifest.
maxFilesStop collecting (and terminate the run) once this many distinct keys are saved.

Definition at line 662 of file engine.hpp.

◆ workerFunction()

void jaffarPlus::Engine::workerFunction ( )
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.

Member Data Documentation

◆ _advanceHashDbAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_advanceHashDbAverageCumulativeTime
private

Cumulative hash-DB advance time.

Definition at line 1740 of file engine.hpp.

◆ _advanceHashDbAverageTime

std::atomic<size_t> jaffarPlus::Engine::_advanceHashDbAverageTime
private

Hash-DB advance time reported for the step.

Definition at line 1739 of file engine.hpp.

◆ _advanceHashDbThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_advanceHashDbThreadRawTime
private

Serially-measured hash-DB advance time for the step.

Definition at line 1738 of file engine.hpp.

◆ _advanceStateDbAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_advanceStateDbAverageCumulativeTime
private

Cumulative state-DB advance time.

Definition at line 1745 of file engine.hpp.

◆ _advanceStateDbAverageTime

std::atomic<size_t> jaffarPlus::Engine::_advanceStateDbAverageTime
private

State-DB advance time reported for the step.

Definition at line 1744 of file engine.hpp.

◆ _advanceStateDbThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_advanceStateDbThreadRawTime
private

Serially-measured state-DB advance time for the step.

Definition at line 1743 of file engine.hpp.

◆ _baseStateBatch

size_t jaffarPlus::Engine::_baseStateBatch
private

Active base-state pull batch size ("Base State Batch Size").

Definition at line 1503 of file engine.hpp.

◆ _bestWinSolutionReward

float jaffarPlus::Engine::_bestWinSolutionReward = -std::numeric_limits<float>::infinity()
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.

◆ _calculateHashAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_calculateHashAverageCumulativeTime
private

Cumulative per-thread-average hash-calculation time.

Definition at line 1700 of file engine.hpp.

◆ _calculateHashAverageTime

std::atomic<size_t> jaffarPlus::Engine::_calculateHashAverageTime
private

Per-thread-average hash-calculation time for the step.

Definition at line 1699 of file engine.hpp.

◆ _calculateHashThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_calculateHashThreadRawTime
private

Summed per-thread hash-calculation time for the step.

Definition at line 1698 of file engine.hpp.

◆ _calculateRewardAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_calculateRewardAverageCumulativeTime
private

Cumulative per-thread-average reward-calculation time.

Definition at line 1725 of file engine.hpp.

◆ _calculateRewardAverageTime

std::atomic<size_t> jaffarPlus::Engine::_calculateRewardAverageTime
private

Per-thread-average reward-calculation time for the step.

Definition at line 1724 of file engine.hpp.

◆ _calculateRewardThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_calculateRewardThreadRawTime
private

Summed per-thread reward-calculation time for the step.

Definition at line 1723 of file engine.hpp.

◆ _candidateInputsDetected

jaffarCommon::concurrent::HashMap_t<jaffarCommon::hash::hash_t, jaffarCommon::concurrent::HashSet_t<InputSet::inputIndex_t> > jaffarPlus::Engine::_candidateInputsDetected
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.

◆ _checkHashAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_checkHashAverageCumulativeTime
private

Cumulative per-thread-average hash-checking time.

Definition at line 1705 of file engine.hpp.

◆ _checkHashAverageTime

std::atomic<size_t> jaffarPlus::Engine::_checkHashAverageTime
private

Per-thread-average hash-checking time for the step.

Definition at line 1704 of file engine.hpp.

◆ _checkHashThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_checkHashThreadRawTime
private

Summed per-thread hash-checking time for the step.

Definition at line 1703 of file engine.hpp.

◆ _checkpointCutoff

std::atomic<size_t> jaffarPlus::Engine::_checkpointCutoff
private

Step index after which states below _checkpointLevel are dropped.

Definition at line 1631 of file engine.hpp.

◆ _checkpointLevel

std::atomic<size_t> jaffarPlus::Engine::_checkpointLevel
private

Highest checkpoint level reached so far.

Definition at line 1629 of file engine.hpp.

◆ _checkpointMutex

std::mutex jaffarPlus::Engine::_checkpointMutex
private

Serializes checkpoint level rises (rare path).

Definition at line 1632 of file engine.hpp.

◆ _checkpointTolerance

std::atomic<size_t> jaffarPlus::Engine::_checkpointTolerance
private

Tolerance (in steps) associated with the current checkpoint level.

Definition at line 1630 of file engine.hpp.

◆ _compactLog

bool jaffarPlus::Engine::_compactLog = false
private

"Log Verbosity": "Compact" collapses the per-step engine block to essentials.

Definition at line 1515 of file engine.hpp.

◆ _currentStep

size_t jaffarPlus::Engine::_currentStep = 0
private

Counter for the current step.

Definition at line 1489 of file engine.hpp.

◆ _currentStepTime

size_t jaffarPlus::Engine::_currentStepTime
private

Overall running time of the current step, in microseconds.

Definition at line 1670 of file engine.hpp.

◆ _droppedStatesBelowReference

std::atomic<size_t> jaffarPlus::Engine::_droppedStatesBelowReference
private

Number of states dropped for falling below the reference reward trace (reference pruning).

Definition at line 1647 of file engine.hpp.

◆ _droppedStatesCheckpoint

std::atomic<size_t> jaffarPlus::Engine::_droppedStatesCheckpoint
private

Counter for states dropped due to not meeting the checkpoint.

Definition at line 1644 of file engine.hpp.

◆ _droppedStatesFailedSerialization

std::atomic<size_t> jaffarPlus::Engine::_droppedStatesFailedSerialization
private

Counter for states dropped due to failed serialization.

Definition at line 1641 of file engine.hpp.

◆ _droppedStatesNoStorage

std::atomic<size_t> jaffarPlus::Engine::_droppedStatesNoStorage
private

Counter for states dropped due to lack of free states.

Definition at line 1638 of file engine.hpp.

◆ _failedStates

std::atomic<size_t> jaffarPlus::Engine::_failedStates
private

Counter for failed states (reached a point in the game considered a loss).

Definition at line 1653 of file engine.hpp.

◆ _fullStateSize

size_t jaffarPlus::Engine::_fullStateSize
private

Full self-contained serialized state size ([hot]+[history]) for standalone snapshot buffers.

Definition at line 1611 of file engine.hpp.

◆ _getAllowedInputsAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_getAllowedInputsAverageCumulativeTime
private

Cumulative per-thread-average get-allowed-inputs time.

Definition at line 1730 of file engine.hpp.

◆ _getAllowedInputsAverageTime

std::atomic<size_t> jaffarPlus::Engine::_getAllowedInputsAverageTime
private

Per-thread-average get-allowed-inputs time for the step.

Definition at line 1729 of file engine.hpp.

◆ _getAllowedInputsThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_getAllowedInputsThreadRawTime
private

Summed per-thread get-allowed-inputs time for the step.

Definition at line 1728 of file engine.hpp.

◆ _getCandidateInputsAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_getCandidateInputsAverageCumulativeTime
private

Cumulative per-thread-average get-candidate-inputs time.

Definition at line 1735 of file engine.hpp.

◆ _getCandidateInputsAverageTime

std::atomic<size_t> jaffarPlus::Engine::_getCandidateInputsAverageTime
private

Per-thread-average get-candidate-inputs time for the step.

Definition at line 1734 of file engine.hpp.

◆ _getCandidateInputsThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_getCandidateInputsThreadRawTime
private

Summed per-thread get-candidate-inputs time for the step.

Definition at line 1733 of file engine.hpp.

◆ _getFreeStateAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_getFreeStateAverageCumulativeTime
private

Cumulative per-thread-average get-free-state time.

Definition at line 1715 of file engine.hpp.

◆ _getFreeStateAverageTime

std::atomic<size_t> jaffarPlus::Engine::_getFreeStateAverageTime
private

Per-thread-average get-free-state time for the step.

Definition at line 1714 of file engine.hpp.

◆ _getFreeStateThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_getFreeStateThreadRawTime
private

Summed per-thread get-free-state time for the step.

Definition at line 1713 of file engine.hpp.

◆ _hashDb

std::unique_ptr<jaffarPlus::HashDb> jaffarPlus::Engine::_hashDb
private

Thread-safe hash database used to detect repeated states.

Definition at line 1605 of file engine.hpp.

◆ _hashDbEnabled

bool jaffarPlus::Engine::_hashDbEnabled
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.

◆ _hashLookahead

size_t jaffarPlus::Engine::_hashLookahead = 0
private

N null-advances before hashing (see "Hash Lookahead"); 0 = hash the current state.

Definition at line 1507 of file engine.hpp.

◆ _inputHistoryBacking

std::shared_ptr<void> jaffarPlus::Engine::_inputHistoryBacking
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.

◆ _manualSaveSolution

manualSaveSolution_t jaffarPlus::Engine::_manualSaveSolution
private

Best manually saved solution for the current step.

Definition at line 1623 of file engine.hpp.

◆ _manualSaveSolutionActiveLastRuleId

ssize_t jaffarPlus::Engine::_manualSaveSolutionActiveLastRuleId
private

Currently active manual-save last-rule id across steps.

Definition at line 1625 of file engine.hpp.

◆ _manualSaveSolutionLastPath

std::string jaffarPlus::Engine::_manualSaveSolutionLastPath = ""
private

Path of the most recently activated manual-save solution.

Definition at line 1626 of file engine.hpp.

◆ _manualSaveSolutionLock

std::mutex jaffarPlus::Engine::_manualSaveSolutionLock
private

Guards updates to _manualSaveSolution.

Definition at line 1622 of file engine.hpp.

◆ _manualSaveSolutionUpdatedLastRuleId

bool jaffarPlus::Engine::_manualSaveSolutionUpdatedLastRuleId
private

Whether the manual-save last-rule id changed this step.

Definition at line 1624 of file engine.hpp.

◆ _maxThreadStepTime

size_t jaffarPlus::Engine::_maxThreadStepTime
private

Maximum per-thread step time for the current step.

Definition at line 1673 of file engine.hpp.

◆ _maxThreadStepTimeThreadId

size_t jaffarPlus::Engine::_maxThreadStepTimeThreadId
private

Id of the thread with the maximum step time.

Definition at line 1674 of file engine.hpp.

◆ _normalStates

std::atomic<size_t> jaffarPlus::Engine::_normalStates
private

Counter for normal states.

Definition at line 1659 of file engine.hpp.

◆ _popBaseStateDbAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_popBaseStateDbAverageCumulativeTime
private

Cumulative per-thread-average base-state pop time.

Definition at line 1750 of file engine.hpp.

◆ _popBaseStateDbAverageTime

std::atomic<size_t> jaffarPlus::Engine::_popBaseStateDbAverageTime
private

Per-thread-average base-state pop time for the step.

Definition at line 1749 of file engine.hpp.

◆ _popBaseStateDbThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_popBaseStateDbThreadRawTime
private

Summed per-thread base-state pop time for the step.

Definition at line 1748 of file engine.hpp.

◆ _refPinBonus

float jaffarPlus::Engine::_refPinBonus = 0.0f
private

Reward bonus for matching the reference at the state's own depth.

Definition at line 1510 of file engine.hpp.

◆ _refPinEnabled

bool jaffarPlus::Engine::_refPinEnabled = false
private

Whether reference pinning is active.

Definition at line 1508 of file engine.hpp.

◆ _refPinExactVerify

bool jaffarPlus::Engine::_refPinExactVerify = true
private

Whether hash-matched pin candidates are byte-verified against captured reference states.

Definition at line 1509 of file engine.hpp.

◆ _refPinHashes

std::vector<jaffarCommon::hash::hash_t> jaffarPlus::Engine::_refPinHashes
private

Reference state hash at each search depth.

Definition at line 1513 of file engine.hpp.

◆ _refPinHits

std::atomic<size_t> jaffarPlus::Engine::_refPinHits {0}
private

Cumulative reference-pin hits (diagnostic).

Definition at line 1514 of file engine.hpp.

◆ _refPinLookahead

size_t jaffarPlus::Engine::_refPinLookahead = 0
private

How many future depths to also match (being ahead).

Definition at line 1511 of file engine.hpp.

◆ _refPinLookaheadBonus

float jaffarPlus::Engine::_refPinLookaheadBonus = 0.0f
private

Extra bonus per frame ahead of the reference.

Definition at line 1512 of file engine.hpp.

◆ _refPinMaxDepthHit

std::atomic<size_t> jaffarPlus::Engine::_refPinMaxDepthHit {0}
private

Deepest reference depth a pin matched (diagnostic).

Definition at line 1516 of file engine.hpp.

◆ _refPinnedAtDepth

std::unique_ptr<std::atomic<uint8_t>[]> jaffarPlus::Engine::_refPinnedAtDepth
private

Per reference depth: claimed(1)/unclaimed(0), so exactly one copy is pinned.

Definition at line 1519 of file engine.hpp.

◆ _refPinSeenPreDedup

std::atomic<size_t> jaffarPlus::Engine::_refPinSeenPreDedup {0}
private

Reference-depth matches seen (diagnostic).

Definition at line 1518 of file engine.hpp.

◆ _refPruneEnabled

bool jaffarPlus::Engine::_refPruneEnabled = false
private

Whether reference-reward pruning is armed (requested AND trace supplied).

Definition at line 897 of file engine.hpp.

◆ _refPruneRequested

bool jaffarPlus::Engine::_refPruneRequested = false
private

Whether "Reference Reward Prune" was enabled in the engine configuration.

Definition at line 894 of file engine.hpp.

◆ _refPruneStepGrace

size_t jaffarPlus::Engine::_refPruneStepGrace = 0
private

Prune each state vs the reference this many steps earlier (transient-wait allowance)

Definition at line 904 of file engine.hpp.

◆ _refPruneTolerance

float jaffarPlus::Engine::_refPruneTolerance = 0.0f
private

Allowed slack below the reference trace before a state is pruned.

Definition at line 903 of file engine.hpp.

◆ _refPruneTrace

std::vector<float> jaffarPlus::Engine::_refPruneTrace
private

Per-depth floor-reward trace of the reference solution for pruning.

Definition at line 900 of file engine.hpp.

◆ _refStates

std::vector<std::vector<uint8_t> > jaffarPlus::Engine::_refStates
private

Per-depth serialized reference states for EXACT pin verification (empty = hash-only pinning).

Definition at line 1517 of file engine.hpp.

◆ _refVolatileMask

std::vector<uint8_t> jaffarPlus::Engine::_refVolatileMask
private

1 = byte is instance-residue (excluded from exact pin verification)

Definition at line 1602 of file engine.hpp.

◆ _repeatedStates

std::atomic<size_t> jaffarPlus::Engine::_repeatedStates
private

Counter for repeated states (detected via hash collision).

Definition at line 1650 of file engine.hpp.

◆ _returnFreeStateAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_returnFreeStateAverageCumulativeTime
private

Cumulative per-thread-average return-free-state time.

Definition at line 1720 of file engine.hpp.

◆ _returnFreeStateAverageTime

std::atomic<size_t> jaffarPlus::Engine::_returnFreeStateAverageTime
private

Per-thread-average return-free-state time for the step.

Definition at line 1719 of file engine.hpp.

◆ _returnFreeStateThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_returnFreeStateThreadRawTime
private

Summed per-thread return-free-state time for the step.

Definition at line 1718 of file engine.hpp.

◆ _ruleCheckingAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_ruleCheckingAverageCumulativeTime
private

Cumulative per-thread-average rule-checking time.

Definition at line 1710 of file engine.hpp.

◆ _ruleCheckingAverageTime

std::atomic<size_t> jaffarPlus::Engine::_ruleCheckingAverageTime
private

Per-thread-average rule-checking time for the step.

Definition at line 1709 of file engine.hpp.

◆ _ruleCheckingThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_ruleCheckingThreadRawTime
private

Summed per-thread rule-checking time for the step.

Definition at line 1708 of file engine.hpp.

◆ _runners

std::vector<std::unique_ptr<Runner> > jaffarPlus::Engine::_runners
private

Collection of runners for the workers to use (one per thread).

Definition at line 1492 of file engine.hpp.

◆ _runnerStateAdvanceAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_runnerStateAdvanceAverageCumulativeTime
private

Cumulative per-thread-average runner-advance time.

Definition at line 1685 of file engine.hpp.

◆ _runnerStateAdvanceAverageTime

std::atomic<size_t> jaffarPlus::Engine::_runnerStateAdvanceAverageTime
private

Per-thread-average runner-advance time for the step.

Definition at line 1684 of file engine.hpp.

◆ _runnerStateAdvanceThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_runnerStateAdvanceThreadRawTime
private

Summed per-thread runner-advance time for the step.

Definition at line 1683 of file engine.hpp.

◆ _runnerStateLoadAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_runnerStateLoadAverageCumulativeTime
private

Cumulative per-thread-average state-load time.

Definition at line 1690 of file engine.hpp.

◆ _runnerStateLoadAverageTime

std::atomic<size_t> jaffarPlus::Engine::_runnerStateLoadAverageTime
private

Per-thread-average state-load time for the step.

Definition at line 1689 of file engine.hpp.

◆ _runnerStateLoadThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_runnerStateLoadThreadRawTime
private

Summed per-thread state-load time for the step.

Definition at line 1688 of file engine.hpp.

◆ _runnerStateSaveAverageCumulativeTime

std::atomic<size_t> jaffarPlus::Engine::_runnerStateSaveAverageCumulativeTime
private

Cumulative per-thread-average state-save time.

Definition at line 1695 of file engine.hpp.

◆ _runnerStateSaveAverageTime

std::atomic<size_t> jaffarPlus::Engine::_runnerStateSaveAverageTime
private

Per-thread-average state-save time for the step.

Definition at line 1694 of file engine.hpp.

◆ _runnerStateSaveThreadRawTime

std::atomic<size_t> jaffarPlus::Engine::_runnerStateSaveThreadRawTime
private

Summed per-thread state-save time for the step.

Definition at line 1693 of file engine.hpp.

◆ _stateDb

std::unique_ptr<jaffarPlus::StateDb> jaffarPlus::Engine::_stateDb
private

Thread-safe state database holding the current and next step's states.

Definition at line 1495 of file engine.hpp.

◆ _stateSizeInDatabase

size_t jaffarPlus::Engine::_stateSizeInDatabase
private

Size of a single state as stored in the database, in bytes.

Definition at line 1608 of file engine.hpp.

◆ _stepBaseStatesProcessed

std::atomic<size_t> jaffarPlus::Engine::_stepBaseStatesProcessed
private

Base states processed during the current step.

Definition at line 1661 of file engine.hpp.

◆ _stepBestWinState

stateInfo_t jaffarPlus::Engine::_stepBestWinState
private

Best win state (by reward) found during the current step.

Definition at line 1614 of file engine.hpp.

◆ _stepBestWinStateLock

std::mutex jaffarPlus::Engine::_stepBestWinStateLock
private

Guards updates to _stepBestWinState.

Definition at line 1613 of file engine.hpp.

◆ _stepMaxLevelStored

std::atomic<size_t> jaffarPlus::Engine::_stepMaxLevelStored
private

States stored this step whose level >= the global checkpoint level.

Definition at line 1633 of file engine.hpp.

◆ _stepNewStatesProcessed

std::atomic<size_t> jaffarPlus::Engine::_stepNewStatesProcessed
private

New states processed during the current step.

Definition at line 1664 of file engine.hpp.

◆ _subTotalAverageCumulativeTime

size_t jaffarPlus::Engine::_subTotalAverageCumulativeTime
private

Sum of all per-operation cumulative average times.

Definition at line 1753 of file engine.hpp.

◆ _subTotalAverageTime

size_t jaffarPlus::Engine::_subTotalAverageTime
private

Sum of all per-operation average times for the current step.

Definition at line 1752 of file engine.hpp.

◆ _threadAccumulators

std::vector<threadAccumulator_t> jaffarPlus::Engine::_threadAccumulators
private

Per-thread accumulators for hot-loop timing/counters, reduced once per step.

Definition at line 1677 of file engine.hpp.

◆ _threadStepTime

std::vector<size_t> jaffarPlus::Engine::_threadStepTime
private

Per-thread running time of the current step, in microseconds.

Definition at line 1672 of file engine.hpp.

◆ _totalBaseStatesProcessed

std::atomic<size_t> jaffarPlus::Engine::_totalBaseStatesProcessed
private

Base states processed across all steps so far.

Definition at line 1662 of file engine.hpp.

◆ _totalNewStatesProcessed

std::atomic<size_t> jaffarPlus::Engine::_totalNewStatesProcessed
private

New states processed across all steps so far.

Definition at line 1665 of file engine.hpp.

◆ _totalRunningTime

size_t jaffarPlus::Engine::_totalRunningTime
private

Total running time so far, in microseconds.

Definition at line 1680 of file engine.hpp.

◆ _winCollectEnabled

bool jaffarPlus::Engine::_winCollectEnabled = false
private

Whether win-state collection is enabled (see setWinStateCollection).

Definition at line 876 of file engine.hpp.

◆ _winCollectLock

std::mutex jaffarPlus::Engine::_winCollectLock
private

Guards _winKeysSeen and the win-collection file writes across worker threads.

Definition at line 891 of file engine.hpp.

◆ _winCollectMax

size_t jaffarPlus::Engine::_winCollectMax = 1000
private

Maximum number of distinct win solutions to collect before terminating.

Definition at line 885 of file engine.hpp.

◆ _winCollectPrefix

std::string jaffarPlus::Engine::_winCollectPrefix
private

Path prefix for saved win-collection .sol files and the manifest.

Definition at line 882 of file engine.hpp.

◆ _winDedupPropNames

std::vector<std::string> jaffarPlus::Engine::_winDedupPropNames
private

Names of the game properties whose bytes form the win-collection dedup key.

Definition at line 879 of file engine.hpp.

◆ _winKeysSeen

std::set<std::string> jaffarPlus::Engine::_winKeysSeen
private

Dedup keys of the win solutions collected so far.

Definition at line 888 of file engine.hpp.

◆ _winSolutionPath

std::string jaffarPlus::Engine::_winSolutionPath = "/tmp/jaffar.winsolution.sol"
private

File the best win-state's input history is written to (see _bestWinSolutionReward).

Definition at line 1618 of file engine.hpp.

◆ _winStates

std::atomic<size_t> jaffarPlus::Engine::_winStates
private

Counter for win states.

Definition at line 1656 of file engine.hpp.

◆ BASE_STATE_BATCH_MAX

constexpr size_t jaffarPlus::Engine::BASE_STATE_BATCH_MAX = 16
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.


The documentation for this class was generated from the following file: