Skip to content

Commit

Permalink
Clamp difficulty
Browse files Browse the repository at this point in the history
  • Loading branch information
xiety committed Mar 11, 2024
1 parent 92045ef commit 8970f6f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
14 changes: 10 additions & 4 deletions src/fsrsCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ export class FsrsCalculator {
}

calcD0(g: number): number {
return this.w[4] - this.w[5] * (g - 3.0);
let d = this.w[4] - this.w[5] * (g - 3.0);
return this.clamp(d, 1, 10);
}

calcDN(d: number, g: number): number {
let dn = d - this.w[6] * (g - 3.0);
return this.w[7] * this.calcD0(3) + (1.0 - this.w[7]) * dn;
let dn2 = this.w[7] * this.calcD0(3) + (1.0 - this.w[7]) * dn;
return this.clamp(dn2, 1, 10);
}

calcRevExp(w: number, r: number): number {
Expand All @@ -45,10 +47,14 @@ export class FsrsCalculator {
return this.w[11] * Math.pow(d, -this.w[12]) * (Math.pow(s + 1.0, this.w[13]) - 1.0) * this.calcRevExp(this.w[14], r);
}

calcRD(d: number){
calcRD(d: number) {
return (d - 1.0) / 9.0 * 100.0;
}

clamp(number: number, min: number, max: number) {
return Math.max(min, Math.min(number, max));
}

public step(card: Card, g: number): Card {
if (g < 1 || g > 4)
return card;
Expand Down Expand Up @@ -99,7 +105,7 @@ export class Card {
cumulativeInterval: number;
score: number;

public constructor(n: boolean, difficulty: number, realDifficulty: number, stability: number, interval: number, cumulativeInterval:number, score: number) {
public constructor(n: boolean, difficulty: number, realDifficulty: number, stability: number, interval: number, cumulativeInterval: number, score: number) {
this.new = n;
this.difficulty = difficulty;
this.realDifficulty = realDifficulty;
Expand Down
18 changes: 9 additions & 9 deletions src/sliderInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ interface SliderInfo {
}

export const sliders: SliderInfo[] = [
{ name: "initial stability (Again)", min: 0.1, max: 365 },
{ name: "initial stability (Hard)", min: 0.1, max: 365 },
{ name: "initial stability (Good)", min: 0.1, max: 365 },
{ name: "initial stability (Easy)", min: 0.1, max: 365 },
{ name: "initial stability (Again)", min: 0.1, max: 100 },
{ name: "initial stability (Hard)", min: 0.1, max: 100 },
{ name: "initial stability (Good)", min: 0.1, max: 100 },
{ name: "initial stability (Easy)", min: 0.1, max: 100 },
{ name: "initial difficulty (Good)", min: 1, max: 10 },
{ name: "initial difficulty (multiplier)", min: 0.1, max: 5 },
{ name: "difficulty (multiplier)", min: 0.1, max: 5 },
{ name: "difficulty (multiplier)", min: 0, max: 0.5 },
{ name: "stability (exponent)", min: 0, max: 3 },
{ name: "difficulty (multiplier)", min: 0, max: 0.75 },
{ name: "stability (exponent)", min: 0, max: 4 },
{ name: "stability (negative power)", min: 0.1, max: 0.8 },
{ name: "stability (exponent)", min: 0.01, max: 2.5 },
{ name: "stability (exponent)", min: 0.01, max: 3.0 },
{ name: "fail stability (multiplier)", min: 0.5, max: 5 },
{ name: "fail stability (negative power)", min: 0.01, max: 0.2 },
{ name: "fail stability (power)", min: 0.01, max: 0.9 },
{ name: "fail stability (exponent)", min: 0.01, max: 2 },
{ name: "fail stability (exponent)", min: 0.01, max: 3 },
{ name: "stability (multiplier for Hard)", min: 0, max: 1 },
{ name: "stability (multiplier for Easy)", min: 1, max: 4 },
{ name: "stability (multiplier for Easy)", min: 1, max: 6 },
];

export const desiredRSlider: SliderInfo = { name: "Desired Retention", min: 0.8, max: 0.99 };

0 comments on commit 8970f6f

Please sign in to comment.