Skip to content

open-spaced-repetition/FSRS-Kotlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  FSRS Scheduler (Version 6) โ€“ Kotlin Implementation

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.


โœ… Features

  • ๐Ÿ“Œ 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

๐Ÿ“ฆ Use Cases

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

๐Ÿš€ Example Usage

//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())
    } 

๐Ÿ“š References

๐Ÿ›  License

This implementation is provided under the MIT License. Attribution to the original FSRS author is appreciated.

๐Ÿ™Œ Contributing

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.

About

Kotlin version of FSRS

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages