👨‍💻 dev new AXs

development

owly

闇の伝説
Staff member
戦闘 コーダー
Code:
**********
*%dripper*
**********
limis = 35
setLimis
drip()->bool
return rnd(100) < limis
dripPlus(int n)->bool
return rnd(100) < limis + n

*****************
*AXNPC:Responder*
*****************
dripper:%dripper
@override
respond()->str
 if dripper.drip(): return responder.response()
 return ""

respondPlus(n)->str
 if dripper.dripPlus(n): return responder.response()
 return ""


***************
*AXResponseDic*
***************
replyDic{str,Responder}
add(key,value)
respond(key)->str:
if !dripper.drip : return ""
return replyDic.getOrDefault(key,"")

**********************************
*AXTimeContextReply:AXResponseDic*
**********************************
init()
replyDic[morning] = new Responder()
...

@override
add(key,value):
 if dic.containsKey(key):
  dic[key].add(value)

@override
 respond(key)->str:
  if dic.containsKey(key):
   return super.respond(key)
  return dic[TOfDay].response()
 

owly

闇の伝説
Staff member
戦闘 コーダー
new sitter skill
Code:
public responder1 = AXTimeContextReply
public responder2 = AXResponseDic()

if ear = "i am bored"
 tStr = responder1.respond()
 if !tStr.isEmpty : alg(tStr);return;

tStr = responder2.respond()
if !tStr.isEmpty : alg(tStr);

new NPC skill:
Code:
// learn

tStr2 = cmdBreaker(ear) // say
if !tStr2.isEmpty: tempResponder.add(tStr2); alg("ok");return

if ear = "set dirty talk": responder = tempResponder;
 tempResponder = Responder(); alg("ok");return

// engage

if ear = "dirty talk":
 gate.open()
if ear.contains("stop"):
 gate.close()

if gate.isOpen():
 tStr = ""
 if ear = ""
  tStr = npc.response()
 else
  tStr = npc.responsePlus()
 if !tStr.isEmpty(): alg(tStr)
 

fukurou

the supreme coder
ADMIN
2645
Java:
public class PercentDripper {
    private DrawRnd dr = new DrawRnd();
    private int limis = 35;

