Quantum 3 3.1.0

Public Attributes | Properties | List of all members
Photon.Deterministic.SimulatorContext Class Reference

Carries metadata about the DeterministicSession simulator in the current Update. More...

Public Attributes

Boolean IsRollbackRequired => TargetVerificationTick > PreviousUpdatePredictedTick
 true when verification has reached past the tick the previous Session Update predicted to, which forces a rollback regardless of SkipPredictionRollbackIfPossible or SkipPrediction. More...
 
Int32? LatestTickPredicted => TicksPredicted <= 0 ? null : PredictedFromTick + TicksPredicted
 The frame number of the latest Predicted frame simulated this Update. null if none were Predicted yet. More...
 
Int32? LatestTickSimulated => LatestTickPredicted ?? LatestTickVerified
 The frame number of the latest frame simulated this Update, either Verified or Predicted. null if none were simulated yet. More...
 
Int32? LatestTickVerified => TicksVerified <= 0 ? null : VerifiedFromTick + TicksVerified
 The frame number of the latest Verified frame simulated this Update. null if none were Verified yet. More...
 
Int32? NextTickToPredict => TicksPendingPrediction <= 0 ? null : PredictedFromTick + TicksPredicted + 1
 The next Predicted frame the simulator intends to simulate. null if there are no ticks pending Prediction. More...
 
Int32? NextTickToSimulate => NextTickToVerify ?? NextTickToPredict
 The next frame the simulator intends to simulate, either Verified or Predicted. null if there are no ticks pending simulation. More...
 
Int32? NextTickToVerify => TicksPendingVerification <= 0 ? null : VerifiedFromTick + TicksVerified + 1
 The next Verified frame the simulator intends to simulate. null if there are no ticks pending Verification. More...
 
Int32 PredictedFromTick => WillRollbackPrediction || HasRolledBackPrediction ? TargetVerificationTick : PreviousUpdatePredictedTick
 The tick from which predictions started or will start on this Session Update. By default, this is the TargetVerificationTick, but can instead be the PreviousUpdatePredictedTick when the rollback is skipped. See WillRollbackPrediction. More...
 
Int32 TargetVerificationTick => VerifiedFromTick + TicksToVerify
 The number of the last Verified frame that the simulation intends to simulate on this Session Update. More...
 
Int32 TicksPendingPrediction => TicksToPredict - TicksPredicted
 The number of remaining Predicted frames to be simulated in this Update in order to reach the TicksToPredict count. More...
 
Int32 TicksPendingSimulation => TicksPendingVerification + TicksPendingPrediction
 The total number of remaining frames to be simulated in this Update, both Verified and Predicted. More...
 
Int32 TicksPendingVerification => TicksToVerify - TicksVerified
 The number of remaining Verified frames to be simulated in this Update in order to reach the TicksToVerify count. More...
 
Int32 TicksSimulated => TicksVerified + TicksPredicted
 The total number of frames already simulated in this Session Update, including Verified and Predicted ones. More...
 
Int32 TicksToPredict
 The total number of Predicted frames that will be simulated on this Session Update in order to reach from PredictedFromTick towards the MaxPredictableTick, limited by the rollback window. Zero if the session is stalling or if SkipPrediction is set. More...
 
Boolean WillRollbackPrediction
 Whether the Predicted state will still be rolled back to the Verified state on this Session Update. If a rollback has already occurred, then this is false and HasRolledBackPrediction is true. Rollbacks are only performed when there is a newer Verified state to rollback to (TargetVerificationTick greater than LatestVerifiedRolledBackTo). In that case, rollback is performed if not skipped with SkipPredictionRollbackIfPossible or SkipPrediction, or if IsRollbackRequired. More...
 

Properties

Boolean HasRolledBackPrediction [get]
 If the Predicted state has been rolled back to the Verified state on this Session Update. Always false up to and including the BeforePrediction stage. More...
 
Boolean IsStalling [get]
 
Int32 LatestVerifiedRolledBackTo [get]
 The latest Verified tick that the Predicted state was rolled back to. More...
 
Int32 MaxPredictableTick [get]
 The max tick the simulator has polled inputs for. More...
 
Int32? MaxPredictedTicks [get, set]
 The number of Predicted frames this Session Update may simulate in total, counted from PredictedFromTick. More...
 
Int32 MaxVerifiableTick [get]
 The max tick the simulator is able to verify given the verified and complete input sets available. More...
 
Int32 PreviousUpdatePredictedTick [get]
 The latest predicted tick the simulator had when starting this update, resultant from the previous update loop. More...
 
