@reintent/lib/worlds
One question that splits the worlds `intent.explore` gives: the first choice (in the likeliest world's order) they disagree on, and the mass of each answer.
Type Aliases
Split
type Split = object;Defined in: packages/lib/src/worlds.ts
Properties
Functions
split()
function split(ws): Split | undefined;Defined in: packages/lib/src/worlds.ts
Parameters
| Parameter | Type |
|---|---|
ws | readonly Pick<PossibleWorld, "choices" | "p">[] |
Returns
Split | undefined
Example
import { choices, createIntent, host, useChoose } from '@reintent/core';
import { split } from '@reintent/lib/worlds';
function Brief() {
const form = useChoose(
choices([
{ value: 'story', weight: 0.5 },
{ value: 'demo', weight: 0.3 },
{ value: 'game', weight: 0.2 },
]),
{ of: 'brief', name: 'form' },
);
return host('brief', { form });
}
const intent = createIntent({ program: <Brief /> });
// The one question that tells the likeliest worlds apart, and how likely each answer is.
const q = split(intent.explore({ k: 3 }))!;
console.log(
q.key,
q.options.map((o) => [o.kind, o.p]),
); // → 'brief#form' [ [ 'story', 0.5 ], [ 'demo', 0.3 ], [ 'game', 0.2 ] ]Last updated on
Edit on GitHub