0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 12:02:16 +02:00

Merge pull request #4392 from hssm/lrn-random

Fix random factor in lrn card scheduling
This commit is contained in:
Tim Rae 2016-07-31 14:15:08 +09:00 committed by GitHub
commit d59cd020c0
2 changed files with 10 additions and 2 deletions

View File

@ -942,9 +942,8 @@ public class Sched {
int delay = _delayForGrade(conf, card.getLeft());
if (card.getDue() < Utils.now()) {
// not collapsed; add some randomness
delay *= (1 + (new Random().nextInt(25) / 100));
delay *= Utils.randomFloatInRange(1f, 1.25f);
}
// TODO: check, if type for second due is correct
card.setDue((int) (Utils.now() + delay));
// due today?

View File

@ -1015,4 +1015,13 @@ public class Utils {
public static String unescape(String htmlText) {
return Html.fromHtml(htmlText).toString();
}
/**
* Return a random float within the range of min and max.
*/
public static float randomFloatInRange(float min, float max) {
Random rand = new Random();
return rand.nextFloat() * (max - min) + min;
}
}