From 5e7c3ad7ed8c287b538de97d4de3a4df87e9a100 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 8 Feb 2026 21:18:55 +0900 Subject: feat(study): use seeded PRNG for deterministic card shuffle order Shuffle order is now fixed within a study day by seeding mulberry32 with the study day boundary timestamp (3:00 AM rollover). Co-Authored-By: Claude Opus 4.6 --- src/client/atoms/study.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/client/atoms') diff --git a/src/client/atoms/study.ts b/src/client/atoms/study.ts index 324f92e..fca17b7 100644 --- a/src/client/atoms/study.ts +++ b/src/client/atoms/study.ts @@ -1,7 +1,8 @@ import { atomFamily } from "jotai-family"; import { atomWithSuspenseQuery } from "jotai-tanstack-query"; +import { getStartOfStudyDayBoundary } from "../../shared/date"; import { apiClient } from "../api/client"; -import { shuffle } from "../utils/shuffle"; +import { createSeededRandom, shuffle } from "../utils/random"; export interface StudyCard { id: string; @@ -54,9 +55,10 @@ export const studyDataAtomFamily = atomFamily((deckId: string) => cards: StudyCard[]; }>(cardsRes); + const seed = getStartOfStudyDayBoundary().getTime(); return { deck: deckData.deck, - cards: shuffle(cardsData.cards), + cards: shuffle(cardsData.cards, createSeededRandom(seed)), }; }, })), -- cgit v1.3-1-g0d28