John Smith commited on 2023-35 11:52:49
Showing 1 changed files, with 11 additions and 6 deletions.
Improving upon a504a3f, the sorting procedure to prioritise prompts to review no longer includes a shuffle phase, instead scoring each prompt by a coefficient of overdueness, its ease (easier cards have lower priority), and a random offset which is more significant on lower-priority cards.
| ... | ... |
@@ -41,11 +41,16 @@ local function update(prompt, revtime, revsucc, conf) |
| 41 | 41 |
end |
| 42 | 42 |
|
| 43 | 43 |
--[[ |
| 44 |
- checks (returns boolean) if `Prompt` `prompt` should be reviewed now |
|
| 44 |
+ checks if `Prompt` `prompt` should be reviewed now, |
|
| 45 |
+ returning `false` if not and a number to indicate urgency if it should |
|
| 45 | 46 |
]] |
| 46 | 47 |
local function should(prompt) |
| 47 | 48 |
local ct = os.time() |
| 48 |
- return prompt.delay >= 0 and ct - (prompt.time or 0) >= (prompt.delay or 0) and (ct - (prompt.time or 0)) / prompt.delay |
|
| 49 |
+ if not prompt.delay then return -1 end |
|
| 50 |
+ if prompt.delay >= 0 and ct - (prompt.time or 0) >= (prompt.delay or 0) then |
|
| 51 |
+ return (ct - (prompt.time or 0)) / prompt.delay / prompt.ease + 0.2 * math.random() |
|
| 52 |
+ end |
|
| 53 |
+ return false |
|
| 49 | 54 |
end |
| 50 | 55 |
|
| 51 | 56 |
--[[ |
| ... | ... |
@@ -80,15 +85,15 @@ local function toreviewlist(deck, filter) |
| 80 | 85 |
local ff = filter or alwaystrue |
| 81 | 86 |
for i, cg in ipairs(deck) do |
| 82 | 87 |
for j, pr in ipairs(cg) do |
| 83 |
- if should(pr) and ff(pr) then |
|
| 84 |
- table.insert(ctrt, { i, j })
|
|
| 88 |
+ local sc = should(pr) |
|
| 89 |
+ if sc and ff(pr) then |
|
| 90 |
+ table.insert(ctrt, { i, j, sc or 0 })
|
|
| 85 | 91 |
end |
| 86 | 92 |
end |
| 87 | 93 |
end |
| 88 | 94 |
table.sort(ctrt, function(a, b) |
| 89 |
- return should(deck[a[1]][a[2]]) > should(deck[b[1]][b[2]]) |
|
| 95 |
+ return a[3] > b[3] |
|
| 90 | 96 |
end) |
| 91 |
- biasedshuffle(ctrt) |
|
| 92 | 97 |
return ctrt |
| 93 | 98 |
end |
| 94 | 99 |
|
| 95 | 100 |