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:
commit
d59cd020c0
@ -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?
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user