👨‍💻 dev porting Auxiliary modules Java->kotlin

development

fukurou

the supreme coder
ADMIN
Kotlin:
class AXConvince(private val req: AXContextCmd) {
private val reset = Responder("reset")
private var min = 3 // minimum requests till agreement
    private val rnd = DrawRnd()
private var counter = 0
    var isConvinced = false
        private set
    private var max_eff_to_convince = 6
    fun setMax_eff_to_convince(max_eff_to_convince: Int) {
this.max_eff_to_convince = max_eff_to_convince
    }

fun engage(ear: String): Int {
// 0:nothing, 1: no, 2:yes, 3: just been reset to no again
        if (reset.responsesContainsStr(ear)) {
counter = 0
            isConvinced = false
            min += rnd.getSimpleRNDNum(max_eff_to_convince)
return 3
        }
if (req.engageCommand(ear)) {
counter++
return if (counter < min) {
1
            } else {
isConvinced = true
                2
            } // convinced
        }
return 0
    }
}
 

fukurou

the supreme coder
ADMIN
Kotlin:
class AXSkillBundle(vararg skillsParams: DiSkillV2) {
    private val skills: ArrayList<DiSkillV2> = ArrayList<DiSkillV2>()
    private val tempN: Neuron = Neuron()
    private var kokoro: Kokoro = Kokoro(AbsDictionaryDB())
    fun setKokoro(kokoro: Kokoro) {
        this.kokoro = kokoro
        for (skill in skills) {
            skill.kokoro = this.kokoro
        }
    }

    init {
        for (skill in skillsParams) {
            skill.kokoro = this.kokoro
            skills.add(skill)
        }
    }

    fun addSkill(skill: DiSkillV2): AXSkillBundle {
        // builder pattern
        skill.kokoro = this.kokoro
        skills.add(skill)
        return this
    }

    fun dispenseAlgorithm(ear: String, skin: String, eye: String): AlgorithmV2? {
        for (skill in skills) {
            skill.input(ear, skin, eye)
            skill.output(tempN)
            for (j in 1..5) {
                val temp: Algorithm? = tempN.getAlg(j)
                if (temp != null) {
                    return AlgorithmV2(j, temp)
                }
            }
        }
        return null
    }

    val size: Int
        get() = skills.size
}
 
Top