Some problems in implementing a state-of-the-art SRS scheduler on Anki

I’m the author of A Stochastic Shortest Path Algorithm for Optimizing Spaced Repetition Scheduling, and I want to implement our algorithm on Anki. However, I don’t know how to store global parameters in custom scheduling. A simple JS implementation is at this GitHub repo: open-spaced-repetition/fsrs.js. Somebody help me?

Anther problem is, there are three state variables for each card in our algorithm, but the table cards in the Anki database only have factor and ivl to save state variables. Is it possible to save and load state variables in extra fields?

Here are some tools and documents that I have used and read:


Have you tried storing the parameters in globalThis yet?


Custom Scheduling

globalThis.someParameter = value;


var parameter = globalThis.someParameter;

I recommend storing a single global object this way from which to retrieve all your parameters.

1 Like

Thank you! I have tired it just now. It works well when I test following codes:

if (states.hard.normal?.review) {
  if (globalThis.test) {
  	globalThis.test = globalThis.test + 1;
  } else {
    globalThis.test = 1

But after I reboot the Anki application, the globalThis.test is lost.

Ah, you want to store these values permanently. This has to be done in the backend, probably with an add-on. Sadly I can’t help you with this stuff because I’m a UX-guy who mostly dabbles in the front-end.

But there are some database-pros here in this forum who might know how to achieve what you want :+1:

1 Like

Added to Support persistent state in custom scheduler code · Issue #2039 · ankitects/anki · GitHub


Thank you very much!

The original link is locked by paywall. Here is the free access: