Randomly offset review delays
John Smith

John Smith commited on 2022-14 23:53:32
Showing 2 changed files, with 5 additions and 0 deletions.


Review delays will now be offset by a random amount, limited to 10%
of the originally calculated delay (in either direction).
This avoids the issue of prompts added on the same day repeatedly
appearing for review on the same day.
... ...
@@ -84,6 +84,8 @@ if arg[2] then
84 84
     deckfname = arg[2]
85 85
 end
86 86
 
87
+math.randomseed(os.time())
88
+
87 89
 --[[
88 90
     do requested action
89 91
 ]]
... ...
@@ -10,6 +10,9 @@ local function update(prompt, revtime, revsucc)
10 10
     if revsucc and revsucc > 0 then
11 11
         local ad = revtime - prompt.time
12 12
         prompt.delay = 2.5 ^ revsucc * (ad + math.max(40000 - 0.5 * ad, 0))
13
+        -- allowed random variation, as a fraction of the "optimal" duration
14
+        local ARV = 0.1
15
+        prompt.delay = prompt.delay * ((1 - ARV) + 2 * ARV * math.random())
13 16
         prompt.succ = prompt.succ + 1
14 17
     else
15 18
         prompt.delay = 30
16 19