Boolean SkipPrediction [get, set]
 If the Prediction stage should simulate no frames at all on this Session Update, leaving the Predicted state where the previous Session Update left it, unless IsRollbackRequired. This property defaults to and is reset to false at the beginning of every Session Update. Attempting to modify this value after the BeforePrediction stage has ended will have no effect. More...
 
Boolean SkipPredictionRollbackIfPossible [get, set]
 If a rollback of the Predicted state to the latest Verified state should be skipped, if possible. See IsRollbackRequired for when rollbacks cannot be skipped. This property defaults to and is reset to false at the beginning of every Session Update. Attempting to modify this value after the prediction loop has started will have no effect. More...
 
SimulatorStage Stage [get]
 The current stage of the Simulator.

See also
SimulatorStage
More...
 
Int32? TargetPredictedTick [get, set]
 The last Predicted tick that should be simulated in this Session Update. More...
 
Int32 TicksPredicted [get]
 The number of Predicted frames already simulated in this Session Update. More...
 
Int32 TicksToVerify [get, set]
 The total number of Verified frames that will be simulated on this Session Update. Defaults to the maximum number of verifiable frames clamped by the limit set in DeterministicSession.MaxVerifiedTicksPerUpdate. More...
 
Int32 TicksVerified [get]
 The number of Verified frames already simulated in this Session Update. More...
 
Int32 VerifiedFromTick [get]
 The Verified tick from which the simulator started on this update. More...
 

Detailed Description

Carries metadata about the DeterministicSession simulator in the current Update.

Member Data Documentation

◆ IsRollbackRequired

Boolean Photon.Deterministic.SimulatorContext.IsRollbackRequired => TargetVerificationTick > PreviousUpdatePredictedTick

true when verification has reached past the tick the previous Session Update predicted to, which forces a rollback regardless of SkipPredictionRollbackIfPossible or SkipPrediction.

Predicting a tick the Verified state already passed would need input sets the simulator has already consumed and released. Under normal conditions the Predicted state leads the Verified one and this stays false.

◆ WillRollbackPrediction

Boolean Photon.Deterministic.SimulatorContext.WillRollbackPrediction
Initial value:

Whether the Predicted state will still be rolled back to the Verified state on this Session Update. If a rollback has already occurred, then this is false and HasRolledBackPrediction is true. Rollbacks are only performed when there is a newer Verified state to rollback to (TargetVerificationTick greater than LatestVerifiedRolledBackTo). In that case, rollback is performed if not skipped with SkipPredictionRollbackIfPossible or SkipPrediction, or if IsRollbackRequired.

Until the BeforePrediction stage has ended the value can still change, as both skip flags accept writes up to then. Only when IsRollbackRequired is the rollback certain earlier.

◆ TargetVerificationTick

Int32 Photon.Deterministic.SimulatorContext.TargetVerificationTick => VerifiedFromTick + TicksToVerify

The number of the last Verified frame that the simulation intends to simulate on this Session Update.

◆ PredictedFromTick

Int32 Photon.Deterministic.SimulatorContext.PredictedFromTick => WillRollbackPrediction || HasRolledBackPrediction ? TargetVerificationTick : PreviousUpdatePredictedTick

The tick from which predictions started or will start on this Session Update. By default, this is the TargetVerificationTick, but can instead be the PreviousUpdatePredictedTick when the rollback is skipped. See WillRollbackPrediction.

◆ TicksToPredict

Int32 Photon.Deterministic.SimulatorContext.TicksToPredict
Initial value:
? 0
: Math.Max(Math.Min(MaxPredictableTick, TargetVerificationTick + RollbackWindow) - PredictedFromTick, 0)

The total number of Predicted frames that will be simulated on this Session Update in order to reach from PredictedFromTick towards the MaxPredictableTick, limited by the rollback window. Zero if the session is stalling or if SkipPrediction is set.

◆ TicksSimulated

Int32 Photon.Deterministic.SimulatorContext.TicksSimulated => TicksVerified + TicksPredicted

The total number of frames already simulated in this Session Update, including Verified and Predicted ones.

◆ TicksPendingVerification

Int32 Photon.Deterministic.SimulatorContext.TicksPendingVerification => TicksToVerify - TicksVerified

The number of remaining Verified frames to be simulated in this Update in order to reach the TicksToVerify count.

◆ TicksPendingPrediction

Int32 Photon.Deterministic.SimulatorContext.TicksPendingPrediction => TicksToPredict - TicksPredicted

The number of remaining Predicted frames to be simulated in this Update in order to reach the TicksToPredict count.

◆ TicksPendingSimulation

