Module: Fsrs::Scheduler::NewState

Included in:
Fsrs::Scheduler
Defined in:
lib/fsrs/fsrs.rb

Overview

rubocop:disable Style/Documentation

Instance Method Summary collapse

Instance Method Details

#init_difficulty(r) ⇒ Object



330
331
332
# File 'lib/fsrs/fsrs.rb', line 330

def init_difficulty(r)
  (self.p.w[4] - (self.p.w[5] * (r - 3))).clamp(1, 10)
end

#init_ds(s) ⇒ Object



315
316
317
318
319
320
321
322
323
324
# File 'lib/fsrs/fsrs.rb', line 315

def init_ds(s)
  s.again.difficulty = init_difficulty(Rating::AGAIN)
  s.again.stability = init_stability(Rating::AGAIN)
  s.hard.difficulty = init_difficulty(Rating::HARD)
  s.hard.stability = init_stability(Rating::HARD)
  s.good.difficulty = init_difficulty(Rating::GOOD)
  s.good.stability = init_stability(Rating::GOOD)
  s.easy.difficulty = init_difficulty(Rating::EASY)
  s.easy.stability = init_stability(Rating::EASY)
end

#init_stability(r) ⇒ Object



326
327
328
# File 'lib/fsrs/fsrs.rb', line 326

def init_stability(r)
  [self.p.w[r - 1], 0.1].max
end

#schedule_new_state(s, now) ⇒ Object



305
306
307
308
309
310
311
312
313
# File 'lib/fsrs/fsrs.rb', line 305

def schedule_new_state(s, now)
  init_ds(s)
  s.again.due = now + 1.minute
  s.hard.due = now + 5.minutes
  s.good.due = now + 10.minutes
  easy_interval = next_interval(s.easy.stability)
  s.easy.scheduled_days = easy_interval
  s.easy.due = now + easy_interval.days
end