AX beefup

fukurou

the supreme coder
ADMIN
Swift:
class SkillHubAlgDispenser {
    /// super class to output an algorithm out of a selection of skills
    ///  engage the hub with dispenseAlg and return the value to outAlg attribute
    ///  of the containing skill (which houses the skill hub)
    ///  this module enables using a selection of 1 skill for triggers instead of having the triggers engage on multible skill
    ///   the methode is ideal for learnability and behavioral modifications
    ///   use a learnability auxiliary module as a condition to run an active skill shuffle or change methode
    ///   (rndAlg , cycleAlg)
    ///   moods can be used for specific cases to change behavior of the AGI, for example low energy state
    ///   for that use (moodAlg)
    var skills:Array<DiSkillV2> = [DiSkillV2]()
    var activeSkill:Int = 0
    init(_skills:DiSkillV2...){
        for skill in _skills {
            self.skills.append(skill)
        }
    }
    func addSkill(skill:DiSkillV2) -> SkillHubAlgDispenser {
        self.skills.append(skill)
        return self
    }
    func dispenseAlgorithm(ear:String, skin:String, eye:String) -> Algorithm? {
        skills[activeSkill].input(ear: ear, skin: skin, eye: eye)
        return skills[activeSkill].outAlg
    }
    func rndAlg(){
        activeSkill = Int.random(in: 0..<skills.count)
    }
    func moodAlg (mood:Int){
        let c1:Int = skills.count
        if -1<mood && mood<c1 {
            activeSkill = mood
        }
    }
    func cycleAlg(){
        activeSkill += 1
        if activeSkill == skills.count {activeSkill = 0}
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

import LivinGrimoire.Algorithm;
import LivinGrimoire.DiSkillV2;
import LivinGrimoire.Neuron;

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

public class SkillHubAlgDispenser {
    // super class to output an algorithm out of a selection of skills
    //  engage the hub with dispenseAlg and return the value to outAlg attribute
    //  of the containing skill (which houses the skill hub)
    //  this module enables using a selection of 1 skill for triggers instead of having the triggers engage on multible skill
    //   the methode is ideal for learnability and behavioral modifications
    //   use a learnability auxiliary module as a condition to run an active skill shuffle or change methode
    //   (rndAlg , cycleAlg)
    //   moods can be used for specific cases to change behavior of the AGI, for example low energy state
    //   for that use (moodAlg)
    private ArrayList<DiSkillV2> skills = new ArrayList<DiSkillV2>();
    private int activeSkill = 0;
    private Neuron tempN = new Neuron();;
    private Random rand = new Random();
    public SkillHubAlgDispenser(DiSkillV2...skillsParams) {
        for (DiSkillV2 skill : skillsParams)
        {
            skills.add(skill);
        }
    }
    public SkillHubAlgDispenser addSkill(DiSkillV2 skill){
        // builder pattern
        skills.add(skill);
        return this;
    }
    public Algorithm dispenseAlgorithm(String ear, String skin, String eye){
        // return value to outAlg param of (external) summoner DiskillV2
        skills.get(activeSkill).input(ear,skin,eye);
        tempN.empty();
        skills.get(activeSkill).output(tempN);
        if (!tempN.negativeAlgParts.isEmpty()){
            return tempN.negativeAlgParts.get(0);
        }
        if (!tempN.algParts.isEmpty()){
            return tempN.algParts.get(0);
        }
        return null;
    }
    public void randomizeActiveSkill(){
        activeSkill = rand.nextInt(skills.size());
    }
    public void setActiveSkillWithMood(int mood){
        // mood integer represents active skill
        // different mood = different behavior
        if ((mood>-1) && mood < (skills.size())){
            activeSkill = mood;
        }
    }
    public void cycleActiveSkill(){
        // changes active skill
        // I recommend this method be triggered with a Learnability or SpiderSense object
        activeSkill++;
        if (activeSkill == skills.size()){
            activeSkill = 0;
        }
    }
}
:s78:
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

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

public class Responder {
    // simple random response dispenser
    private ArrayList<String> responses = new ArrayList<String>();
    private Random rand = new Random();
    public Responder(String... replies) {
        for (int i = 0; i < replies.length; i++) {
            responses.add(replies[i]);
        }
    }
    public String getAResponse(){
        if (responses.isEmpty()){
            return "";
        }
        return responses.get(rand.nextInt(responses.size()));
    }
    public Boolean responsesContainsStr(String str){
        return responses.contains(str);
    }
    public Boolean strContainsResponse(String str){
        Boolean result = false;
        for (String tempStr: responses) {
            if (str.contains(tempStr)){
                result = true;
                break;
            }
        }
        return result;
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Swift:
let happy = Responder("good","awesome","great","wonderful","sweet","happy")
    let curious = Responder("why","where","when","how","who","which","whose")
    let angry = Responder("hiyas","fudge","angry","waste","stupid","retard")
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

public class EmoDetectorHappy extends Responder{
    public EmoDetectorHappy() {
        super("good","awesome","great","wonderful","sweet","happy");
    }
    public Boolean isHappy(String str){
        return super.strContainsResponse(str);
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
package AXJava;

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 "";
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Swift:
class RepeatedElements{
    // detects repeating elements
    let p1:PriorityQueue<String> = PriorityQueue<String>()
    let p2:PriorityQueue<String> = PriorityQueue<String>()
    var queLimit:Int = 5
    func input(in1:String) {
        if p1.elements.contains(in1){
            p2.insert(in1)
            if p2.size() > queLimit {p2.poll()}
        }
        p1.insert(in1)
        if p1.size() > queLimit {p1.poll()}
    }
    func getRandomElement()->String{
        return p2.elements.randomElement() ?? ""
    }
    func contains(str:String) -> Bool {
        return p2.elements.contains(str)
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Swift:
class ForcedLearn{
    var keyWord:String = "say"
    let rUtil:RegexUtil = RegexUtil()
    let p1:PriorityQueue<String> = PriorityQueue<String>()
    var queLimit:Int = 5
    func input(in1:String) {
        if rUtil.firstWord(str2Check: in1).elementsEqual(keyWord){
            p1.insert(in1.replacingOccurrences(of: keyWord, with: "").trimmingCharacters(in: .whitespacesAndNewlines))
            if p1.size() > queLimit {p1.poll()}
        }
    }
    func getRandomElement()->String{
        return p1.elements.randomElement() ?? ""
    }
    func contains(str:String) -> Bool {
        return p1.elements.contains(str)
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

import LivinGrimoire.LGFIFO;
import LivinGrimoire.RegexUtil;

public class ForcedLearn {
   // remembers key inputs because they start with keyword
   // also can dispense key inputs
    public String keyword = "say";
    private LGFIFO<String> p1 = new LGFIFO<String>();
    private RegexUtil ru = new RegexUtil();
    private int queLimit = 5;

    public int getQueLimit() {
        return queLimit;
    }

    public void setQueLimit(int queLimit) {
        if(!(queLimit>0)){return;}
        this.queLimit = queLimit;
    }
    public void input(String in1){
        if (keyword.equals(ru.firstWord(in1))){
            p1.add(in1.replace(keyword,""));
            if (p1.size()>queLimit){
                p1.poll();
            }
        }
    }
    public String getRandomElement(){
        if (p1.isEmpty()){return "";}
        return p1.getRNDElement();
    }
    public Boolean contains(String item){
        return p1.contains(item);
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Swift:
// TRIGGERS
public class TrGEV3 {
    // advanced boolean gates with internal logic
    // these ease connecting common logic patterns, as triggers
    func reset() {
    }

    func input(ear:String, skin:String, eye:String) {
    }

    func trigger() -> Bool{
        return false;
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

public class TrGEV3 {
    // advanced boolean gates with internal logic
    // these ease connecting common logic patterns, as triggers
    public void reset(){}
    public void input(String ear, String skin, String eye) {
    }
    public Boolean trigger(){return false;}
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Swift:
class EV3DaisyChain {
    // this class connects several logic gates triggers together
    var trgGates:Array<TrGEV3> = [TrGEV3]()
    func EV3DaisyChain(_ gates:TrGEV3...) {
        for g8t:TrGEV3 in gates{
            trgGates.append(g8t)
        }
    }
    func reset() {
        for g8t:TrGEV3 in trgGates{
            g8t.reset()
        }
    }

    func input(ear:String, skin:String, eye:String) {
        for g8t:TrGEV3 in trgGates{
            g8t.input(ear: ear, skin: skin, eye: eye)
        }
    }

    func trigger() -> Bool{
        var result:Bool = true;
        for g8t:TrGEV3 in trgGates{
            result = result && g8t.trigger()
        }
        return result;
    }
}
I also want an or trigger
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

import LivinGrimoire.DiSkillV2;

import java.util.ArrayList;

public class EV3DaisyChainAndMode extends TrGEV3{
    // this class connects several logic gates triggers together
    private ArrayList<TrGEV3> trgGates = new ArrayList<TrGEV3>();

    public EV3DaisyChainAndMode(TrGEV3... gates) {
        for (TrGEV3 gate : gates)
        {
            trgGates.add(gate);
        }
    }

    @Override
    public void input(String ear, String skin, String eye) {
        for (TrGEV3 gate : trgGates)
        {
            gate.input(ear, skin, eye);
        }
    }

    @Override
    public void reset() {
        for (TrGEV3 gate : trgGates)
        {
            gate.reset();
        }
    }

    @Override
    public Boolean trigger() {
        for (TrGEV3 gate : trgGates)
        {
            if(!gate.trigger()){
                // not all gates return true
                return false;
            }
        }
        // all gates return true
        return true;
    }
}

Java:
package AXJava;

import java.util.ArrayList;

public class EV3DaisyChainOrMode extends TrGEV3{
    // this class connects several logic gates triggers together
    private ArrayList<TrGEV3> trgGates = new ArrayList<TrGEV3>();

    public EV3DaisyChainOrMode(TrGEV3... gates) {
        for (TrGEV3 gate : gates)
        {
            trgGates.add(gate);
        }
    }

    @Override
    public void input(String ear, String skin, String eye) {
        for (TrGEV3 gate : trgGates)
        {
            gate.input(ear, skin, eye);
        }
    }

    @Override
    public void reset() {
        for (TrGEV3 gate : trgGates)
        {
            gate.reset();
        }
    }

    @Override
    public Boolean trigger() {
        for (TrGEV3 gate : trgGates)
        {
            if(gate.trigger()){
                // at least 1 gate is engaged
                return true;
            }
        }
        // all gates are not engaged
        return false;
    }
}
 
Top