    public void setLimis(int limis) {
        this.limis = limis;
    }
    public boolean drip(){
        return dr.getSimpleRNDNum(100) < limis;
    }
    public boolean dripPlus(int plus){
        return dr.getSimpleRNDNum(100) < limis + plus;
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
down that coffee slug
we have waifubots to code :s45:
 

fukurou

the supreme coder
ADMIN
Java:
public class AXNPC {
    public Responder responder = new Responder();
    public PercentDripper dripper = new PercentDripper();
    public String respond(){
        if (dripper.drip()){
            return responder.getAResponse();
        }
        return "";
    }
    public String respondPlus(int plus){
        // increase rate of output
        if (dripper.dripPlus(plus)){
            return responder.getAResponse();
        }
        return "";
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class Catche {
    // limited sized dictionary
    private int limit;
    private UniqueItemSizeLimitedPriorityQueue keys;
    private Hashtable<String,String> d1 = new Hashtable<>();
    public Catche(int size) {
        this.limit = size;
        this.keys = new UniqueItemSizeLimitedPriorityQueue();
        this.keys.setLimit(size);
    }
    public void insert(String key,String value){
        // update
        if (d1.contains(key)){
            d1.put(key,value);
            return;
        }
        // insert
        if (keys.size() == limit){
            String temp = keys.peak();
            d1.remove(key);
        }
        keys.add(key);
        d1.put(key,value);
    }
    public void clear() {
        keys.clear();
        d1.clear();
    }
    public String read(String key){
        return d1.getOrDefault(key,"null");
    }
}
 

fukurou

the supreme coder
ADMIN
we could brew this mofo to a neurosama:
value->sizelimitedQ
insert values using f'strings with learned params per category.

shit inDSman!
 

owly

闇の伝説
Staff member
戦闘 コーダー
we could brew this mofo to a neurosama:
value->sizelimitedQ
insert values using f'strings with learned params per category.

shit inDSman!
you can't use fstrings like det fuckwad, we need to use the perchance exploit
 

fukurou

the supreme coder
ADMIN
Java:
import LivinGrimoire.RegexUtil;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Random;

public class ChatBot {
    protected ArrayList<String> sentences = new ArrayList<String>();
    protected Hashtable<String, RefreshQ> wordToList = new Hashtable<>();
    protected Random rand = new Random();
    private RegexUtil regexUtil = new RegexUtil();
    protected Hashtable<String, String> allParamRef = new Hashtable<>();

    public String talk() {
        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.put(category, new RefreshQ());
        }
        wordToList.get(category).add(value);
        allParamRef.put(value,category); // for learnV2
    }
    public void addParam(AXKeyValuePair kv){
        if(!(wordToList.containsKey(kv.getKey()))){
            wordToList.put(kv.getKey(), new RefreshQ());
        }
        wordToList.get(kv.getKey()).add(kv.getValue());
        allParamRef.put(kv.getValue(),kv.getKey()); // for learnV2
    }
    public void addSentence(String sentence){
        this.sentences.add(sentence);
    }
    public void learn(String s1){
        for (String key : wordToList.keySet()) {
            s1 = s1.replace(key, String.format("%s #", key));
        }
        sentences.add(s1);
    }
    public void learnV2(String s1){
        for (String key : allParamRef.keySet()) {
            s1 = s1.replace(key, String.format("%s #", allParamRef.get(key)));
        }
        sentences.add(s1);
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
import LivinGrimoire.RegexUtil;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Random;

public class ChatBot {
    protected RefreshQ sentences = new RefreshQ();
    protected Hashtable<String, RefreshQ> wordToList = new Hashtable<>();
    protected Random rand = new Random();
    private RegexUtil regexUtil = new RegexUtil();
    protected Hashtable<String, String> allParamRef = new Hashtable<>();

    public String talk() {
        String result = sentences.getRNDElement();
        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);
        }
    }
    // learn on init:
    public void addParam(String category, String value){
        if(!(wordToList.containsKey(category))){
            wordToList.put(category, new RefreshQ());
        }
        wordToList.get(category).add(value);
        allParamRef.put(value,category); // for learnV2
    }
    public void addParam(AXKeyValuePair kv){
        if(!(wordToList.containsKey(kv.getKey()))){
            wordToList.put(kv.getKey(), new RefreshQ());
        }
        wordToList.get(kv.getKey()).add(kv.getValue());
        allParamRef.put(kv.getValue(),kv.getKey()); // for learnV2
    }
    public void addSentence(String sentence){
        this.sentences.add(sentence);
    }
    public void learn(String s1){
        for (String key : wordToList.keySet()) {
            s1 = s1.replace(key, String.format("%s #", key));
        }
        sentences.add(s1);
    }
    // learn while code is running
    public void learnV2(String s1){
        for (String key : allParamRef.keySet()) {
            s1 = s1.replace(key, String.format("%s #", allParamRef.get(key)));
        }
        sentences.add(s1);
    }
    public void learnParam(String s1){
        if (!s1.contains("is a")){return;}
        String category = regexUtil.afterWord("is a",s1);
        if(!(wordToList.containsKey(category))){return;}
        String param = s1.replace("is a "+category,"");
        wordToList.get(category).add(param);
        allParamRef.put(param,category);
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

import LivinGrimoire.RegexUtil;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Random;

public class ChatBot {
    protected RefreshQ sentences = new RefreshQ();
    protected Hashtable<String, RefreshQ> wordToList = new Hashtable<>();
    protected Random rand = new Random();
    private RegexUtil regexUtil = new RegexUtil();
    protected Hashtable<String, String> allParamRef = new Hashtable<>();
    protected int paramLim = 5;
    protected RefreshQ loggedParams = new RefreshQ();

    public ChatBot(int logParamLim) {
        loggedParams.setLimit(logParamLim);
    }

    public void setSentencesLim(int lim){sentences.setLimit(lim);}

    public void setParamLim(int paramLim) {
        this.paramLim = paramLim;
    }

    public String talk() {
        String result = sentences.getRNDElement();
        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);
        }
    }
    // learn on init:
    public void addParam(String category, String value){
        if(!(wordToList.containsKey(category))){
            RefreshQ temp = new RefreshQ();
            temp.setLimit(paramLim);
            wordToList.put(category, temp);
        }
        wordToList.get(category).add(value);
        allParamRef.put(value,category); // for learnV2
    }
    public void addParam(AXKeyValuePair kv){
        if(!(wordToList.containsKey(kv.getKey()))){
            RefreshQ temp = new RefreshQ();
            temp.setLimit(paramLim);
            wordToList.put(kv.getKey(), temp);
        }
        wordToList.get(kv.getKey()).add(kv.getValue());
        allParamRef.put(kv.getValue(),kv.getKey()); // for learnV2
    }
    public void addSentence(String sentence){
        this.sentences.add(sentence);
    }
    public void learn(String s1){
        for (String key : wordToList.keySet()) {
            s1 = s1.replace(key, String.format("%s #", key));
        }
        sentences.add(s1);
    }
    // learn while code is running
    public void learnV2(String s1){
        for (String key : allParamRef.keySet()) {
            s1 = s1.replace(key, String.format("%s #", allParamRef.get(key)));
        }
        sentences.add(s1);
    }
    public void learnParam(String s1){
        if (!s1.contains("is a")){return;}
        String category = regexUtil.afterWord("is a",s1);
        if(!(wordToList.containsKey(category))){return;}
        String param = s1.replace("is a "+category,"");
        wordToList.get(category).add(param);
        allParamRef.put(param,category);
        loggedParams.add(s1);
    }
    public String getALoggedParam(){return  loggedParams.getRNDElement();}
}
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

import LivinGrimoire.RegexUtil;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Random;

public class ChatBot {
    /*
    * chatbot example use in main :
    *         // init
        ChatBot chatbot = new ChatBot(5);
        // set param categories (init stage):
        chatbot.addParam("name","jinpachi");
        chatbot.addParam("name","sakura");
        chatbot.addParam("verb","eat");
        chatbot.addParam("verb","code");
        // learn sentence at init stage(optiona):
        chatbot.addSentence("i can verb #");
        // learning params post init stage (code is running)
        chatbot.learnParam("ryu is a name");
        chatbot.learnParam("ken is a name");
        chatbot.learnParam("drink is a verb");
        chatbot.learnParam("rest is a verb");
        // learn sentences from input during code run stage
        chatbot.learnV2("hello ryu i like to code");
        chatbot.learnV2("greetings ken");
        for (int i = 1; i < 10; i++) {
            // gen speech
            System.out.println(chatbot.talk());
            // share params for other chatbot to learn
            System.out.println(chatbot.getALoggedParam());
            }
    * */
    protected RefreshQ sentences = new RefreshQ();
    protected Hashtable<String, RefreshQ> wordToList = new Hashtable<>(); // params
    protected Random rand = new Random(); // randomizer
    private RegexUtil regexUtil = new RegexUtil();
    protected Hashtable<String, String> allParamRef = new Hashtable<>();
    protected int paramLim = 5;
    protected RefreshQ loggedParams = new RefreshQ();
    private String conjuration = "is a";

    public ChatBot(int logParamLim) {
        loggedParams.setLimit(logParamLim);
    }

    public void setConjuration(String conjuration) {
        this.conjuration = conjuration;
    }

    public void setSentencesLim(int lim){sentences.setLimit(lim);}

    public void setParamLim(int paramLim) {
        this.paramLim = paramLim;
    }

    public String talk() {
        String result = sentences.getRNDElement();
        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);
        }
    }
    // learn on init:
    public void addParam(String category, String value){
        if(!(wordToList.containsKey(category))){
            RefreshQ temp = new RefreshQ();
            temp.setLimit(paramLim);
            wordToList.put(category, temp);
        }
        wordToList.get(category).add(value);
        allParamRef.put(value,category); // for learnV2
    }
    public void addParam(AXKeyValuePair kv){
        if(!(wordToList.containsKey(kv.getKey()))){
            RefreshQ temp = new RefreshQ();
            temp.setLimit(paramLim);
            wordToList.put(kv.getKey(), temp);
        }
        wordToList.get(kv.getKey()).add(kv.getValue());
        allParamRef.put(kv.getValue(),kv.getKey()); // for learnV2
    }
    // chatbot.addSentence("hello name #");
    public void addSentence(String sentence){
        this.sentences.add(sentence);
    }
    // chatbot.learn("hello name i like to verb");
    public void learn(String s1){
        for (String key : wordToList.keySet()) {
            s1 = s1.replace(key, String.format("%s #", key));
        }
        sentences.add(s1);
    }
    // learn while code is running
    public void learnV2(String s1){
        for (String key : allParamRef.keySet()) {
            s1 = s1.replace(key, String.format("%s #", allParamRef.get(key)));
        }
        sentences.add(s1);
    }
    public void learnParam(String s1){
        if (!s1.contains(conjuration)){return;}
        String category = regexUtil.afterWord(conjuration,s1);
        if(!(wordToList.containsKey(category))){return;}
        String param = s1.replace(conjuration +" "+category,"");
        wordToList.get(category).add(param);
        allParamRef.put(param.trim(),category);
        loggedParams.add(s1);
    }
    public String getALoggedParam(){return  loggedParams.getRNDElement();}
}
 
Top