import { createMemo, createSignal, For } from "solid-js"; type Scenario = { id: string; prompt: string; correctAmount: 0 | 1; showTruth?: boolean; correctTruth?: boolean; }; const SCENARIOS: Scenario[] = [ { id: "empty-box", prompt: "The box has no marbles inside.", correctAmount: 0, }, { id: "one-apple", prompt: "There is exactly one apple on the plate.", correctAmount: 1, }, { id: "light-off", prompt: "The lamp is off — no light showing.", correctAmount: 0, }, { id: "light-on", prompt: "The lamp is on — one steady light.", correctAmount: 1, }, { id: "statement-false", prompt: "Statement: “The door is open.” (The door is shut.)", correctAmount: 0, showTruth: true, correctTruth: false, }, { id: "statement-true", prompt: "Statement: “There is one bell ringing.” (You hear one bell.)", correctAmount: 1, showTruth: true, correctTruth: true, }, ]; function ZeroOneBoard() { const [index, setIndex] = createSignal(0); const [picked, setPicked] = createSignal<0 | 1 | null>(null); const [truthPicked, setTruthPicked] = createSignal(null); const scenario = createMemo(() => SCENARIOS[index() % SCENARIOS.length]); const atEnd = createMemo(() => index() >= SCENARIOS.length - 1); const amountCorrect = createMemo(() => { const p = picked(); return p !== null && p === scenario().correctAmount; }); const truthCorrect = createMemo(() => { const s = scenario(); if (!s.showTruth) return true; const t = truthPicked(); return t !== null && t === s.correctTruth; }); const answered = createMemo(() => { const s = scenario(); if (picked() === null) return false; if (s.showTruth && truthPicked() === null) return false; return true; }); const allCorrect = createMemo(() => answered() && amountCorrect() && truthCorrect()); const feedback = createMemo(() => { if (!answered()) return "Choose how many, then Next when you are ready."; if (allCorrect()) { return atEnd() ? "Well done — you can tell 0 from 1. Continue to Counting and numbers." : "Correct. Try the next situation."; } if (!amountCorrect()) { return picked() === 0 ? "Not quite — this situation is one, not zero." : "Not quite — this situation is zero, not one."; } return truthPicked() === true ? "Check the statement again — it does not match the world (false)." : "Check the statement again — it matches the world (true)."; }); const pickAmount = (n: 0 | 1) => { setPicked(n); }; const pickTruth = (value: boolean) => { setTruthPicked(value); }; const goNext = () => { if (!answered() || !allCorrect()) return; if (atEnd()) return; setIndex((i) => i + 1); setPicked(null); setTruthPicked(null); }; const resetAll = () => { setIndex(0); setPicked(null); setTruthPicked(null); }; return (

Practice: zero or one

Situation {index() + 1} of {SCENARIOS.length}. Pick the amount that fits. When a statement is shown, also pick true or false.

{scenario().prompt}

{picked() === null ? "?" : picked()}

{scenario().showTruth ? (
) : null}
); } export default ZeroOneBoard;