Skip to content

oracular / evaluate

Function: evaluate() ​

ts
function evaluate(
   state, 
   intent, 
   at, 
   opts?
): Evaluation;

Defined in: evaluate.ts:34

predict, shouldReveal and explain in one call, from a single decay pass over the intent. The three results are identical to what the separate functions return for the same inputs; this is the one to call on every event when you need all of them. Read-only.

Parameters ​

ParameterTypeDescription
stateEngineStateThe current state. Not mutated.
intentstringName of an intent declared in the config.
atnumberThe time to evaluate at.
opts?EvaluateOptionsReveal overrides (threshold, z, cooldown, bound) and explain filters (nonZero, limit) in one object.

Returns ​

Evaluation

prediction (as predict), reveal (as shouldReveal) and explanation (as explain with the same filters).

Throws ​

RangeError when intent is not declared in the config.

Throws ​

TypeError when state is not an engine state, at is not finite, or opts is malformed.

Example ​

ts
const { prediction, reveal, explanation } = evaluate(state, 'upgrade', Date.now(), { limit: 3 });
if (reveal) showOffer(explanation[0]?.signal);

Released under the MIT License.