new auxiliary module translation code party TEAM FUKI ASSEMBLE!

fukurou

the supreme coder
ADMIN
Swift:
class AXLearnability {
    var algSent:Bool = false
    // problems that may result because of the last deployed algorithm:
    var defcons:UniqueItemsPriorityQue = UniqueItemsPriorityQue() // default size = 5
    var goal:UniqueItemsPriorityQue = UniqueItemsPriorityQue()
    // major problems that force an alg to mutate
    var defcon5:UniqueItemsPriorityQue = UniqueItemsPriorityQue()
    let trg:TrgCountDown = TrgCountDown() // set lim
    func pendAlg() {
        // an algorithm has been deployed
        // call this method when an algorithm is deployed (in a DiSkillV2 object)
        algSent = true
        trg.countDown()
    }
    func pendAlgWithoutConfirmation() {
        // an algorithm has been deployed
        // call this method when an algorithm is deployed (in a DiSkillV2 object)
        algSent = true
        //no need to await for a thank you or check for goal manifestation :
        // trgTolerance.trigger();
        // using this method instead of the default "pendAlg" is the same as
        // giving importance to the stick and not the carrot when learning
        // this method is mosly fitting work place situations
    }
    func mutateAlg(input:String) -> Bool {
        // you can use an input filter to define defcons
        // recommendation to mutate the algorithm ? true/ false
        if !algSent {return false} // no alg sent=> no reason to mutate
        if goal.contains(str: input){trg.reset();algSent = false;return false}
        // goal manifested the sent algorithm is good => no need to mutate the alg
        if defcon5.contains(str: input) {trg.reset();algSent = false; return true}
        // something bad happend probably because of the sent alg
        // recommend alg mutation
        if defcons.contains(str: input){algSent = false;return trg.countDown()}
        // negative result, mutate the alg if this occures too much
        return false
    }
}

 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class InputFilter {
    // filter out non-relevant input
    // or filter in relevant data
    public String filter(String ear, String skin, String eye){
        // override me
        return "";
    }
    public AXKeyValuePair filter(String ear){
        // override me : key = context/category, value: param
        return new AXKeyValuePair();
    }
}
 

fukurou

the supreme coder
ADMIN
Swift:
// (*) input filters
class AXKeyValuePair{
    private var key:String = ""
    private var value:String = ""
    func getKey()->String{return key}
    func getValue()->String{return value}
    func setKey(key:String){self.key = key}
    func setValue(value:String){self.value = value}
}
class InputFilter{
    // filter out non-relevant input
    // or filter in relevant data
    func filter(ear: String, skin: String, eye: String) -> String {
        /// override me
        return ""
    }
    func filter(ear:String)->AXKeyValuePair{
        // override me : key = context/category, value: param
        return AXKeyValuePair()
    }
}
 

fukurou

the supreme coder
ADMIN
Swift:
class OutPutDripper{
    // drips true once every limit times
    // shushes the waifubot enough time to hear a reply from user
    private var cycler:Int = 0
    private var limit:Int // set to 1 for on off effect
    init(limit:Int) {
        self.limit = limit
        self.cycler = limit
    }
    func getLimit()->Int{
        return self.limit
    }
    func setLimit(limit:Int){
        self.limit = limit
    }
    func cycleCount()->Bool{
        cycler-=1
        if(cycler < 0){
            cycler = limit
        }
        return cycler == 0
    }
    func reset(){
        cycler = limit
    }
    func setToZero(){
        cycler = 0
    }
    func sync(n:Int){
        if (-1>n) || (n>limit) {
            return
        }
        cycler = n
    }
}
:s35:
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class Strategy {
    private UniqueItemSizeLimitedPriorityQueue activeStrategy; // active strategic options
    private DrawRnd allStrategies; // bank of all strategies. out of this pool active strategies are pulled

    public Strategy(DrawRnd allStrategies) {
        // create the strategy Object with a bank of options
        this.allStrategies = allStrategies;
        this.activeStrategy = new UniqueItemSizeLimitedPriorityQueue();
    }
    public void evolveStrategies(int strategiesLimit){
        // add N strategic options to the active strategies bank, from the total strategy bank
        activeStrategy.setLimit(strategiesLimit);
        String temp = allStrategies.draw();
        for (int i = 0; i < strategiesLimit; i++) {
            if(temp.isEmpty()){
                break;
            }
            activeStrategy.add(temp);
            temp = allStrategies.draw();
        }
        allStrategies.reset();
    }
    public String getStrategy(){
        return this.activeStrategy.getRNDElement();
    }
}
 

