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

Private Types

enum  inputResult_t {
  repeated , droppedNoStorage , droppedFailedSerialization , droppedCheckpoint ,
  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 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

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").
 
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.
 
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.
 
size_t _checkpointLevel
 Highest checkpoint level reached so far.
 
size_t _checkpointTolerance
 Tolerance (in steps) associated with the current checkpoint level.
 
size_t _checkpointCutoff
 Step index after which states below _checkpointLevel are dropped.
 
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 > _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 56 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.

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 701 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 67 of file engine.hpp.

◆ ~Engine()

jaffarPlus::Engine::~Engine ( )
inline

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

Definition at line 518 of file engine.hpp.

Member Function Documentation

◆ getFullStateSize()

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

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

Definition at line 677 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 541 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 539 of file engine.hpp.

◆ getManualSaveSolution()

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

Returns a copy of the most recent manually saved solution.

Definition at line 532 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 536 of file engine.hpp.

◆ getStateDb()

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

Returns a reference to the owned state database.

Definition at line 528 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 674 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 530 of file engine.hpp.

◆ getWinStatesFound()

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

Returns the cumulative number of win states found so far.

Definition at line 534 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 136 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 543 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 548 of file engine.hpp.

◆ runInput()

inputResult_t jaffarPlus::Engine::runInput ( Runner r,
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.
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 936 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 885 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 337 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 779 of file engine.hpp.

Member Data Documentation

◆ _advanceHashDbAverageCumulativeTime

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

Cumulative hash-DB advance time.

Definition at line 1214 of file engine.hpp.

◆ _advanceHashDbAverageTime

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

Hash-DB advance time reported for the step.

Definition at line 1213 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 1212 of file engine.hpp.

◆ _advanceStateDbAverageCumulativeTime

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

Cumulative state-DB advance time.

Definition at line 1219 of file engine.hpp.

◆ _advanceStateDbAverageTime

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

State-DB advance time reported for the step.

Definition at line 1218 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 1217 of file engine.hpp.

◆ _baseStateBatch

size_t jaffarPlus::Engine::_baseStateBatch
private

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

Definition at line 1085 of file engine.hpp.

◆ _calculateHashAverageCumulativeTime

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

Cumulative per-thread-average hash-calculation time.

Definition at line 1174 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 1173 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 1172 of file engine.hpp.

◆ _calculateRewardAverageCumulativeTime

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

Cumulative per-thread-average reward-calculation time.

Definition at line 1199 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 1198 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 1197 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 1068 of file engine.hpp.

◆ _checkHashAverageCumulativeTime

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

Cumulative per-thread-average hash-checking time.

Definition at line 1179 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 1178 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 1177 of file engine.hpp.

◆ _checkpointCutoff

size_t jaffarPlus::Engine::_checkpointCutoff
private

Step index after which states below _checkpointLevel are dropped.

Definition at line 1110 of file engine.hpp.

◆ _checkpointLevel

size_t jaffarPlus::Engine::_checkpointLevel
private

Highest checkpoint level reached so far.

Definition at line 1108 of file engine.hpp.

◆ _checkpointTolerance

size_t jaffarPlus::Engine::_checkpointTolerance
private

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

Definition at line 1109 of file engine.hpp.

◆ _currentStep

size_t jaffarPlus::Engine::_currentStep = 0
private

Counter for the current step.

Definition at line 1071 of file engine.hpp.

◆ _currentStepTime

size_t jaffarPlus::Engine::_currentStepTime
private

Overall running time of the current step, in microseconds.

Definition at line 1144 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 1121 of file engine.hpp.

◆ _droppedStatesFailedSerialization

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

Counter for states dropped due to failed serialization.

Definition at line 1118 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 1115 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 1127 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 1094 of file engine.hpp.

◆ _getAllowedInputsAverageCumulativeTime

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

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

Definition at line 1204 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 1203 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 1202 of file engine.hpp.

◆ _getCandidateInputsAverageCumulativeTime

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

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

Definition at line 1209 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 1208 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 1207 of file engine.hpp.

◆ _getFreeStateAverageCumulativeTime

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

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

Definition at line 1189 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 1188 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 1187 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 1088 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 1084 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 1081 of file engine.hpp.

◆ _manualSaveSolution

manualSaveSolution_t jaffarPlus::Engine::_manualSaveSolution
private

Best manually saved solution for the current step.

Definition at line 1102 of file engine.hpp.

◆ _manualSaveSolutionActiveLastRuleId

ssize_t jaffarPlus::Engine::_manualSaveSolutionActiveLastRuleId
private

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

Definition at line 1104 of file engine.hpp.

◆ _manualSaveSolutionLastPath

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

Path of the most recently activated manual-save solution.

Definition at line 1105 of file engine.hpp.

◆ _manualSaveSolutionLock

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

Guards updates to _manualSaveSolution.

Definition at line 1101 of file engine.hpp.

◆ _manualSaveSolutionUpdatedLastRuleId

bool jaffarPlus::Engine::_manualSaveSolutionUpdatedLastRuleId
private

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

Definition at line 1103 of file engine.hpp.

◆ _maxThreadStepTime

size_t jaffarPlus::Engine::_maxThreadStepTime
private

Maximum per-thread step time for the current step.

Definition at line 1147 of file engine.hpp.

◆ _maxThreadStepTimeThreadId

size_t jaffarPlus::Engine::_maxThreadStepTimeThreadId
private

Id of the thread with the maximum step time.

Definition at line 1148 of file engine.hpp.

◆ _normalStates

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

Counter for normal states.

Definition at line 1133 of file engine.hpp.

◆ _popBaseStateDbAverageCumulativeTime

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

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

Definition at line 1224 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 1223 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 1222 of file engine.hpp.

◆ _repeatedStates

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

Counter for repeated states (detected via hash collision).

Definition at line 1124 of file engine.hpp.

◆ _returnFreeStateAverageCumulativeTime

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

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

Definition at line 1194 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 1193 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 1192 of file engine.hpp.

◆ _ruleCheckingAverageCumulativeTime

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

Cumulative per-thread-average rule-checking time.

Definition at line 1184 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 1183 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 1182 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 1074 of file engine.hpp.

◆ _runnerStateAdvanceAverageCumulativeTime

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

Cumulative per-thread-average runner-advance time.

Definition at line 1159 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 1158 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 1157 of file engine.hpp.

◆ _runnerStateLoadAverageCumulativeTime

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

Cumulative per-thread-average state-load time.

Definition at line 1164 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 1163 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 1162 of file engine.hpp.

◆ _runnerStateSaveAverageCumulativeTime

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

Cumulative per-thread-average state-save time.

Definition at line 1169 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 1168 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 1167 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 1077 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 1091 of file engine.hpp.

◆ _stepBaseStatesProcessed

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

Base states processed during the current step.

Definition at line 1135 of file engine.hpp.

◆ _stepBestWinState

stateInfo_t jaffarPlus::Engine::_stepBestWinState
private

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

Definition at line 1097 of file engine.hpp.

◆ _stepBestWinStateLock

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

Guards updates to _stepBestWinState.

Definition at line 1096 of file engine.hpp.

◆ _stepNewStatesProcessed

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

New states processed during the current step.

Definition at line 1138 of file engine.hpp.

◆ _subTotalAverageCumulativeTime

size_t jaffarPlus::Engine::_subTotalAverageCumulativeTime
private

Sum of all per-operation cumulative average times.

Definition at line 1227 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 1226 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 1151 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 1146 of file engine.hpp.

◆ _totalBaseStatesProcessed

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

Base states processed across all steps so far.

Definition at line 1136 of file engine.hpp.

◆ _totalNewStatesProcessed

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

New states processed across all steps so far.

Definition at line 1139 of file engine.hpp.

◆ _totalRunningTime

size_t jaffarPlus::Engine::_totalRunningTime
private

Total running time so far, in microseconds.

Definition at line 1154 of file engine.hpp.

◆ _winStates

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

Counter for win states.

Definition at line 1130 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 698 of file engine.hpp.


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