Ensure good is at least previous+1 even if low hard factor set
https://forums.ankiweb.net/t/anki-scheduler-broken/27987/8
This commit is contained in:
parent
d1abfbc6a1
commit
4a053e5f88
@ -137,21 +137,29 @@ impl ReviewState {
|
||||
fn passing_nonearly_review_intervals(self, ctx: &StateContext) -> (u32, u32, u32) {
|
||||
let current_interval = self.scheduled_days as f32;
|
||||
let days_late = self.days_late().max(0) as f32;
|
||||
|
||||
// hard
|
||||
let hard_factor = ctx.hard_multiplier;
|
||||
let hard_minimum = if hard_factor <= 1.0 {
|
||||
0
|
||||
} else {
|
||||
self.scheduled_days + 1
|
||||
};
|
||||
|
||||
let hard_interval =
|
||||
constrain_passing_interval(ctx, current_interval * hard_factor, hard_minimum, true);
|
||||
// good
|
||||
let good_minimum = if hard_factor <= 1.0 {
|
||||
self.scheduled_days + 1
|
||||
} else {
|
||||
hard_interval + 1
|
||||
};
|
||||
let good_interval = constrain_passing_interval(
|
||||
ctx,
|
||||
(current_interval + days_late / 2.0) * self.ease_factor,
|
||||
hard_interval + 1,
|
||||
good_minimum,
|
||||
true,
|
||||
);
|
||||
// easy
|
||||
let easy_interval = constrain_passing_interval(
|
||||
ctx,
|
||||
(current_interval + days_late) * self.ease_factor * ctx.easy_multiplier,
|
||||
@ -284,4 +292,21 @@ mod test {
|
||||
ctx.maximum_review_interval = 5;
|
||||
assert_eq!(state.passing_review_intervals(&ctx), (5, 5, 5));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn low_hard_multiplier_does_not_pull_good_down() {
|
||||
let mut ctx = StateContext::defaults_for_testing();
|
||||
// our calculations should work correctly with a low ease or non-default
|
||||
// multiplier
|
||||
ctx.hard_multiplier = 0.1;
|
||||
let state = ReviewState {
|
||||
scheduled_days: 2,
|
||||
elapsed_days: 2,
|
||||
ease_factor: 1.3,
|
||||
lapses: 0,
|
||||
leeched: false,
|
||||
};
|
||||
ctx.fuzz_factor = Some(0.0);
|
||||
assert_eq!(state.passing_review_intervals(&ctx), (1, 3, 4));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user