This repository contains a Kotlin implementation of the Free Spaced Repetition Scheduler (FSRS), version 6. FSRS is a modern algorithm for spaced repetition, optimized using machine learning to improve long-term retention and scheduling efficiency.
๐ฌ FSRS v6 is the latest official version of the algorithm, offering better accuracy and flexibility compared to older algorithms like SM-2.
- ๐ Based on the official FSRS v6 specification
- ๐ Supports all review responses:
Again
,Hard
,Good
,Easy
- ๐งฎ Returns updated stability, difficulty, and interval
- ๐งฑ Written in idiomatic Kotlin, easy to integrate into Android or JVM projects
- ๐ Uses
LocalDateTime
for precise due date handling - ๐งช Suitable for experimentation or direct production use
This FSRS implementation can be used in:
- Flashcard apps (Anki-like)
- Educational software for medical, language, and test prep
- Any Kotlin-based spaced repetition project
//create instance, use deck default retention(0.9) and default params
//FSRS-6 sepecific params = [0.212, 1.2931, 2.3065, 8.2956, 6.4133, 0.8334, 3.0194, 0.001, 1.8722, 0.1666, 0.796, 1.4835, 0.0614, 0.2629, 1.6483, 0.6014, 1.8729, 0.5425, 0.0912, 0.0658, 0.1542]
val fsrs = FSRS(deck.retention, deck.params)
//calculate a list contains stability, difficulty, interval, durationMillis and text to be shown for each button
//see models.kt file
val gradeList = fsrs.calculate(flashCard)
//to update card, just add interval to current time
fun addMillisToNow(millis: Long): LocalDateTime {
val nowInstant = Instant.now()
val newInstant = nowInstant.plusMillis(millis)
return LocalDateTime.ofInstant(newInstant, ZoneId.systemDefault())
}
This implementation is provided under the MIT License. Attribution to the original FSRS author is appreciated.
Feel free to fork the repo and submit pull requests if youโd like to add enhancements or bug fixes. Issues and suggestions are always welcome.