| 17 | */ |
| 18 | |
| 19 | const ce = new ComputeEngine(); |
| 20 | |
| 21 | const evaluate = (mathjson: any): string => |
| 22 | ce.box(mathjson).evaluate().toString(); |
| 23 | |
| 24 | const values = (mathjson: any): (number | undefined)[] => |
| 25 | [...ce.box(mathjson).evaluate().each()].map((x) => x.re); |
| 26 | |
| 27 | /** The `n`-th draw of a frame seeded `seed`, computed independently of the |
| 28 | * engine — the reference the draw-consumption probes compare against. */ |
| 29 | function expectedDraw(seed: number | string, n: number): number { |
| 30 | const [lo, hi] = foldSeed(seed); |
| 31 | return frameDraw(lo, hi, n); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * How many draws `body` consumed inside a frame: evaluate |
| 36 | * `WithRandomSeed(seed, Block(body, Random()))` and identify the trailing |
| 37 | * draw's index in the frame's stream. |