""" """ from card import Card HISTORY_DEPTH = 8 class SchedulerBrutal: def __init__(self, cards: dict[int, Card], state: dict): self._cards = cards self._state = {} # Synchronise state with current card collection for id, card in self._cards.items(): history = state.get(id, [None] * HISTORY_DEPTH) # adjust history if depth has changed if len(history) > HISTORY_DEPTH: history = history[-HISTORY_DEPTH:] elif len(history) < HISTORY_DEPTH: history = ([None] * (HISTORY_DEPTH - len(history))) + history self._state[id] = history def practice(self, size: int) -> dict: pass def test(self, size: int) -> dict: pass def update(self, results: dict[int, int]) -> None: # Add card result to sliding window, or None if card was not shown self._state = {id: history[1:] + [results.get(id, None)] for id, history in self._state.items()} def getState(self) -> dict: return self._state