summaryrefslogtreecommitdiff
path: root/org-fc-algo-tn.el
diff options
context:
space:
mode:
Diffstat (limited to 'org-fc-algo-tn.el')
-rw-r--r--org-fc-algo-tn.el41
1 files changed, 41 insertions, 0 deletions
diff --git a/org-fc-algo-tn.el b/org-fc-algo-tn.el
new file mode 100644
index 0000000..7b4f1bc
--- /dev/null
+++ b/org-fc-algo-tn.el
@@ -0,0 +1,41 @@
+(require 'org-fc-core)
+
+;;; Main Algorithm
+
+(defun nth-tn (n)
+ "The mathematical formula for the Nth triangular number."
+ (/ (* n
+ (1+ n))
+ 2))
+
+(defun org-fc-algo-tn-next-parameters (ease box interval rating)
+ "Calculate the next parameters of a card, based on the review RATING.
+EASE, BOX and INTERVAL are the current parameters of the card."
+ (let* ((incorrect-at-edge (and (eq rating 'incorrect)
+ (eq box 1)))
+ (incorrect (eq rating 'incorrect))
+ (correct t)
+ (next-ease (cond (incorrect-at-edge (- ease 0.01))
+ (incorrect (- ease 0.01))
+ (correct ease)))
+ (next-box (cond (incorrect-at-edge box)
+ (incorrect (1- box))
+ (correct 1+ box)))
+ (next-interval (cond (incorrect-at-edge 1)
+ (incorrect (nth-tn next-box))
+ (correct (nth-tn next-box)))))
+ (list next-ease next-box next-interval)))
+
+(defun org-fc-algo-tn-initial-review-data (position)
+ "Initial TN review data for POSITION."
+ (let ((box 1)
+ (ease 1)
+ (interval 1)
+ (due (org-fc-timestamp-in 0)))
+ (list position ease box interval due)))
+
+;;; Footer
+
+(provide 'org-fc-algo-tn)
+
+;; org-fc-algo-tn.el ends here.