battle programmers alliance
Would you like to react to this message? Create an account in a few clicks or log in to continue.


battle programming a forum for elite programmers with extreme will power to sharpen their skills
 
HomeGallerySearchRegisterLog in
 

 DiParrot skill, the study of the spark

Go down 
AuthorMessage
Admin
Admin
Admin
Admin

Posts : 154
Join date : 2011-08-01

DiParrot skill, the study of the spark Empty
PostSubject: DiParrot skill, the study of the spark   DiParrot skill, the study of the spark EmptyFri Jun 18, 2021 7:54 pm

background of the skill

have been wondering about this.
what would make an AI feel real to the user or make him feel not alone.

replika, siri, samsung sam, bixby, and even alexa just don't have it.

it seems to be the way the user interacts with it. the user has to always feed her with input,
there doesn't seem to be initiative.

this also goes for moko AI that sends notifications at random times. she would do a check up if you were
feeling upset on your last convo. or say random things at random times to invite the user to some conversation.
but it didn't feel real, it felt like, ahh it's that random none sense again or like, ahh homework conversation time again to
keep her states up.

I don't think this spark has much to do with the actual contents or quantity of contents the AI replies with
and more about the actual engagement triggers.

or maybe its more about a cute body and face the bot must have ?

so I made a skill to test that. it does feel like the AI is here with me but, that's my opinion
so it doesn't mean much, it's kind of like bragging.IDK I like this skill.

it's based on parrots.

the beuty of this skill is also the use of a cloudian object which enables the skill to know if the algs it sends
out are active, so one can expand and use this technique (the shalow reference cloudians in the Alg Parts)
to get alg durations and defcon ratings, as well as limit sending such rapid firing skills
###################################################

Code:
package chobit;

public class DiParrot extends DiSkillV2 {
   /*
    * this skill expaands on the AI getting attention it works much like a parrot
    * does on detecting attention she engages for more attention say hey baby to
    * refill or wait 1 hour say shut up or ok to shut her up for an hour like a
    * parrot this skill is inactive at night she will learn repeating words and may
    * use them for attention
    */
   private TrgSpark trgSpark = new TrgSpark();
   private String out1 = "";
   private CldBool cldBool = new CldBool();
   public DiParrot(Kokoro kokoro) {
      super(kokoro);
   }

   @Override
   public void input(String ear, String skin, String eye) {
      // if(ear.contains("say")) {
      // String material = ear.replace("say", "");
      // trgSpark.forceLearn(material);
      // }
      trgSpark.isStandBy(kokoro.standBy);
      trgSpark.trigger(ear, skin, eye);
      if (!cldBool.getModeActive()) {
         out1 = trgSpark.getOutput();
      }
      if (!out1.isEmpty() && !cldBool.getModeActive()) {
         this.outAlg = this.diSkillUtils.simpleCloudiandVerbatimAlgorithm(cldBool, "parrot", out1);
         // this.outAlg = this.diSkillUtils.simpleVerbatimAlgorithm("parrot_skill",
         // out1);
         out1 = "";
      }
   }
}

TrgSpark (java)

