summaryrefslogtreecommitdiff
path: root/org-fc-algo-tn.el
blob: 974aeaeb10195db450992e5d091491f58e60b333 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(require 'org-fc-core)

;;; Main Algorithm

(defun nth-tn (n)
  "The mathematical formula for the Nth triangular number."
  (if (zerop n)
      0
    (/ (* n (1+ n)) 2.0)))

(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 0)))
       (incorrect (eq rating 'incorrect))
       (correct t)
       (next-ease
	(cond
	 (incorrect-at-edge (1+ ease))
	 (incorrect (1+ ease))
	 (correct ease)))
       (next-box
	(cond
	 (incorrect-at-edge box)
	 (incorrect (1- box))
	 (correct (1+ box))))
       (next-interval (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 0)
       (ease 0)
       (interval 1.0)
       (due (org-fc-timestamp-in 1.0)))
    (list position ease box interval due)))

;;; Footer

(provide 'org-fc-algo-tn)

;; org-fc-algo-tn.el ends here.