All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.mahjongutils.shanten.helpers.BestHandPatternsSelector.kt Maven / Gradle / Ivy

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy