// knownAnswer (core/solver.js) against the published data/public/known_answers.json: the guide's recommended answers // are found on the game's full texts, wrong colours and deadly answers are not picked, and unknown screens stay open. const test = require("node:test"); const assert = require("node:assert/strict"); const path = require("node:path"); const S = require("../../core/solver.js"); const known = require(path.join(__dirname, "../../data/public/known_answers.json")); test("the Black: 'Hold its gaze' is the strong pick, 'Lower your eyes' is bad", () => { const r = S.knownAnswer(known, ["Lower your eyes", "Hold its gaze"], { target: "black", sceneColour: "Black" }); assert.equal(r.pick, 1); assert.equal(r.confidence, "strong"); assert.equal(r.choices[0].verdict, "bad"); }); test("a guide paraphrase matches the game's full text", () => { const r = S.knownAnswer(known, ["Climb onto its foreleg", "Reach a hand slowly to touch its talon"], { target: "Red", sceneColour: "Red" }); assert.equal(r.pick, 1); assert.match(r.reason, /Touch its talon/); }); test("the two Greens: the answer for the right Green is not the pick for a Brown target", () => { const offered = ["You respect their nature", "You don't know", "Intellect match"]; assert.equal(S.knownAnswer(known, offered, { target: "Green" }).pick, 0); assert.equal(S.knownAnswer(known, offered, { target: "Brown" }).pick, 2); }); test("a screen nobody has seen: no pick, every choice unknown", () => { const r = S.knownAnswer(known, ["Whistle a tune", "Count the clouds"], { target: "Blue" }); assert.equal(r.pick, null); assert.deepEqual(r.choices.map((c) => c.verdict), ["unknown", "unknown"]); });