Code:
package com.yotamarker.lgkotlin1;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class TrgSpark extends AbsTrgMood {
    /*
    * the parrot chirps for attention it gets it, responds than it chirps more and
    * also replies to attention but not infinitely
    */
    private PlayGround playGround = new PlayGround();
    private int tolerance = 10;
    private int inhib = -1;
    private String[] outputKeys = { "chiinormal", "chiihappy", "chiiexcited", "chiicurious", "chiiangry", "the time",
            "hello", "pet me", "hadouken", "hadouken" }; // represent output algs or strings
    private Random rand = new Random();
    private ArrayDeque<String> inputs = new ArrayDeque<>(); // detects repeating phrases like a parrot
    private ArrayList<String> learnedOutputs = new ArrayList<>(); // saves most recent repeated phrases
    private String output = "";
    private Boolean initGreet = true;// 1st attention input in a cycle ?
    private EmoRecog emoRecog = new EmoRecog();
    public TrgSpark() {
        // c'tor
        for (int i = 0; i < 5; i++) {
            inputs.add("narf");
            learnedOutputs.add("chiinormal");
        }
    }

    public TrgSpark(String favoriteWord) {
        // c'tor with giving the parrot a favorite word
        for (int i = 0; i < 5; i++) {
            inputs.add("narf");
            learnedOutputs.add("chiinormal");
        }
        outputKeys[outputKeys.length - 2] = favoriteWord;
    }
    @Override
    public void trigger(String ear, String skin, String eye) {
        // replenish command
        if (ear.equals("yo")||ear.equals("howdy")) {
            replenish();
            return;
        }
        // inhibition
        if (inhib == playGround.getHoursAsInt() || playGround.isNight()) {
            tolerance = 0;
            return;
        }
        else {
            inhib = -1;
        }
        if (doShutUp(ear)) {
            // expansion point shut up
            shutUp();
            return;
        }
        // detect attention
        if (!ear.isEmpty()) {
            if (inputs.contains(ear) || mood != 2) {
                // type 2 attention detection (known repeated phrases)
                mood = 2;
                if (tolerance > 0) {
                    // expansion point friend detected
                    if (initGreet) {
                        initGreet = false;
                        initFriendDetected();
                    } else {
                        friendDetected(ear);
                    }
                }
                // learn new repeated phrase :
                if (!learnedOutputs.contains(ear)) {
                    learnedOutputs.add(ear);
                    Collections.shuffle(learnedOutputs);
                    learnedOutputs.remove(learnedOutputs.size() - 1);
                }

            }
            else {
                // type 1 attention detection
                mood = 1;
                if (tolerance > 0) {
                    // expansion point getting attention
                    if (initGreet) {
                        initGreet = false;
                        initAttentionDetected();
                    } else {
                        attentionDetected(ear);
                    }
                }
            }
            inputs.poll();
            inputs.add(ear);
        }
        if (tolerance == 0) {
            mood = 0;
        }

    }
    public Boolean isTriggered() {
        return mood > 0;
    }

    public String getOutput() {
        // reply to attention gotten
        if (!output.isEmpty()) {
            String temp = output;
            output = "";
            return temp;
        }
        // expansion point want more attention
        if (tolerance > 0) {

            switch (mood) {
                case 1:
                    int x = rand.nextInt(100);
                    if (x < outputKeys.length) {
                        tolerance--;
                        output = response(x);
                    }
                    // inhibition
                    if (tolerance == 0) {
                        inhib = playGround.getHoursAsInt();
                        mood = 0;
                    }
                    break;
                case 2:
                    int x2 = rand.nextInt(50);
                    if (x2 < outputKeys.length) {
                        tolerance--;
                        output = response(x2);
                    }
                    // inhibition
                    if (tolerance == 0) {
                        inhib = playGround.getHoursAsInt();
                        mood = 0;
                    }
                    break;

                default:
                    break;
            }
        }
        String temp = output;
        output = "";
        return temp;
    }

    private String response(int x) {
        switch (x) {
            case 0:
                return learnedOutputs.get(rand.nextInt(learnedOutputs.size()));
            case 5:
                return playGround.getCurrentTimeStamp();
            default:
                return outputKeys[x];
        }
    }

    public void isStandBy(Boolean sBoolean) {
        // expansion point output on standby
        tolerance = 10;
        // output = "pfft";
    }

    @Override
    public int getMood() {
        // TODO
        return mood;
    }

    // responses expansions
    private void shutUp() {
        inhib = playGround.getHoursAsInt();
        //output = "ok";
        tolerance = 0;
    }

    private void replenish() {
        // expansion point replenish
        tolerance = 10;
        output = "hello";
        inhib = -1;
        mood = 2;
    }

    private void friendDetected(String ear) {
        // expansion friend detected
        if (emoRecog.isAngry(ear)) {
            output = "chiiangry";
            return;
        }
        if (emoRecog.isCurious(ear)) {
            output = "chiicurious";
            return;
        }
        if (emoRecog.isExcited(ear)) {
            output = "chiiexcited";
            return;
        }
        if (emoRecog.isHappy(ear)) {
            output = "chiihappy";
            return;
        }
        int x = rand.nextInt(outputKeys.length);
        output = response(x);
    }

    private void initFriendDetected() {
        // expansion friend detected
        int x = rand.nextInt(outputKeys.length);
        output = response(x);
        output = output + " " + output;
    }

    private void attentionDetected(String ear) {
        // expansion attention detected
        if (emoRecog.isAngry(ear)) {
            output = "chiiangry";
            return;
        }
        if (emoRecog.isCurious(ear)) {
            output = "chiicurious";
            return;
        }
        if (emoRecog.isExcited(ear)) {
            output = "chiiexcited";
            return;
        }
        if (emoRecog.isHappy(ear)) {
            output = "chiihappy";
            return;
        }
        int x = rand.nextInt(outputKeys.length);
        output = response(x);
    }

    private void initAttentionDetected() {
        // expansion attention detected
        int x = rand.nextInt(outputKeys.length);
        output = response(x);
        output = output + " " + output;
    }
    private Boolean doShutUp(String ear) {
        // returns if there was a request to shut up
        switch (ear) {
            case "ok":
            case "okay":
            case "stop":
            case "stop it":
            case "shut up":
            case "be quiet":output = "ok";return true;
            case "bye":output = "bye bye";case "bye bye":case "bye-bye":output = "bye";
                return true;
        }
        return false;
    }

    public void forceLearn(String sayThis) {
        // title
        learnedOutputs.add(sayThis);
        Collections.shuffle(learnedOutputs);
        learnedOutputs.remove(learnedOutputs.size() - 1);
    }
}