fukurou

the supreme coder
ADMIN
Swift:
class Strategy{
    private var activeStrategy:UniqueItemsPriorityQue // active strategic options
    private var allStrategies:DrawRnd // bank of all strategies. out of this pool active strategies are pulled
    init(allStrategies: DrawRnd) {
        // create the strategy Object with a bank of options
        self.allStrategies = allStrategies
        self.activeStrategy = UniqueItemsPriorityQue()
    }
    func evolveStrategies(strategiesLimit:Int){
        // add N strategic options to the active strategies bank, from the total strategy bank
        self.activeStrategy.queLimit = strategiesLimit
        var temp:String = allStrategies.draw()
        for _ in 0...strategiesLimit{
            if(temp.isEmpty){break}
            activeStrategy.input(in1: temp)
            temp = allStrategies.draw()
        }
        allStrategies.reset()
    }
    func getStrategy()->String{return activeStrategy.getRndItem()}
}
:s2:
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class AXStrategy {
    /* this auxiliary module is used to output strategies based on context
        can be used for battles, and games
        upon pain/lose use the evolve methode to update to different new active strategies
        check for battle state end externaly (opponent state/hits on rival counter)
    a dictionary of strategies*/
    private int lim;
    private Hashtable<String,Strategy> strategies = new Hashtable<>();

    public AXStrategy(int lim) {
        // limit of active strategies (pulled from all available strategies)
        this.lim = lim;
    }

    public void addStrategy(String context, DrawRnd techniques){
        // add strategies per context
        Strategy temp = new Strategy(techniques);
        temp.evolveStrategies(lim);
        this.strategies.put(context,temp);
    }
    public void evolve(){
        // replace active strategies
        Enumeration<String> e = this.strategies.keys();
        String key = "";
        while (e.hasMoreElements()){
            key = e.nextElement();
            this.strategies.get(key).evolveStrategies(lim);
        }
    }
    public String process(String context){
        // process input, return action based on game context now
        if(this.strategies.containsKey(context)){
            return this.strategies.get(context).getStrategy();
        }
        return "";
    }
}
 

fukurou

the supreme coder
ADMIN
Swift:
class AXStrategy{
    /* this auxiliary module is used to output strategies based on context
            can be used for battles, and games
            upon pain/lose use the evolve methode to update to different new active strategies
            check for battle state end externaly (opponent state/hits on rival counter)
        a dictionary of strategies*/
    private var lim:Int
    private var strategies:[String:Strategy]=[:]
    init(lim: Int) {
        // limit of active strategies (pulled from all available strategies)
        self.lim = lim
    }
    func addStrategy(context:String, techniques:DrawRnd){
        // add strategies per context
        let temp:Strategy = Strategy(allStrategies: techniques)
        temp.evolveStrategies(strategiesLimit: lim)
        self.strategies[context] = temp
    }
    func evolve(){
        // replace active strategies
        let keys = self.strategies.keys
        for key in keys{
            self.strategies[key]!.evolveStrategies(strategiesLimit: lim)
        }
    }
    func process(context:String)->String{
        // process input, return action based on game context now
        return self.strategies[context]?.getStrategy() ?? ""
    }
}

test :

