mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
tweak the hard delay for first step
This commit is contained in:
parent
da5b8cb5b4
commit
ecae43c456
2 changed files with 12 additions and 9 deletions
|
|
@ -490,14 +490,14 @@ def test_nextIvl():
|
||||||
##################################################
|
##################################################
|
||||||
ni = col.sched.nextIvl
|
ni = col.sched.nextIvl
|
||||||
assert ni(c, 1) == 30
|
assert ni(c, 1) == 30
|
||||||
assert ni(c, 2) == (30 + 180) // 2
|
assert ni(c, 2) == round(30 * 0.75 + 180 * 0.25)
|
||||||
assert ni(c, 3) == 180
|
assert ni(c, 3) == 180
|
||||||
assert ni(c, 4) == 4 * 86400
|
assert ni(c, 4) == 4 * 86400
|
||||||
col.sched.answerCard(c, 1)
|
col.sched.answerCard(c, 1)
|
||||||
# cards in learning
|
# cards in learning
|
||||||
##################################################
|
##################################################
|
||||||
assert ni(c, 1) == 30
|
assert ni(c, 1) == 30
|
||||||
assert ni(c, 2) == (30 + 180) // 2
|
assert ni(c, 2) == round(30 * 0.75 + 180 * 0.25)
|
||||||
assert ni(c, 3) == 180
|
assert ni(c, 3) == 180
|
||||||
assert ni(c, 4) == 4 * 86400
|
assert ni(c, 4) == 4 * 86400
|
||||||
col.sched.answerCard(c, 3)
|
col.sched.answerCard(c, 3)
|
||||||
|
|
@ -1177,9 +1177,9 @@ def test_initial_repeat():
|
||||||
|
|
||||||
c = col.sched.getCard()
|
c = col.sched.getCard()
|
||||||
col.sched.answerCard(c, 2)
|
col.sched.answerCard(c, 2)
|
||||||
# should be due in ~ 5.5 mins
|
# should be due in ~ 3.25 mins
|
||||||
expected = time.time() + 5.5 * 60
|
expected = time.time() + 3.25 * 60
|
||||||
assert expected - 10 < c.due < expected * 1.25
|
assert expected - 10 < c.due < expected * 1.25
|
||||||
|
|
||||||
ivl = col.db.scalar("select ivl from revlog")
|
ivl = col.db.scalar("select ivl from revlog")
|
||||||
assert ivl == -5.5 * 60
|
assert ivl == -3.25 * 60
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,11 @@ impl LearningSteps<'_> {
|
||||||
/// at least with reasonable settings.
|
/// at least with reasonable settings.
|
||||||
fn hard_delay_secs_for_first_step(self, again_secs: u32) -> u32 {
|
fn hard_delay_secs_for_first_step(self, again_secs: u32) -> u32 {
|
||||||
if let Some(next) = self.secs_at_index(1) {
|
if let Some(next) = self.secs_at_index(1) {
|
||||||
// average of first (again) and second (good) steps
|
const AGAIN_WEIGHT: f64 = 0.75;
|
||||||
maybe_round_in_days(again_secs.saturating_add(next) / 2)
|
const GOOD_WEIGHT: f64 = 0.25;
|
||||||
|
let hard = (again_secs as f64) * AGAIN_WEIGHT + (next as f64) * GOOD_WEIGHT;
|
||||||
|
let hard = hard.round().max(0.0).min(u32::MAX as f64) as u32;
|
||||||
|
maybe_round_in_days(hard)
|
||||||
} else {
|
} else {
|
||||||
// 50% more than the again secs, but at most one day more
|
// 50% more than the again secs, but at most one day more
|
||||||
// otherwise, a learning step of 3 days and a graduating interval of 4 days e.g.
|
// otherwise, a learning step of 3 days and a graduating interval of 4 days e.g.
|
||||||
|
|
@ -126,10 +129,10 @@ mod test {
|
||||||
None
|
None
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_delay_secs!([1.0, 10.0], 2, Some(60), Some(330), Some(600));
|
assert_delay_secs!([1.0, 10.0], 2, Some(60), Some(195), Some(600));
|
||||||
assert_delay_secs!([1.0, 10.0], 1, Some(60), Some(600), None);
|
assert_delay_secs!([1.0, 10.0], 1, Some(60), Some(600), None);
|
||||||
|
|
||||||
assert_delay_secs!([1.0, 10.0, 100.0], 3, Some(60), Some(330), Some(600));
|
assert_delay_secs!([1.0, 10.0, 100.0], 3, Some(60), Some(195), Some(600));
|
||||||
assert_delay_secs!([1.0, 10.0, 100.0], 2, Some(60), Some(600), Some(6000));
|
assert_delay_secs!([1.0, 10.0, 100.0], 2, Some(60), Some(600), Some(6000));
|
||||||
assert_delay_secs!([1.0, 10.0, 100.0], 1, Some(60), Some(6000), None);
|
assert_delay_secs!([1.0, 10.0, 100.0], 1, Some(60), Some(6000), None);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue