class Engine::AnkiStrategy

Constants

INITIAL_INTERVALS
LEARNING_INTERVALS
LEARNING_STEPS

Public Instance Methods

learning?() click to toggle source
# File lib/engine/strategies.rb, line 31
def learning?
  steps_to_graduation > 0
end
next_factor() click to toggle source
# File lib/engine/strategies.rb, line 43
def next_factor
  if learning?
    factor
  else
    [factor + [0.15, 0, -0.15, -0.3].fetch(neg_rating) {0}, 1.3].max
  end
end
next_interval() click to toggle source
# 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() click to toggle source
# File lib/engine/strategies.rb, line 39
def next_streak
  fail? || learning? ? 0 : streak + 1
end
pseudo_rand() click to toggle source

Good enough for our purposes, and stable for a given card-state

# File lib/engine/strategies.rb, line 52
def pseudo_rand
  data_point.timestamp.to_f % 1
end
steps_to_graduation() click to toggle source
# File lib/engine/strategies.rb, line 35
def steps_to_graduation
  data_points.map(&:rating).inject(LEARNING_STEPS, :-)
end