summaryrefslogtreecommitdiffstats
path: root/src/scheduler_brutal.py
blob: d1c98b5a189b4257fbc694f9ad05f01daa56fb61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
"""

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