def _earlyReviewIvl(self, card: Card, ease: int) -> int:
assert card.odid and card.type == CARD_TYPE_REV
assert card.factor
assert ease > 1
elapsed = card.ivl - (card.odue - self.today)
#// elapsed: number of days that have passed since you reviewed the card
#// card.ivl: card's given interval
#// card.odue: card's original due date
#// self.today: today date
conf = self._revConf(card)
easyBonus = 1
# early 3/4 reviews shouldn't decrease previous interval
minNewIvl = 1
if ease == BUTTON_TWO: #// if you press hard
factor = conf.get("hardFactor", 1.2)
#// hardFactor: should
# hard cards shouldn't have their interval decreased by more than 50%
# of the normal factor
minNewIvl = factor / 2
elif ease == BUTTON_THREE: #// if you press good
factor = card.factor / 1000
else: # ease == BUTTON_FOUR: #// if you press easy
factor = card.factor / 1000
ease4 = conf["ease4"]
#// ease4: should be the ease bonus (review tab in deck options) not sure tho
# 1.3 -> 1.15
easyBonus = ease4 - (ease4 - 1) / 2
ivl_1 = max(elapsed * factor, 1)
#// card.factor: if ease = 250%, card.factor = 2500
#// factor: if ease = 250%, factor = 2.5
# cap interval decreases
ivl_2 = max(card.ivl * minNewIvl, ivl_1) * easyBonus
ivl_3 = self._constrainedIvl(ivl_2, conf, prev=0, fuzz=False)
#// self._constrainedIvl -> applies fuzz,checks for maximum interval cap,
#// checks for previous interval and does one more thing that i honestly don't understand :/
#// for review ahead, fuzz is false (no fuzz applies)
#// previous interval = 0, maximum is always the interval that this function gives it
#// so i'll just assume that it has no effect on the interval and just use this function in my example (:|)
return ivl_3
#// returns new interval for the card
if you press hard
card.ivl = 20 (days)
elapsed = 9 (days)
easyBonus = 1
minNewIvl = 0.55 (factor = conf.get("hardFactor", 1.2
| then minNewIvl = factor / 2
) (my hard factor is 110% -> anki stores it as 1.10 => 1.10/2 = 0.55)
factor = 1.1
ivl_1 = 10
ivl_2 = 11
final interval on hard button = 11 (days)
if you press good
card.ivl = 20 (days)
elapsed = 9 (days)
easyBonus = 1
minNewIvl = 1
factor = 2.5
ivl_1 = 22.5
ivl_2 = 22.5
final interval on good button = 22 (days)
if you press easy
card.ivl = 20 (days)
elapsed = 9 (days)
easyBonus = 1.15 (check out #NOTE)
minNewIvl = 1
factor = 2.5
ivl_1 = 22.5
ivl_2 = 25.8
final interval on easy button = 26 (days)
#NOTE -> how easyBonus was calculated:
ease4 = conf[“ease4”] -> this is the easy bonus that you set on deck options -> review tab
| if it’s 130%, anki stores it as 1.3
easyBonus = ease4 - (ease4 - 1) / 2
so if ease4 = 1.3
-> easyBonus = 1.3 - (0.3)/2 => 1.3 - 0.15 = 1.15
I know it’s a mess
hope you understand it tho