mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Use card.reps - 1 when calculating fuzz (#2933)
https://github.com/open-spaced-repetition/fsrs4anki-helper/issues/343#issuecomment-1879584562 https://forums.ankiweb.net/t/reschedule-is-inconsistent-with-normal-schedule-in-fuzz/39363
This commit is contained in:
parent
cc81db0f9d
commit
bf06020855
5 changed files with 20 additions and 11 deletions
|
@ -53,8 +53,8 @@ service SchedulerService {
|
|||
returns (ComputeOptimalRetentionResponse);
|
||||
rpc EvaluateWeights(EvaluateWeightsRequest) returns (EvaluateWeightsResponse);
|
||||
rpc ComputeMemoryState(cards.CardId) returns (ComputeMemoryStateResponse);
|
||||
// The number of days the calculated interval will be fuzzed by. Utilized by
|
||||
// the FSRS add-on.
|
||||
// The number of days the calculated interval was fuzzed by on the previous
|
||||
// review (if any). Utilized by the FSRS add-on.
|
||||
rpc FuzzDelta(FuzzDeltaRequest) returns (FuzzDeltaResponse);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,9 +114,9 @@ pub enum AnkiError {
|
|||
InvalidMethodIndex,
|
||||
InvalidServiceIndex,
|
||||
FsrsWeightsInvalid,
|
||||
// Returned by fsrs-rs; may happen even if 1000+ reviews
|
||||
/// Returned by fsrs-rs; may happen even if 1000+ reviews
|
||||
FsrsInsufficientData,
|
||||
// Generated by our backend if count < 1000
|
||||
/// Generated by our backend if count < 1000
|
||||
FsrsInsufficientReviews {
|
||||
count: usize,
|
||||
},
|
||||
|
|
|
@ -398,7 +398,7 @@ impl Collection {
|
|||
};
|
||||
let desired_retention = fsrs_enabled.then_some(config.inner.desired_retention);
|
||||
Ok(CardStateUpdater {
|
||||
fuzz_seed: get_fuzz_seed(&card),
|
||||
fuzz_seed: get_fuzz_seed(&card, false),
|
||||
card,
|
||||
deck,
|
||||
config,
|
||||
|
@ -519,14 +519,23 @@ pub mod test_helpers {
|
|||
}
|
||||
|
||||
impl Card {
|
||||
pub(crate) fn get_fuzz_factor(&self) -> Option<f32> {
|
||||
get_fuzz_factor(get_fuzz_seed(self))
|
||||
/// If for_reschedule is true, we use card.reps - 1 to match the previous
|
||||
/// review.
|
||||
pub(crate) fn get_fuzz_factor(&self, for_reschedule: bool) -> Option<f32> {
|
||||
get_fuzz_factor(get_fuzz_seed(self, for_reschedule))
|
||||
}
|
||||
}
|
||||
|
||||
/// Return a consistent seed for a given card at a given number of reps.
|
||||
fn get_fuzz_seed(card: &Card) -> Option<u64> {
|
||||
get_fuzz_seed_for_id_and_reps(card.id, card.reps)
|
||||
/// If for_reschedule is true, we use card.reps - 1 to match the previous
|
||||
/// review.
|
||||
fn get_fuzz_seed(card: &Card, for_reschedule: bool) -> Option<u64> {
|
||||
let reps = if for_reschedule {
|
||||
card.reps.saturating_sub(1)
|
||||
} else {
|
||||
card.reps
|
||||
};
|
||||
get_fuzz_seed_for_id_and_reps(card.id, reps)
|
||||
}
|
||||
|
||||
/// If in test environment, disable fuzzing.
|
||||
|
|
|
@ -95,7 +95,7 @@ impl Collection {
|
|||
)
|
||||
as f32;
|
||||
card.interval = with_review_fuzz(
|
||||
card.get_fuzz_factor(),
|
||||
card.get_fuzz_factor(true),
|
||||
interval,
|
||||
1,
|
||||
req.max_interval,
|
||||
|
|
|
@ -49,7 +49,7 @@ impl Collection {
|
|||
.or_not_found(card.deck_id)?;
|
||||
let config = self.home_deck_config(deck.config_id(), card.original_deck_id)?;
|
||||
let fuzzed = with_review_fuzz(
|
||||
card.get_fuzz_factor(),
|
||||
card.get_fuzz_factor(true),
|
||||
interval as f32,
|
||||
1,
|
||||
config.inner.maximum_review_interval,
|
||||
|
|
Loading…
Reference in a new issue