Swift:
class AXStrategy{
    /* this auxiliary module is used to output strategies based on context
            can be used for battles, and games
            upon pain/lose use the evolve methode to update to different new active strategies
            check for battle state end externaly (opponent state/hits on rival counter)
        a dictionary of strategies*/
    private var lim:Int
    private var strategies:[String:Strategy]=[:]
    init(lim: Int) {
        // limit of active strategies (pulled from all available strategies)
        self.lim = lim
    }
    func addStrategy(context:String, techniques:DrawRnd){
        // add strategies per context
        let temp:Strategy = Strategy(allStrategies: techniques)
        temp.evolveStrategies(strategiesLimit: lim)
        self.strategies[context] = temp
    }
    func evolve(){
        // replace active strategies
        let keys = self.strategies.keys
        for key in keys{
            self.strategies[key]!.evolveStrategies(strategiesLimit: lim)
        }
    }
    func process(context:String)->String{
        // process input, return action based on game context now
        return self.strategies[context]?.getStrategy() ?? ""
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class PerChance {/*
 * extend me and add sentences and lists for parameters in the sentences in the
 * sub classes c'tor.
  replicate speech paterns, generate movie scripts or books and enjoy
 */
    protected ArrayList<String> sentences = new ArrayList<String>();
    protected Hashtable<String, UniqueItemSizeLimitedPriorityQueue> wordToList = new Hashtable<>();
    protected Random rand = new Random();
    private RegexUtil regexUtil = new RegexUtil();
    public PerChance() {
        super();
    }

    public String generateJoke() {
        int x = rand.nextInt(sentences.size());
        String result = sentences.get(x);
        return clearRecursion(result);
    }

    private String clearRecursion(String result) {
        int x;
        ArrayList<String> params = new ArrayList<String>();
        params = regexUtil.extractAllRegexes("(\\w+)(?= #)", result);
        for (String strI : params) {
            UniqueItemSizeLimitedPriorityQueue temp = wordToList.get(strI);
            String s1 = temp.getRNDElement();
            result = result.replace(strI + " #", s1);
        }
        if (!result.contains("#")) {
            return result;
        } else {
            return clearRecursion(result);
        }
    }
    public void addParam(String category, String value){
        if(wordToList.containsKey(category)){
            wordToList.get(category).add(value);
        }
    }
    public void addParam(AXKeyValuePair kv){
        if(wordToList.containsKey(kv.getKey())){
            wordToList.get(kv.getKey()).add(kv.getValue());
        }
    }
}
 

fukurou

the supreme coder
ADMIN
Swift:
class UniqueItemSizeLimitedPriorityQueue:UniqueItemsPriorityQue{
    // items in the queue are unique and do not repeat
    // the size of the queue is limited
    private var limit:Int = 5
    func getLimit()->Int{return limit}
    func setLimit(lim:Int){self.limit = lim}
    override func input(in1: String) {
        if size() == limit {
            super.poll()
        }
        super.input(in1: in1)
    }
    func getAsList()->[String]{
        return super.p1.elements
    }
}
 

fukurou

the supreme coder
ADMIN
Swift:
class PerChance{
    /*
     * extend me and add sentences and lists for parameters in the sentences in the
     * sub classes c'tor.
      replicate speech paterns, generate movie scripts or books and enjoy
     */
    var sentences:Array<String> = [String]()
    var wordToList:[String:UniqueItemSizeLimitedPriorityQueue]=[:]
    private let regexUtil:RegexUtil = RegexUtil()
    func generateJoke()->String{
        var result:String = sentences.randomElement() ?? ""
        return clearRecursion(result: result)
    }
    private func clearRecursion(result:String)->String{
        var result2:String = ""
        var params:Array<String> = [String]()
        params = regexUtil.extractAllRegexResults(regex: "(\\w+)(?= #)", text: result)
        for strI in params{
            let temp:UniqueItemSizeLimitedPriorityQueue = wordToList[strI]!
            let s1:String = temp.getRndItem()
            result2 = result.replacingOccurrences(of: strI + " #", with: s1)
        }
        if !result2.contains("#"){return result2}
        return clearRecursion(result: result2)
    }
    func addParam(category:String, value1:String){
        wordToList[category]?.input(in1: value1)
    }
    func addParam(kv:AXKeyValuePair){
        wordToList[kv.getKey()]?.input(in1: kv.getValue())
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
cool, I wanna slim the remaining 2 classes ngl tbh tbf tbph tbqh ngl ngl
gonna as well. aha aha yes I am. cause I am based, yes indeed.
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class TODOListManager {
    private UniqueItemSizeLimitedPriorityQueue q1 = new UniqueItemSizeLimitedPriorityQueue();
    private UniqueItemSizeLimitedPriorityQueue backup = new UniqueItemSizeLimitedPriorityQueue();
    private DrawRnd d1 = new DrawRnd();

    public TODOListManager(int todoLim) {
        q1.setLimit(todoLim);
        backup.setLimit(todoLim);
    }

    public void addElement(String e1){
        q1.add(e1);
    }
    public String getTask(){
        String temp = q1.poll();
        if(!temp.isEmpty()){backup.add(temp);}
        return temp;
    }
    public String getOldTask(){
        return backup.getRNDElement();
    }
    public void clearAllTasks(){
        q1.clear();
        backup.clear();
    }
    public void clearTask(String task){
        q1.removeItem(task);
        backup.removeItem(task);
    }
}
 

fukurou

the supreme coder
ADMIN
Swift:
class TODOListManager{
    /* manages to do tasks.
    q1 tasks are mentioned once, and forgotten
    backup tasks are the memory of recently mentioned tasks
    * */
    var q1:UniqueItemSizeLimitedPriorityQueue = UniqueItemSizeLimitedPriorityQueue()
    var backup:UniqueItemSizeLimitedPriorityQueue = UniqueItemSizeLimitedPriorityQueue()
    init(todoLim:Int) {
        self.q1.setLimit(lim: todoLim)
        self.backup.setLimit(lim: todoLim)
    }
    func addTask(e1:String){
        q1.input(in1: e1)
    }
    func getTask()->String{
        let temp:String = self.q1.poll()
        if !temp.isEmpty {backup.input(in1: temp)}
        return temp
    }
    func getOldAnTask()->String{
        // task graveyard (tasks you've tackled already)
        return backup.getRndItem()
    }
    func clearAllTasks(){
        q1.clearData()
        backup.clearData()
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class PersistantQuestion {
    private Boolean isActive = false;
    private String mode = "yes"; // key mode
    private Hashtable<String, DrawRnd>dic = new Hashtable<>();
    private OutputDripper outputDripper = new OutputDripper(1);
    private String loggedAnswer = ""; // only used in log() which replaces process()

    public String getLoggedAnswer() {
        return loggedAnswer;
    }

    public void setLoggedAnswer(String loggedAnswer) {
        this.loggedAnswer = loggedAnswer;
    }

    public void addPath(String answer, DrawRnd nags){
        dic.put(answer,nags);
    }
    public void activate(){isActive = true;}
    public void deActivate(){
        isActive = false;
        dic.get(mode).reset();
    }
    public String process(String inp){
        // got answer?
        if (dic.containsKey(inp)){
            mode = inp;
            isActive = false;
            dic.get(mode).reset();
            return "okay"; // can extend code to reply key, rnd finalizer
        }
        // nag for answer
        if (!outputDripper.drip()) {return "";}
        String result = dic.get(mode).draw();
        if (!result.isEmpty()){return result;}
        else {dic.get(mode).reset();isActive = false; return "i see";}
    }
    public String log(String inp){
        // got answer?
        if (dic.containsKey(inp)){
            mode = inp;
            loggedAnswer = inp;
            isActive = false;
            dic.get(mode).reset();
            return "okay"; // can extend code to reply key, rnd finalizer
        }
        if (!inp.isEmpty()){
            loggedAnswer = inp;
            isActive = false;
            dic.get(mode).reset();
            return "okay"; // can extend code to reply key, rnd finalizer
        }
        // nag for answer
        if (!outputDripper.drip()) {return "";}
        String result = dic.get(mode).draw();
        if (!result.isEmpty()){return result;}
        else {dic.get(mode).reset();isActive = false; return "i see";}
    }

    public String getMode() {
        return mode;
    }

    public void setMode(String mode) {
        this.mode = mode;
    }
    public void setPause(int pause){
        // set pause between question to wait for answer
        this.outputDripper.setLimit(pause);
    }
}
 
Top