SuperMemo算法
>重复 – 这是用户看到闪卡的次数. 0表示他们尚未研究过,1表示这是他们的第一次,依此类推.在一些文档中它也被称为n.
>质量 – 也称为评估质量.这是闪存卡的难度(由用户定义).比例从0到5.
> easyiness – 这也称为easyiness factor或EFactor或EF.它是乘数,用于增加间隔重复的“空间”.范围从1.3到2.5.
> interval – 这是重复之间的时间长度(以天为单位).它是间隔重复的“空间”.
> nextPractice – 这是闪卡随后再次审核的date/time.
默认值
int repetitions = 0;
int interval = 1;
float easiness = 2.5;
码
private void calculateSuperMemo2Algorithm(FlashCard card, int quality) {
if (quality < 0 || quality > 5) {
// throw error here or ensure elsewhere that quality is always within 0-5
}
// retrieve the stored values (default values if new cards)
int repetitions = card.getRepetitions();
float easiness = card.getEasinessFactor();
int interval = card.getInterval();
// easiness factor
easiness = (float) Math.max(1.3, easiness + 0.1 - (5.0 - quality) * (0.08 + (5.0 - quality) * 0.02));
// repetitions
if (quality < 3) {
repetitions = 0;
} else {
repetitions += 1;
}
// interval
if (repetitions <= 1) {
interval = 1;
} else if (repetitions == 2) {
interval = 6;
} else {
interval = Math.round(interval * easiness);
}
// next practice
int secondsInDay = 60 * 60 * 24;
long now = System.currentTimeMillis();
long nextPracticeDate = now + secondsInDay*interval;
// Store the nextPracticeDate in the database
// ...
}
笔记
>上面的代码没有设置容易度的上限.应该是2.5吗?文档和源代码似乎互相矛盾.
>如果质量评估小于3,文档也听起来似乎不应该更新容易因素,但这似乎与源代码相矛盾.在我看来,更新它更有意义(只要它保持在1.3以上).无论如何,我每次都在更新它.
> Anki源代码是here.虽然这是一个很大的项目,但我还没有深入挖掘它们的算法版本.
> This post讨论了SM-2的一些问题以及这些问题的解决方案.