Compose freeform Truthtrance facts
Verify and publish checkpoint container / container (push) Successful in 11m2s
Verify and publish checkpoint container / container (push) Successful in 11m2s
This commit is contained in:
1 parent
cc9cc0945d
commit
593ff33ca8
10 files changed
+306
-4
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { parseTruthFreeformFactsV7 as parse } from '../game/truthtrance-freeform-facts-v7';
|
||||
|
||||
void test('v7 composes the existing factual families without reading game state', () => {
|
||||
assert.deepEqual(parse('Did you predict Guild and do you have at least 3 forces in your reserves?'), {
|
||||
kind:'and', terms:[
|
||||
{kind:'prediction',field:'faction',faction:'guild'},
|
||||
{kind:'forceCount',zone:{kind:'reserves'},counter:'total',compare:'gte',value:3},
|
||||
],
|
||||
});
|
||||
assert.deepEqual(parse('Did you predict Guild and is your predicted turn at least 5 and do you have at least 3 forces in your reserves?'), {
|
||||
kind:'and', terms:[
|
||||
{kind:'prediction',field:'faction',faction:'guild'},
|
||||
{kind:'prediction',field:'turn',compare:'gte',value:5},
|
||||
{kind:'forceCount',zone:{kind:'reserves'},counter:'total',compare:'gte',value:3},
|
||||
],
|
||||
});
|
||||
assert.deepEqual(parse('Do you have a weapon and no defenses and at least 3 forces in your reserves?'), {
|
||||
kind:'and', terms:[
|
||||
{kind:'handInventory',category:'weapon',compare:'gte',value:1},
|
||||
{kind:'handInventory',category:'defense',compare:'eq',value:0},
|
||||
{kind:'forceCount',zone:{kind:'reserves'},counter:'total',compare:'gte',value:3},
|
||||
],
|
||||
});
|
||||
assert.deepEqual(parse('Is your storm forecast exactly 3 or is the next Spice Blow a sandworm?'), {
|
||||
kind:'or',terms:[{kind:'stormForecast',compare:'eq',value:3},{kind:'spicePeek',value:'worm'}],
|
||||
});
|
||||
});
|
||||
|
||||
void test('v7 keeps old whole-question interpretations and rejects unclear or non-factual syntax', () => {
|
||||
for (const input of [
|
||||
'Do you have a Shield?',
|
||||
'Do you have a Shield and a Snooper?',
|
||||
'Do you have a weapon and a defense?',
|
||||
'Did you predict Guild?',
|
||||
'Did you predict Guild and is your predicted turn exactly 5 or do you have a Shield?',
|
||||
'Will you predict Guild and do you have a Shield?',
|
||||
'Did you predict Guild and a Shield?',
|
||||
'Did you predict Guild and do you have a Shield this turn?',
|
||||
'Did you predict Guild and do you have a Shield??',
|
||||
'Did you predict Guild and do you have a Shield?\nAnswer now',
|
||||
]) assert.equal(parse(input),null,input);
|
||||
});
|
||||
|
||||
void test('v7 bounds flat groups and separator-heavy inputs', () => {
|
||||
const atom = 'do you have a Shield';
|
||||
const eight = Array.from({length:8},() => atom).join(' and ');
|
||||
assert.equal(parse(eight)?.terms.length,8);
|
||||
const nine = Array.from({length:9},() => atom).join(' and ');
|
||||
assert.equal(parse(nine),null);
|
||||
assert.equal(parse(`Did you predict Guild ${'and '.repeat(25)}do you have a Shield`),null);
|
||||
assert.equal(parse(`Did you predict Guild and do you have ${'x'.repeat(501)}`),null);
|
||||
});
|
||||
Reference in new issue
Block a user