Int32 Photon.Deterministic.SimulatorContext.TicksPendingSimulation => TicksPendingVerification + TicksPendingPrediction

The total number of remaining frames to be simulated in this Update, both Verified and Predicted.

◆ LatestTickVerified

Int32? Photon.Deterministic.SimulatorContext.LatestTickVerified => TicksVerified <= 0 ? null : VerifiedFromTick + TicksVerified

The frame number of the latest Verified frame simulated this Update. null if none were Verified yet.

◆ LatestTickPredicted

Int32? Photon.Deterministic.SimulatorContext.LatestTickPredicted => TicksPredicted <= 0 ? null : PredictedFromTick + TicksPredicted

The frame number of the latest Predicted frame simulated this Update. null if none were Predicted yet.

◆ LatestTickSimulated

Int32? Photon.Deterministic.SimulatorContext.LatestTickSimulated => LatestTickPredicted ?? LatestTickVerified

The frame number of the latest frame simulated this Update, either Verified or Predicted. null if none were simulated yet.

◆ NextTickToVerify

Int32? Photon.Deterministic.SimulatorContext.NextTickToVerify => TicksPendingVerification <= 0 ? null : VerifiedFromTick + TicksVerified + 1

The next Verified frame the simulator intends to simulate. null if there are no ticks pending Verification.

◆ NextTickToPredict

Int32? Photon.Deterministic.SimulatorContext.NextTickToPredict => TicksPendingPrediction <= 0 ? null : PredictedFromTick + TicksPredicted + 1

The next Predicted frame the simulator intends to simulate. null if there are no ticks pending Prediction.

◆ NextTickToSimulate

Int32? Photon.Deterministic.SimulatorContext.NextTickToSimulate => NextTickToVerify ?? NextTickToPredict

The next frame the simulator intends to simulate, either Verified or Predicted. null if there are no ticks pending simulation.

Property Documentation

◆ MaxVerifiableTick

Int32 Photon.Deterministic.SimulatorContext.MaxVerifiableTick
get

The max tick the simulator is able to verify given the verified and complete input sets available.

◆ MaxPredictableTick

Int32 Photon.Deterministic.SimulatorContext.MaxPredictableTick
get

The max tick the simulator has polled inputs for.

◆ VerifiedFromTick

Int32 Photon.Deterministic.SimulatorContext.VerifiedFromTick
get

The Verified tick from which the simulator started on this update.

◆ PreviousUpdatePredictedTick

Int32 Photon.Deterministic.SimulatorContext.PreviousUpdatePredictedTick
get

The latest predicted tick the simulator had when starting this update, resultant from the previous update loop.

◆ Stage

SimulatorStage Photon.Deterministic.SimulatorContext.Stage
get

The current stage of the Simulator.

See also
SimulatorStage

◆ LatestVerifiedRolledBackTo

Int32 Photon.Deterministic.SimulatorContext.LatestVerifiedRolledBackTo
get

The latest Verified tick that the Predicted state was rolled back to.

Rollbacks are performed before the Prediction loop and this becomes the TargetVerificationTick. When skipping rollbacks with SkipPredictionRollbackIfPossible, this will fall behind the TargetVerificationTick and the window between them tells how outdated is the Verified state that Predictions are based on relative to the latest Verified state.

◆ SkipPredictionRollbackIfPossible

Boolean Photon.Deterministic.SimulatorContext.SkipPredictionRollbackIfPossible
getset

If a rollback of the Predicted state to the latest Verified state should be skipped, if possible. See IsRollbackRequired for when rollbacks cannot be skipped. This property defaults to and is reset to false at the beginning of every Session Update. Attempting to modify this value after the prediction loop has started will have no effect.

Prediction Rollbacks are NOT performed if new Verified frames were not simulated since the last rollback. Skipping prediction rollbacks saves on performance, but tends to cause more mispredictions the larger is the window between the latest Verified state and the last Verified state the Predicted stated was rolled back to. Prediction rollbacks must occur periodically and frequently in order to keep the predictions accurate.

Setting this to true is a request, not a guarantee: it is overridden when verification has advanced past the tick the previous Session Update predicted to. See IsRollbackRequired and WillRollbackPrediction.

Only the rollback is skipped, the Prediction stage still runs. Use SkipPrediction to skip both.

◆ SkipPrediction

Boolean Photon.Deterministic.SimulatorContext.SkipPrediction
getset

If the Prediction stage should simulate no frames at all on this Session Update, leaving the Predicted state where the previous Session Update left it, unless IsRollbackRequired. This property defaults to and is reset to false at the beginning of every Session Update. Attempting to modify this value after the BeforePrediction stage has ended will have no effect.

