Damien Elmes 2024-01-09 12:26:46 +10:00 committed by GitHub
parent cc81db0f9d
commit bf06020855
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 11 deletions

View file

@ -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);
}

View file

@ -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,
},

View file

@ -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.

View file

@ -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,

View file

@ -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,