DIBlabber

owly

闇の伝説
Staff member
戦闘 コーダー
we start off with the improved connand context:

Java:
public class AXContextCmd {
    // engage on commands
    // when commands are engaged, context commans can also engage
    public UniqueItemSizeLimitedPriorityQueue commands = new UniqueItemSizeLimitedPriorityQueue();
    public UniqueItemSizeLimitedPriorityQueue contextCommands = new UniqueItemSizeLimitedPriorityQueue();
    public Boolean trgTolerance  = false;
    public Boolean engageCommand(String s1){
        if (s1.isEmpty()){return false;}
        if (contextCommands.contains(s1)){
            trgTolerance = true;
            return true;
        }
        if (trgTolerance && !commands.contains(s1)){
            trgTolerance = false;
            return false;
        }
        return trgTolerance;
    }
    public void disable(){
        // context commands are disabled till next engagement with a command
        trgTolerance = false;
    }
}
@fukurou
 

fukurou

the supreme coder
ADMIN
Java:
public class AXContextCmd {
    // engage on commands
    // when commands are engaged, context commans can also engage
    public UniqueItemSizeLimitedPriorityQueue commands = new UniqueItemSizeLimitedPriorityQueue();
    public UniqueItemSizeLimitedPriorityQueue contextCommands = new UniqueItemSizeLimitedPriorityQueue();
    public Boolean trgTolerance  = false;
    public Boolean engageCommand(String s1){
        if (s1.isEmpty()){return false;}
        if (contextCommands.contains(s1)){
            trgTolerance = true;
            return true;
        }
        if (trgTolerance && !commands.contains(s1)){
            trgTolerance = false;
            return false;
        }
        return trgTolerance;
    }
    public void disable(){
        // context commands are disabled till next engagement with a command
        trgTolerance = false;
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
public class AXContextCmd {
    // engage on commands
    // when commands are engaged, context commans can also engage
    public UniqueItemSizeLimitedPriorityQueue commands = new UniqueItemSizeLimitedPriorityQueue();
    public UniqueItemSizeLimitedPriorityQueue contextCommands = new UniqueItemSizeLimitedPriorityQueue();
    public Boolean trgTolerance  = false;
    public Boolean engageCommand(String s1){
        if (s1.isEmpty()){return false;}
        if (contextCommands.contains(s1)){
            trgTolerance = true;
            return true;
        }
        if (trgTolerance && !commands.contains(s1)){
            trgTolerance = false;
            return false;
        }
        return trgTolerance;
    }
    public void disable(){
        // context commands are disabled till next engagement with a command
        trgTolerance = false;
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
public class AXNPC {
    public RefreshQ responder = new RefreshQ();
    public PercentDripper dripper = new PercentDripper();
    public AXCmdBreaker cmdBreaker = new AXCmdBreaker("say");

    public AXNPC(int replyStockLim, int outputChance) {
        responder.setLimit(replyStockLim);
        if (outputChance >0 && outputChance < 101){
            dripper.setLimis(outputChance);
        }
    }

    public String respond(){
        if (dripper.drip()){
            return responder.getRNDElement();
        }
        return "";
    }
    public String respondPlus(int plus){
        // increase rate of output
        if (dripper.dripPlus(plus)){
            return responder.getRNDElement();
        }
        return "";
    }
    public void learn(String ear){
        String temp = cmdBreaker.extractCmdParam(ear);
        if (temp.isEmpty()){return;}
        responder.add(temp);
    }
}
 

fukurou

the supreme coder
ADMIN
Python:
class AXContextCmd:
    # engage on commands
    # when commands are engaged, context commans can also engage
    def __init__(self):
        self.commands: UniqueItemSizeLimitedPriorityQueue = UniqueItemSizeLimitedPriorityQueue(5)
        self.contextCommands: UniqueItemSizeLimitedPriorityQueue = UniqueItemSizeLimitedPriorityQueue(5)
        self.trgTolerance: bool = False

    def engageCommand(self, s1: str) -> bool:
        if len(s1) == 0:
            return False
        # active context
        if self.contextCommands.contains(s1):
            self.trgTolerance = True
            return True
        # exit context:
        if self.trgTolerance and not self.commands.contains(s1):
            self.trgTolerance = False
            return False
        return self.trgTolerance

    def disable(self):
        # context commands are disabled till next engagement with a command
        self.trgTolerance = False
 

fukurou

the supreme coder
ADMIN
Python:
class AXNPC:
    def __init__(self, replyStackLim: int, outputChance: int):
        self.responder: RefreshQ = RefreshQ(replyStackLim)
        self.dripper = PercentDripper()
        if 0 < outputChance < 101:
            self.dripper.setLimit(outputChance)
        self.cmdBreaker: AXCmdBreaker = AXCmdBreaker("say")

    def respond(self) -> str:
        if self.dripper.drip():
            return self.responder.getRNDElement()
        return ""

    def respondPlus(self, plus) -> str:
        if self.dripper.dripPlus(plus):
            return self.responder.getRNDElement()
        return ""

    def learn(self, ear: str):
        temp: str = self.cmdBreaker.extractCmdParam(ear)
        if len(temp) == 0:
            return
        self.responder.insert(temp)
 

fukurou

the supreme coder
ADMIN
Swift:
class AXContextCmd{
    // engage on commands
    // when commands are engaged, context commans can also engage
    public var commands:UniqueItemSizeLimitedPriorityQueue = UniqueItemSizeLimitedPriorityQueue()
    public var contextCommands:UniqueItemSizeLimitedPriorityQueue = UniqueItemSizeLimitedPriorityQueue()
    private var trgTolerance:Bool = false
    func engageCommand(ear:String) -> Bool {
        if ear.isEmpty{return false}
        if contextCommands.contains(str: ear){
            trgTolerance = true
            return true
        }
        if trgTolerance && !commands.contains(str: ear){
            trgTolerance = false
            return false
        }
        return trgTolerance
    }
    func disable(){
        // context commands are disabled till next engagement with a command
        trgTolerance = false
    }
}
 

fukurou

the supreme coder
ADMIN
Swift:
class AXNPC {
    public var responder:RefreshQ = RefreshQ()
    public var dripper:PercentDripper = PercentDripper()
    public var cmdBreaker:AXCmdBreaker = AXCmdBreaker(conjuration: "say")
    init(replyStockLim:Int,outputChance:Int) {
        responder.setLimit(lim: replyStockLim)
        if 0 < outputChance && outputChance < 101{
            dripper.setLimis(outputChance)
        }
    }
    
    func respond() -> String {
        if dripper.drip() {
            return responder.getRndItem()
        }
        return ""
    }
    func respondPlus(plus:Int) -> String {
        if dripper.dripPlus(plus) {
            return responder.getRndItem()
        }
        return ""
    }
    
    func learn(ear:String) {
        let temp:String = cmdBreaker.extractCmdParam(s1: ear)
        if temp.isEmpty {return}
        responder.input(in1: temp)
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
import AXJava.AXContextCmd;
import AXJava.AXNPC;
import AXJava.Cycler;
import LivinGrimoire.DiSkillV2;

public class DIBlabber extends DiSkillV2 {
    private Boolean isActive = true; // skill toggle
    public AXContextCmd skillToggler = new AXContextCmd();
    // chat mode select
    public AXContextCmd modeSwitch = new AXContextCmd();
    protected Cycler mode = new Cycler(1); // chat-bot mode
    // engage chatbot
    public AXContextCmd engage = new AXContextCmd();
    // chatbots
    public AXNPC chatbot1 = new AXNPC(30,90);
    public AXNPC chatbot2 = new AXNPC(30,90);
    public DIBlabber(String skill_name) {
        skillToggler.contextCommands.add("toggle " + skill_name);
        skillToggler.commands.add("again");skillToggler.commands.add("repeat");
        modeSwitch.contextCommands.add("switch " + skill_name + "mode");
        modeSwitch.commands.add("again");modeSwitch.commands.add("repeat");
        engage.contextCommands.add("switch " + skill_name + "mode");engage.contextCommands.add("talk");
        engage.contextCommands.add("talk to me");
        engage.commands.add("again");engage.commands.add("repeat");
    }

    @Override
    public void input(String ear, String skin, String eye) {
        // skill toggle:
        if(skillToggler.engageCommand(ear)){isActive = !isActive;}
        if (!isActive){return;}
        // chat-bot mode switch mode
        if(modeSwitch.engageCommand(ear)){
            mode.cycleCount();
            this.outAlg = this.diSkillUtils.simpleVerbatimAlgorithm("blabber","mode switched");
        }
        switch (mode.getMode()){
            case 0:
                mode0(ear);
                break;
            case 1:
                mode1(ear);
                break;
        }
    }
    private void mode0(String ear) {
        chatbot1.learn(ear);
        String result = "";
        if (engage.engageCommand(ear)) {
            result = chatbot1.respond();
            if (!result.isEmpty()) {
                setVerbatimAlg(4, result);
                return;
            }
        }
        result = chatbot1.strRespond(ear);
        if (!result.isEmpty()) {
            setVerbatimAlg(4, result);
        }
    }
    private void mode1(String ear) {
        chatbot2.learn(ear);
        String result = "";
        if (engage.engageCommand(ear)) {
            result = chatbot2.respond();
            if (!result.isEmpty()) {
                setVerbatimAlg(4, result);
            }
        }
    }
}
 
Top