mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Fix/disable FSRS short-term scheduler if w[17] or w[18] is zero (#3788)
* Fix/disable FSRS short-term scheduler if w[17] or w[18] is zero * fix bracket * rename variable
This commit is contained in:
parent
2cbcd79a84
commit
54679c5779
5 changed files with 29 additions and 8 deletions
|
@ -74,6 +74,7 @@ struct CardStateUpdater {
|
|||
/// Set if FSRS is enabled.
|
||||
desired_retention: Option<f32>,
|
||||
fsrs_short_term_with_steps: bool,
|
||||
fsrs_allow_short_term: bool,
|
||||
}
|
||||
|
||||
impl CardStateUpdater {
|
||||
|
@ -112,6 +113,7 @@ impl CardStateUpdater {
|
|||
},
|
||||
fsrs_next_states: self.fsrs_next_states.clone(),
|
||||
fsrs_short_term_with_steps_enabled: self.fsrs_short_term_with_steps,
|
||||
fsrs_allow_short_term: self.fsrs_allow_short_term,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -462,6 +464,16 @@ impl Collection {
|
|||
let desired_retention = fsrs_enabled.then_some(config.inner.desired_retention);
|
||||
let fsrs_short_term_with_steps =
|
||||
self.get_config_bool(BoolKey::FsrsShortTermWithStepsEnabled);
|
||||
let fsrs_allow_short_term = if fsrs_enabled {
|
||||
let params = config.fsrs_params();
|
||||
if params.len() == 19 {
|
||||
params[17] > 0.0 && params[18] > 0.0
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
false
|
||||
};
|
||||
Ok(CardStateUpdater {
|
||||
fuzz_seed: get_fuzz_seed(&card, false),
|
||||
card,
|
||||
|
@ -472,6 +484,7 @@ impl Collection {
|
|||
fsrs_next_states,
|
||||
desired_retention,
|
||||
fsrs_short_term_with_steps,
|
||||
fsrs_allow_short_term,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,8 @@ impl LearnState {
|
|||
let (interval, short_term) = if let Some(states) = &ctx.fsrs_next_states {
|
||||
(
|
||||
states.again.interval,
|
||||
(ctx.fsrs_short_term_with_steps_enabled || ctx.steps.is_empty())
|
||||
ctx.fsrs_allow_short_term
|
||||
&& (ctx.fsrs_short_term_with_steps_enabled || ctx.steps.is_empty())
|
||||
&& states.again.interval < 0.5,
|
||||
)
|
||||
} else {
|
||||
|
@ -97,7 +98,8 @@ impl LearnState {
|
|||
let (interval, short_term) = if let Some(states) = &ctx.fsrs_next_states {
|
||||
(
|
||||
states.hard.interval,
|
||||
(ctx.fsrs_short_term_with_steps_enabled || ctx.steps.is_empty())
|
||||
ctx.fsrs_allow_short_term
|
||||
&& (ctx.fsrs_short_term_with_steps_enabled || ctx.steps.is_empty())
|
||||
&& states.hard.interval < 0.5,
|
||||
)
|
||||
} else {
|
||||
|
@ -143,7 +145,8 @@ impl LearnState {
|
|||
let (interval, short_term) = if let Some(states) = &ctx.fsrs_next_states {
|
||||
(
|
||||
states.good.interval,
|
||||
(ctx.fsrs_short_term_with_steps_enabled || ctx.steps.is_empty())
|
||||
ctx.fsrs_allow_short_term
|
||||
&& (ctx.fsrs_short_term_with_steps_enabled || ctx.steps.is_empty())
|
||||
&& states.good.interval < 0.5,
|
||||
)
|
||||
} else {
|
||||
|
|
|
@ -89,7 +89,7 @@ pub(crate) struct StateContext<'a> {
|
|||
pub fuzz_factor: Option<f32>,
|
||||
pub fsrs_next_states: Option<NextStates>,
|
||||
pub fsrs_short_term_with_steps_enabled: bool,
|
||||
|
||||
pub fsrs_allow_short_term: bool,
|
||||
// learning
|
||||
pub steps: LearningSteps<'a>,
|
||||
pub graduating_interval_good: u32,
|
||||
|
@ -149,6 +149,7 @@ impl StateContext<'_> {
|
|||
},
|
||||
fsrs_next_states: None,
|
||||
fsrs_short_term_with_steps_enabled: false,
|
||||
fsrs_allow_short_term: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,8 @@ impl RelearnState {
|
|||
},
|
||||
review: again_review,
|
||||
};
|
||||
if (ctx.fsrs_short_term_with_steps_enabled || ctx.relearn_steps.is_empty())
|
||||
if ctx.fsrs_allow_short_term
|
||||
&& (ctx.fsrs_short_term_with_steps_enabled || ctx.relearn_steps.is_empty())
|
||||
&& interval < 0.5
|
||||
{
|
||||
again_relearn.into()
|
||||
|
@ -116,7 +117,8 @@ impl RelearnState {
|
|||
},
|
||||
review: hard_review,
|
||||
};
|
||||
if (ctx.fsrs_short_term_with_steps_enabled || ctx.relearn_steps.is_empty())
|
||||
if ctx.fsrs_allow_short_term
|
||||
&& (ctx.fsrs_short_term_with_steps_enabled || ctx.relearn_steps.is_empty())
|
||||
&& interval < 0.5
|
||||
{
|
||||
hard_relearn.into()
|
||||
|
@ -169,7 +171,8 @@ impl RelearnState {
|
|||
},
|
||||
review: good_review,
|
||||
};
|
||||
if (ctx.fsrs_short_term_with_steps_enabled || ctx.relearn_steps.is_empty())
|
||||
if ctx.fsrs_allow_short_term
|
||||
&& (ctx.fsrs_short_term_with_steps_enabled || ctx.relearn_steps.is_empty())
|
||||
&& interval < 0.5
|
||||
{
|
||||
good_relearn.into()
|
||||
|
|
|
@ -124,7 +124,8 @@ impl ReviewState {
|
|||
review: again_review,
|
||||
}
|
||||
.into()
|
||||
} else if (ctx.fsrs_short_term_with_steps_enabled || ctx.relearn_steps.is_empty())
|
||||
} else if ctx.fsrs_allow_short_term
|
||||
&& (ctx.fsrs_short_term_with_steps_enabled || ctx.relearn_steps.is_empty())
|
||||
&& scheduled_days < 0.5
|
||||
{
|
||||
again_relearn.into()
|
||||
|
|
Loading…
Reference in a new issue