Skipping predictions also skips the rollback that would precede them, so the Predicted state is not rewound to a tick it had already passed and left there with nothing predicted on top of it.

If IsRollbackRequired, a rollback still occurs. The Predicted state then ends the update holding the Verified state at TargetVerificationTick, the same shape a stalling update produces, so it never trails the Verified state.

A lockstep session (e.g. in Replay mode) never predicts, so this has no effect there.

◆ HasRolledBackPrediction

Boolean Photon.Deterministic.SimulatorContext.HasRolledBackPrediction
get

If the Predicted state has been rolled back to the Verified state on this Session Update. Always false up to and including the BeforePrediction stage.

◆ TicksToVerify

Int32 Photon.Deterministic.SimulatorContext.TicksToVerify
getset

The total number of Verified frames that will be simulated on this Session Update. Defaults to the maximum number of verifiable frames clamped by the limit set in DeterministicSession.MaxVerifiedTicksPerUpdate.

Attempting to modify this value after the Verification stage has ended will have no effect. Values set are clamped between the number of frames already Verified (including a frame still being simulated) and the max number of verifiable frames.

◆ MaxPredictedTicks

Int32? Photon.Deterministic.SimulatorContext.MaxPredictedTicks
getset

The number of Predicted frames this Session Update may simulate in total, counted from PredictedFromTick.

Derived from SkipPrediction and reads 0 while predictions are skipped and Int32.MaxValue otherwise. Writing those two values is still supported and sets the flag; any other value throws, as partial budgets are no longer supported.

Attempting to modify this value after the BeforePrediction stage has ended will have no effect.

Exceptions
ArgumentOutOfRangeExceptionThrown when the value is neither 0 nor Int32.MaxValue.

◆ TargetPredictedTick

Int32? Photon.Deterministic.SimulatorContext.TargetPredictedTick
getset

The last Predicted tick that should be simulated in this Session Update.

Derives from SkipPrediction and reads PredictedFromTick while predictions are skipped and MaxPredictableTick otherwise. Writing those two ticks is still supported and sets the flag; any other value throws, as partial budgets are no longer supported. When both ticks are the same there is nothing left to predict either way, and the write is taken as MaxPredictableTick so that it does not also suppress the rollback.

Attempting to modify this value after the BeforePrediction stage has ended will have no effect.

Exceptions
ArgumentOutOfRangeExceptionThrown when the value is neither MaxPredictableTick nor PredictedFromTick.

◆ TicksVerified

Int32 Photon.Deterministic.SimulatorContext.TicksVerified
get

The number of Verified frames already simulated in this Session Update.

◆ TicksPredicted

Int32 Photon.Deterministic.SimulatorContext.TicksPredicted
get

The number of Predicted frames already simulated in this Session Update.

Photon.Deterministic.SimulatorContext.TargetVerificationTick
Int32 TargetVerificationTick
The number of the last Verified frame that the simulation intends to simulate on this Session Update.
Definition: DeterministicSimulator.Context.cs:320
Photon.Deterministic.SimulatorContext.IsRollbackRequired
Boolean IsRollbackRequired
true when verification has reached past the tick the previous Session Update predicted to,...
Definition: DeterministicSimulator.Context.cs:176
Photon.Deterministic.SimulatorContext.LatestVerifiedRolledBackTo
Int32 LatestVerifiedRolledBackTo
The latest Verified tick that the Predicted state was rolled back to.
Definition: DeterministicSimulator.Context.cs:96
Photon.Deterministic.SimulatorContext.PredictedFromTick
Int32 PredictedFromTick
The tick from which predictions started or will start on this Session Update. By default,...
Definition: DeterministicSimulator.Context.cs:327
Photon.Deterministic.SimulatorContext.SkipPredictionRollbackIfPossible
Boolean SkipPredictionRollbackIfPossible
If a rollback of the Predicted state to the latest Verified state should be skipped,...
Definition: DeterministicSimulator.Context.cs:125
Photon.Deterministic.SimulatorContext.IsStalling
Boolean IsStalling
Definition: DeterministicSimulator.Context.cs:59
Photon.Deterministic.SimulatorContext.SkipPrediction
Boolean SkipPrediction
If the Prediction stage should simulate no frames at all on this Session Update, leaving the Predicte...
Definition: DeterministicSimulator.Context.cs:157
Photon.Deterministic.SimulatorContext.MaxPredictableTick
Int32 MaxPredictableTick
The max tick the simulator has polled inputs for.
Definition: DeterministicSimulator.Context.cs:69