commonMain.mahjongutils.shanten.helpers.BestHandPatternsSelector.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mahjong-utils Show documentation
Show all versions of mahjong-utils Show documentation
Mahjong Utils (for Japanese Riichi Mahjong)
The newest version!
package mahjongutils.shanten.helpers
import mahjongutils.models.hand.HandPattern
internal class BestHandPatternsSelector(
private val calcShanten: (T) -> Int
) {
var bestShanten = 100
private set
var bestPatterns = ArrayList()
private set
fun receive(pattern: T) {
val patShanten = calcShanten(pattern)
if (patShanten < bestShanten) {
bestShanten = patShanten
bestPatterns = ArrayList()
}
if (patShanten == bestShanten) {
bestPatterns.add(pattern)
}
}
}