Class: Engine::AnkiStrategy
- Inherits:
-
BaseStrategy
- Object
- Struct
- BaseStrategy
- Engine::AnkiStrategy
- Defined in:
- lib/engine/strategies.rb
Constant Summary collapse
- LEARNING_INTERVALS =
[0, 1, 10, 25].map(&:to_f)
- INITIAL_INTERVALS =
[1, 2].map {|min| min*60*24 }.map(&:to_f)
- LEARNING_STEPS =
LEARNING_INTERVALS.length - 1
Instance Attribute Summary
Attributes inherited from BaseStrategy
Instance Method Summary collapse
- #learning? ⇒ Boolean
- #next_factor ⇒ Object
- #next_interval ⇒ Object
- #next_streak ⇒ Object
-
#pseudo_rand ⇒ Object
Good enough for our purposes, and stable for a given card-state.
- #steps_to_graduation ⇒ Object
Instance Method Details
#learning? ⇒ Boolean
31 32 33 |
# File 'lib/engine/strategies.rb', line 31 def learning? steps_to_graduation > 0 end |
#next_factor ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/engine/strategies.rb', line 43 def next_factor if learning? factor else [factor + [0.15, 0, -0.15, -0.3].fetch() {0}, 1.3].max end end |
#next_interval ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/engine/strategies.rb', line 56 def next_interval if learning? LEARNING_INTERVALS.fetch(-steps_to_graduation) else INITIAL_INTERVALS.fetch(next_streak) do interval * next_factor end end * (0.8 + pseudo_rand * 0.4) # 0.8 - 1.2 end |
#next_streak ⇒ Object
39 40 41 |
# File 'lib/engine/strategies.rb', line 39 def next_streak fail? || learning? ? 0 : streak + 1 end |
#pseudo_rand ⇒ Object
Good enough for our purposes, and stable for a given card-state
52 53 54 |
# File 'lib/engine/strategies.rb', line 52 def pseudo_rand data_point..to_f % 1 end |
#steps_to_graduation ⇒ Object
35 36 37 |
# File 'lib/engine/strategies.rb', line 35 def steps_to_graduation data_points.map(&:rating).inject(LEARNING_STEPS, :-) end |