This commit is contained in:
adueck 2024-12-18 23:17:09 -05:00
parent 9c9fa06588
commit 7b933effa4
2 changed files with 3 additions and 3 deletions

View File

@ -36,6 +36,7 @@ export default function MinimalPairsGame({
minimalPairs.find((x) => x.title === level)?.pairs || [] minimalPairs.find((x) => x.title === level)?.pairs || []
); );
function getQuestion(): Question { function getQuestion(): Question {
console.log("getting question");
const pair = getPair(); const pair = getPair();
const selected: 0 | 1 = randFromArray([0, 1]); const selected: 0 | 1 = randFromArray([0, 1]);
return { pair, selected }; return { pair, selected };

View File

@ -13,9 +13,7 @@ export function makePool<P>(poolBase: P[], removalLaxity = 0): () => P {
let pool = [...poolBase]; let pool = [...poolBase];
function shouldStillKeepIt() { function shouldStillKeepIt() {
if (!removalLaxity) return false; if (!removalLaxity) return false;
const r = Math.random() < removalLaxity / 100; return Math.random() < removalLaxity / 100;
console.log({ r });
return r;
} }
function pickRandomFromPool(): P { function pickRandomFromPool(): P {
// Pick an item from the pool; // Pick an item from the pool;
@ -26,6 +24,7 @@ export function makePool<P>(poolBase: P[], removalLaxity = 0): () => P {
return pick; return pick;
} }
const index = pool.findIndex((v) => equal(v, pick)); const index = pool.findIndex((v) => equal(v, pick));
console.log({ pool });
if (index === -1) throw new Error("could not find pick from pool"); if (index === -1) throw new Error("could not find pick from pool");
pool.splice(index, 1); pool.splice(index, 1);
// If the pool is empty, reset it // If the pool is empty, reset it