summaryrefslogtreecommitdiff
path: root/gnosis-algorithm.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-07-22 09:33:55 +0300
committerThanos Apollo <[email protected]>2024-07-22 09:34:46 +0300
commitbc19cca217e4cc8693fd408c4d2425b32cf216fc (patch)
tree427572c8ea3891e7a7f7d6ce590644bd7f68e154 /gnosis-algorithm.el
parent9bf0e241f0862526583262a1f2671b0524a8508d (diff)
gnosis-algorithm: Add interval threshold & unlimit init-interval.
* Adding threshold value that will be used to reset interval to 0 when c-fails reaches threshold. * Inital interval now can be more than 2 items, allowing for further customization of gnosis algorithm.
Diffstat (limited to 'gnosis-algorithm.el')
-rw-r--r--gnosis-algorithm.el30
1 files changed, 22 insertions, 8 deletions
diff --git a/gnosis-algorithm.el b/gnosis-algorithm.el
index 33e3232..787d7ec 100644
--- a/gnosis-algorithm.el
+++ b/gnosis-algorithm.el
@@ -169,17 +169,27 @@ by DECREASE."
(gnosis-algorithm-round-items new-ef)))
(cl-defun gnosis-algorithm-next-interval (&key last-interval ef success successful-reviews
- failure-factor initial-interval)
+ failure-factor initial-interval c-fails
+ threshold)
"Calculate next interval.
-LAST-INTERVAL: number of days since last review
+LAST-INTERVAL: Number of days since last review
+
+C-FAILS: Total consecutive failed reviews.
+
EF: Easiness factor
-SUCCESS: t if review was successful, nil otherwise
-SUCCESSFUL-REVIEWS: number of successful reviews
-FAILURE-FACTOR: factor to multiply last interval by if review was unsuccessful
-INITIAL-INTERVAL: list of initial intervals for initial successful
+
+SUCCESS: non-nil when review was successful.
+
+SUCCESSFUL-REVIEWS: Number of successful reviews.
+
+FAILURE-FACTOR: Factor to multiply last interval by if review was unsuccessful.
+
+INITIAL-INTERVAL: List of initial intervals for initial successful
reviews. Will be used to determine the next interval for the first 2
-successful reviews."
+successful reviews. Until successfully completing INITIAL-INTERVAL reviews, for every failed attempt next interval will be set to 0.
+
+THRESHOLD: Upon having C-FAILS >= threshold, set next interval to 0."
(cl-assert (< gnosis-algorithm-ff 1) "Value of `gnosis-algorithm-ff' must be lower than 1")
;; This should only occur in testing env or when the user has made breaking changes.
(let* ((last-interval (if (<= last-interval 0) 1 last-interval)) ;; If last-interval is 0, use 1 instead.
@@ -189,7 +199,11 @@ successful reviews."
(cadr initial-interval))
;; If it's still on initial stage, review the
;; same day
- ((and (< successful-reviews 2) (not success)) 0)
+ ((and (or (< successful-reviews (length initial-interval))
+ ;; reset threshold
+ (and threshold (>= c-fails threshold)))
+ (not success))
+ 0)
(t (let* ((success-interval (* ef last-interval))
(failure-interval (* last-interval failure-factor)))
(if success success-interval