AX beefup

owly

闇の伝説
Staff member
戦闘 コーダー
tolerance trigger
Swift:
class TrgRnd:TrGEV3{
    var reps:Int = 0
    var maxReps:Int = 2
    override init() {
    }
    init(maxReps:Int) {
        self.maxReps = maxReps
    }
    override func reset() {
        // refill trigger
        reps = Int.random(in: 0...maxReps)
    }
    override func trigger() -> Bool {
        // connect to input filter with trigger 2
        if reps > 0 {
            reps-=1
            return true
        }
        return false
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

import java.util.Random;

public class TrgTolerance extends TrGEV3{
    // this boolean gate will return true till depletion or reset()
    private int repeats = 0;
    private int maxrepeats = 2;
    private Random rand = new Random();
    public TrgTolerance(int maxrepeats) {
        this.maxrepeats = maxrepeats;
    }

    public void setMaxrepeats(int maxrepeats) {
        this.maxrepeats = maxrepeats;
        reset();
    }

    @Override
    public void reset() {
        // refill trigger
        repeats = rand.nextInt(maxrepeats);
    }

    @Override
    public Boolean trigger() {
        // will return true till depletion or reset()
        if (repeats > 0) {
            repeats--;
            return true;
        }
        return false;
    }
}
:s66:
 

owly

闇の伝説
Staff member
戦闘 コーダー
Swift:
class TrgMinute:TrGEV3{
    // trigger true at minute once per hour
    var hour1:Int = -1
    let minute:Int
    override init() {
        minute = Int.random(in: 0...59)
    }
    init(minute:Int) {
        self.minute = minute
    }
    let pl:PlayGround = PlayGround()
    override func trigger() -> Bool {
        let tempHour:Int = pl.getHoursAsInt()
        if tempHour != hour1 {
            if pl.getMinutesAsInt() == minute {
                hour1 = tempHour
                return true
            }
        }
        return false
    }
    override func reset() {
        hour1 = -1
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

import LivinGrimoire.PlayGround;

import java.util.Random;

public class TrgMinute extends TrGEV3{
    // trigger true at minute once per hour
    private int hour1 = -1;
    int minute;
    private Random rand = new Random();
    private PlayGround pl = new PlayGround();
    public TrgMinute() {
        minute = rand.nextInt(60);
    }

    public TrgMinute(int minute) {
        this.minute = minute;
    }

    @Override
    public Boolean trigger() {
        int tempHour = pl.getHoursAsInt();
        if(tempHour!=hour1){
            if(pl.getMinutesAsInt() == minute){
                hour1 = tempHour;
                return true;
            }
        }
        return false;
    }

    @Override
    public void reset() {
        hour1 = -1;
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Swift:
class TrgParrot:TrGEV3{
    var maxTolerance:Int = 10
    var tolerance:Int = 10
    var kokoro:Kokoro
    // responses
    var defaultResponse:Responder = Responder("hadouken","talk","chi3","chi4","shoryuken")
    let repeatedResponder:RepeatedElements = RepeatedElements()
    let forcedResponses:ForcedLearn = ForcedLearn()
    let replenisher:String = "hey"
    private(set) var output:String = ""
    var convo:Bool = false
    let pl:PlayGround = PlayGround()
    var trgMinute:TrgMinute = TrgMinute()
    let shutUp:Responder = Responder("ok","okay","stop","shut up","quiet")
    let emoRecognizer:EmoRecognizer = EmoRecognizer()
    init(kokoro:Kokoro) {
        self.kokoro = kokoro
    }
    override func reset() {
        // replenish
        tolerance = maxTolerance
    }
    override func trigger() -> Bool {
        return false
    }
    override func input(ear: String, skin: String, eye: String) {
        // learn new responses
        if !ear.contains(forcedResponses.keyWord){
            repeatedResponder.input(in1: ear)}
        forcedResponses.input(in1: ear)
        if pl.isNight() {return}
        // force convo
        if ear == replenisher {
            reset();calcResponse(ear: ear)
            convo = true
            return
        }
        if kokoro.standBy {
            reset()
            convo = false
            return
        }
        // shut up ()
        if shutUp.contains(str: ear){
            reset()
            convo = false
            return
        }
        // engage or continue convo
        if detectedInput(ear: ear) {
            if tolerance == 0 {convo = false}
            else if !ear.isEmpty {tolerance -= 1;calcResponse(ear: ear);return}
        }
        if trgMinute.trigger() {
            calcResponse(ear: ear)
        }
    }
    func calcResponse(ear:String) {
        let path:Int = Int.random(in: 0...2)
        if emoRecognizer.isAngry(in1: ear) {
            output = "chii angry";return
        }
        if emoRecognizer.isCurious(in1: ear) {
            output = "chii Curious";return
        }
        if emoRecognizer.isHappy(in1: ear) {
            output = "chii Happy";return
        }
        switch (path)  {
        case 1:
            output = forcedResponses.getRandomElement()
        case 2:
            output = repeatedResponder.getRandomElement()
        default:
            output = defaultResponse.getAResponse()
        }
    }
    func detectedInput(ear: String) -> Bool {
        if defaultResponse.contains(str: ear) || forcedResponses.contains(str: ear) || repeatedResponder.contains(str: ear){
            convo = true
        }
        return convo
    }
    func getOutput() -> String{
        let temp = output;output = ""
        return temp
    }
    func setMaxTolerance(newMaxTolerance:Int) {
        maxTolerance = newMaxTolerance
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

import LivinGrimoire.PlayGround;

public class TrgParrot {
    // simulates a parrot chirp trigger mechanism
    // as such this trigger is off at night
    // in essence this trigger says: I am here, are you here? good.
    private TrgTolerance tolerance = new TrgTolerance(5);
    private Responder silencer = new Responder("ok","okay","stop","shut up","quiet");
    private PlayGround pl = new PlayGround();

    public void setTolerance(int limit) {
        if(limit>0){
        this.tolerance = new TrgTolerance(limit);}
    }

    public Boolean trigger(Boolean standBy, String ear){
        // relies on the Kokoro standby boolean
        // no input or output for a set amount of time results with a true
        // and replenishing the trigger.
        if(pl.isNight()){
            // is it night? I will be quite
            return false;
        }
        // you want the bird to shut up?
        if(silencer.responsesContainsStr(ear)){
            tolerance.disable();
            return false;
        }
        // no input or output for a while?
        if(standBy){
            // I will chirp
            tolerance.reset();;
            return true;
        }
        // we are handshaking?
        if(!ear.isEmpty()){
            // I will reply chirp till it grows old for me (a set amount of times till reset)
            if(tolerance.trigger()){
                return true;
            }
        }
        return false;
    }
}
:s74:
 

owly

闇の伝説
Staff member
戦闘 コーダー
Swift:
class UniqueItemsPriorityQue{
    /// a priority queue without repeating elements
    var p1:PriorityQueue<String> = PriorityQueue<String>()
    var queLimit:Int = 5
    init() {
    }
    init(queLimit:Int) {
        self.queLimit = queLimit
    }
    init(_items:String...) {
        self.queLimit = _items.count
        for item in _items{
            p1.insert(item)
        }
    }
    /// insert an item into the queue
    func input(in1:String) {
        if !p1.elements.contains(in1){
            p1.insert(in1)
            if p1.size() > queLimit {p1.poll()}
        }
    }
    func contains(str:String) -> Bool {
        return p1.elements.contains(str)
    }
    @discardableResult
    func poll() -> String {
        guard !p1.isEmpty() else {
        return ""
      }
        return p1.elements.removeFirst()
    }
      func size() -> Int {
          return p1.size()
      }
    @discardableResult
    func peak() -> String {
        guard !p1.isEmpty() else {
        return ""
      }
        return p1.elements[0]
    }
    func deleteStr(str1:String){
        for i in 0...p1.size()-1 {
            if p1.elements[i] == str1 {
                p1.elements.remove(at: i)
                break
            }
        }
    }
    func getRndItem()-> String{
        guard !p1.isEmpty() else {
        return ""
      }
        return p1.elements.randomElement()!
    }
    func clearData() {
        p1 = PriorityQueue<String>()
    }
  }
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

import LivinGrimoire.LGFIFO;

public class UniqueItemsPriorityQue extends LGFIFO<String>{
    // a priority queue without repeating elements
    @Override
    public void add(String item) {
        if(!super.contains(item)){
        super.add(item);}
    }
}

Java:
package AXJava;

public class UniqueItemSizeLimitedPriorityQueue extends UniqueItemsPriorityQue{
    private int limit = 5;

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    @Override
    public void add(String item) {
        if(super.size()<limit){
        super.add(item);}
    }

    @Override
    public String poll() {
        String temp = super.poll();
        if (temp == null){
            return "";
        }
        return temp;
    }
}
:s75:
 

owly

闇の伝説
Staff member
戦闘 コーダー
Swift:
class TrgCountDown {
    var maxCount:Int = 2
    var count:Int
    init() {
        count = maxCount
    }
    init(limit:Int) {
        count = limit
        maxCount = limit
    }
    @discardableResult
    func countDown() -> Bool{
        count -= 1
        if (count == 0) {
            reset()
            return true
        }
        return false
    }
    func reset() {
        count = maxCount
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Swift:
class AXLearnability {
    var defcons:UniqueItemsPriorityQue = UniqueItemsPriorityQue()
    var algSent:Bool = false
    var goal:UniqueItemsPriorityQue = UniqueItemsPriorityQue()
    var defcon5:UniqueItemsPriorityQue = UniqueItemsPriorityQue()
    let trg:TrgCountDown = TrgCountDown() // set lim
    func pendAlg() {
        // an algorithm has been deployed
        algSent = true
        trg.countDown()
    }
    func mutateAlg(input:String) -> Bool {
        // 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:
package AXJava;

public class AXLearnability {
    private Boolean algSent = false;
    // problems that may result because of the last deployed algorithm:
    public UniqueItemSizeLimitedPriorityQueue defcons = new UniqueItemSizeLimitedPriorityQueue();// default size = 5
    // major chaotic problems that may result because of the last deployed algorithm:
    public UniqueItemSizeLimitedPriorityQueue defcon5 = new UniqueItemSizeLimitedPriorityQueue();
    // goals the last deployed algorithm aims to achieve:
    public UniqueItemSizeLimitedPriorityQueue goals = new UniqueItemSizeLimitedPriorityQueue();
    // how many failures / problems till the algorithm needs to mutate (change)
    public TrgTolerance trgTolerance;

    public AXLearnability(int tolerance) {
        this.trgTolerance = new TrgTolerance(tolerance);
    }
    public void pendAlg(){
        // an algorithm has been deployed
        // call this method when an algorithm is deployed (in a DiSkillV2 object)
        algSent = true;
        trgTolerance.trigger();
    }
    public void pendAlgWithoutConfirmation(){
        // an algorithm has been deployed
        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
    }
    public Boolean mutateAlg(String input){
        // recommendation to mutate the algorithm ? true/ false
        if (!algSent) {return false;} // no alg sent=> no reason to mutate
        if (goals.contains(input)){trgTolerance.reset();algSent = false;return false;}
        // goal manifested the sent algorithm is good => no need to mutate the alg
        if (defcon5.contains(input)) {trgTolerance.reset();algSent = false; return true;}
        // ^ something bad happend probably because of the sent alg
        // recommend alg mutation
        if (defcons.contains(input)){algSent = false;return trgTolerance.trigger();}
        // ^ negative result, mutate the alg if this occures too much
        return false;
    }
}

it's all about shenanigans :s63:
 

fukurou

the supreme coder
ADMIN
Swift:
class SpiderSense {
    /// enables event prediction
    private var spiderSense:Bool = false
    var events:UniqueItemsPriorityQue = UniqueItemsPriorityQue()
    var alerts:UniqueItemsPriorityQue = UniqueItemsPriorityQue()
    var prev:String = ""
    init() {
    }
    /// event's predictions become event's predictions, enabling  earlier but less
    ///  aqurate predictions, these can be used in detective work
    init(lv1:SpiderSense) {
        self.events = lv1.events
    }
    /// input param  can be run through an input filter prior to this function
    /// weather related data (sky state) only for example for weather events predictions
    func learn(in1:String) {
        // simple prediction of an event from the events que :
        if alerts.contains(str: in1){
            spiderSense = true;return
        }
        // event has occured, remember what lead to it
        if events.contains(str: in1){
            alerts.input(in1: prev);return
        }
        // nothing happend
        prev = in1
    }
    func getSpiderSense() -> Bool {
        // spider sense is tingling
        let t = spiderSense;spiderSense = false
        return t
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

import LivinGrimoire.DeepCopier;

import java.util.ArrayList;

public class SpiderSense {
// enables event prediction
    private Boolean spiderSense = false;
    private UniqueItemSizeLimitedPriorityQueue events = new UniqueItemSizeLimitedPriorityQueue();
    private UniqueItemSizeLimitedPriorityQueue alerts = new UniqueItemSizeLimitedPriorityQueue();
    private String prev = "";
    public SpiderSense addEvent(String event){
// builder pattern
        events.add(event);
        return this;
    }
// input param  can be run through an input filter prior to this function
    // weather related data (sky state) only for example for weather events predictions
    public void learn(String in1){
// simple prediction of an event from the events que :
        if (alerts.contains(in1)){
spiderSense = true;return;
        }
// event has occured, remember what lead to it
        if (events.contains(in1)){
alerts.add(prev);return;
        }
// nothing happend
        prev = in1;
    }

public Boolean getSpiderSense() {
// spider sense is tingling? event predicted?
        Boolean temp = spiderSense; spiderSense = false;
        return temp;
    }
public ArrayList<String> getAlertsShallowCopy(){
// return shallow copy of alerts list
        return alerts.getElements();
    }
public ArrayList<String> getAlertsClone(){
// return deep copy of alerts list
        DeepCopier dc = new DeepCopier();
        return dc.copyList(alerts.getElements());
    }
}
:s33:
 
Last edited:
Top