From ecae43c4565d2828990aa27cf20da0832792e651 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Wed, 29 Oct 2025 19:13:16 +0800 Subject: [PATCH] tweak the hard delay for first step --- pylib/tests/test_schedv3.py | 10 +++++----- rslib/src/scheduler/states/steps.rs | 11 +++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pylib/tests/test_schedv3.py b/pylib/tests/test_schedv3.py index a71fa7140..b2f006d0b 100644 --- a/pylib/tests/test_schedv3.py +++ b/pylib/tests/test_schedv3.py @@ -490,14 +490,14 @@ def test_nextIvl(): ################################################## ni = col.sched.nextIvl 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, 4) == 4 * 86400 col.sched.answerCard(c, 1) # cards in learning ################################################## 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, 4) == 4 * 86400 col.sched.answerCard(c, 3) @@ -1177,9 +1177,9 @@ def test_initial_repeat(): c = col.sched.getCard() col.sched.answerCard(c, 2) - # should be due in ~ 5.5 mins - expected = time.time() + 5.5 * 60 + # should be due in ~ 3.25 mins + expected = time.time() + 3.25 * 60 assert expected - 10 < c.due < expected * 1.25 ivl = col.db.scalar("select ivl from revlog") - assert ivl == -5.5 * 60 + assert ivl == -3.25 * 60 diff --git a/rslib/src/scheduler/states/steps.rs b/rslib/src/scheduler/states/steps.rs index 5cb11f930..ccd4d8457 100644 --- a/rslib/src/scheduler/states/steps.rs +++ b/rslib/src/scheduler/states/steps.rs @@ -54,8 +54,11 @@ impl LearningSteps<'_> { /// at least with reasonable settings. fn hard_delay_secs_for_first_step(self, again_secs: u32) -> u32 { if let Some(next) = self.secs_at_index(1) { - // average of first (again) and second (good) steps - maybe_round_in_days(again_secs.saturating_add(next) / 2) + const AGAIN_WEIGHT: f64 = 0.75; + 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 { // 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. @@ -126,10 +129,10 @@ mod test { 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, 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], 1, Some(60), Some(6000), None); }