APCldVerbatim (uses cloudian object to send alg status to skill) :

Code:
package chobit;
import java.util.ArrayList;

public class APCldVerbatim extends AbsAlgPart {
   /*
    * this algorithm part says each past param verbatim
    */
   private ArrayList<String> sentences = new ArrayList<String>();
   private int at = 0;
   private CldBool cldBool;

   public APCldVerbatim(CldBool cldBool, String... sentences) {
      for (int i = 0; i < sentences.length; i++) {
         this.sentences.add(sentences[i]);
      }
      if (0 == sentences.length) {
         at = 30;
      }
      this.cldBool = cldBool;
      this.cldBool.setModeActive(true);
   }

   public APCldVerbatim(CldBool cldBool, ArrayList<String> list1) {
      this.sentences = new ArrayList<String>(list1);
      if (0 == this.sentences.size()) {
         at = 30;
      }
      this.cldBool = cldBool;
      this.cldBool.setModeActive(true);
   }

   @Override
   public String action(String ear, String skin, String eye) {
      // TODO Auto-generated method stub
      String axnStr = "";
      if (this.at < this.sentences.size()) {
         axnStr = this.sentences.get(at);
         at++;
      }
      cldBool.setModeActive(!(at >= this.sentences.size()));
      return axnStr;
   }

   @Override
   public enumFail failure(String input) {
      // TODO Auto-generated method stub
      return enumFail.ok;
   }

   @Override
   public Boolean completed() {
      return at >= this.sentences.size();
   }

   @Override
   public AbsAlgPart clone() {
      // TODO Auto-generated method stub
      return new APCldVerbatim(cldBool, this.sentences);
   }

   @Override
   public Boolean itemize() {
      // TODO add logic
      // at home
      return true;
   }
}

cool

_________________
kurayami no kagi admin
Back to top Go down
http://yotamarker.forumotion.com
 
DiParrot skill, the study of the spark
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
battle programmers alliance :: battle programming alliance :: the LivinGrimoire-
Jump to: