walterscarborough/LibSpacey

Wrong algorithm?

Closed this issue · 1 comments

I may be misunderstanding so please correct me if I am wrong, but the code does not seem to reflect the SM2 algorithm correctly.

Problem 1:

srsengine.cpp line 38:

if (grade == 3) {
        flashcard.setInterval(0);
    }

From the Supermemo 2 Algorithm website:
"6. If the quality response was lower than 3 then start repetitions for the item from the beginning..."

This if statement contradicts the quoted sentence as well as the source code of the algorithm.

However it seems like there is a reason for this implementation since this little if statement is placed after the big if/else statement (line8 to 36) that follows the algorithm.

Problem 2

srsengine.cpp line 32:
int newInterval = ceil((flashcard.getRepetition() - 1) * flashcard.getEasinessFactor());

The Supermemo 2 Algorithm website: says the following when calculating the intervals:
"3. Repeat items using the following intervals:
...
for n>2: *I(n):=I(n-1)EF"

That should mean that the calculation of I(n) for n>2 uses the previous interval * EF?
This is also shown in the source code:
Interval:=round(Interval*EF);

The code here at line 32 uses getRepetition() in it's calculation, instead of using the previous interval.

@iMaddin Thanks so much for pointing those errors out! I've fixed them in the current release 1.1.0