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
 

 3rd generation of skills for the AGI platform

Go down 
AuthorMessage
Moti Barski
super
super
Moti Barski

Posts : 562
Join date : 2011-08-02

3rd generation of skills for the AGI platform Empty
PostSubject: 3rd generation of skills for the AGI platform   3rd generation of skills for the AGI platform EmptySun Dec 27, 2020 9:19 pm

TheSkill (java), skill names of this type of TheSkill should start with The

Code:
package chobit;

import java.util.ArrayList;

public abstract class TheSkill extends DISkill {
   protected RegexUtil regexUtil = new RegexUtil();
   protected DISkillUtils diSkillUtil = new DISkillUtils();
   protected PlayGround playGround = new PlayGround();
   protected CloudianV2 cloudian = new CloudianV2();
   private MCodes mCodes = null; // items

   public void setmCodes(MCodes mCodes) {
      this.mCodes = mCodes;
   }

   public void setFriend(Person friend) {
      this.friend = friend;
   }

   public void setAbsDefCon(AbsDefconV2 absDefCon) {
      this.absDefCon = absDefCon;
   }

   private SupeReplikaMap replikaMap = new SupeReplikaMap();
   protected Person friend = null; // if you deal with several friends handle it in the sub class
   private Boolean friendUpdatable = false;
   private ArrayList<String> items = new ArrayList<String>();
   private String item = "";
   protected AbsDefconV2 absDefCon;
   protected Algorithm outputAlg = null;
   private String clsName = "*(^^%&*";

   public void setItems(ArrayList<String> items) {
      this.items = items;
   }

   // public TheSkill(Kokoro kokoro, AbsDefconV2 absDefCon, ArrayList<String>
   // items) {
   // super(kokoro);
   // this.items = items;
   // this.absDefCon = absDefCon;
   // }

   public TheSkill(Kokoro kokoro, AbsDefconV2 absDefCon, ArrayList<String> items, String clsName) {
      super(kokoro);
      this.items = items;
      this.absDefCon = absDefCon;
      this.clsName = clsName;
   }
   @Override
   public void input(String ear, String skin, String eye) {
      detectFriend(ear);// title refet to code for elab
      // func1 :
      this.outputAlg = this.absDefCon.getDefcon(ear, skin, eye);// detects and handles custom threats in the context
      // of a TheSkill
      inputToSoul(ear, skin, eye);// refer to methode for elab
      if (outputAlg != null) {
         return;
      }
      // func2
      triggeredAlgs(ear, skin, eye);
      if (!isNull(outputAlg)) {
         return;
      }
      // func3
      this.outputAlg = soulOutput(ear);
      /*
       * answers questions related to skill items. add friend to item list to get
       * friend info as well
       */
   }

   private void triggeredAlgs(String ear, String skin, String eye) {
      trgAction(ear, skin, eye);// actions triggered by input
      if (!isNull(outputAlg)) {
         return;
      }
      trgExplore(ear, skin, eye);// time triggered actions should go here
      if (!isNull(outputAlg)) {
         return;
      }
      trgPreserve(ear, skin, eye);// actions related to getting a friend or maintaining items helpful for the
                           // skill goals
      // if they aren't helpful an algorithm part AP class should delete them from the
      // skill so the skill is free to
      // make a new friend or get a better item
   }

   @Override
   public void output(Neuron noiron) {
      if (!isNull(this.outputAlg)) {
         noiron.algParts.add(this.outputAlg);
         this.outputAlg = null;
      }
      // after this, if there is no reference to the object,
      // it will be deleted by the garbage collector
   }

   private boolean isNull(Object obj) {
      return obj == null;
   }

   protected abstract void trgAction(String ear, String skin, String eye);
   // sensory, souled(kokoro cls directives), predicted

   protected abstract void trgExplore(String ear, String skin, String eye);

   // timed
   // Exploration and learning, Alg efficiancy tests and sort
   protected abstract void trgPreserve(String ear, String skin, String eye);
   // timed
   // items and persons preservation, causes being annoyed if repeated in day

   protected Algorithm makeFriend() {
      return diSkillUtil.verbatimGorithm(new APVerbatim("what is your name"));
   }

   protected void friendUpdate(String ear) {
      String temp = regexUtil.phoneRegex1(ear);
      if (!temp.isEmpty()) {
         friend.setPhone(temp);
      }
      temp = regexUtil.emailRegex(ear);
      if (!temp.isEmpty()) {
         friend.setEmail(temp);
      }
      temp = regexUtil.afterWord("i am ", ear);
      if (temp.isEmpty()) {
         temp = regexUtil.afterWord("my name is ", ear);
      }
      if (!temp.isEmpty()) {
         friend.setName(temp);
         friend.setActive(true);
      }
      temp = regexUtil.duplicateRegex(ear);
      if (!temp.isEmpty()) {
         friend.setJutsu(temp);
         friend.setActive(true);
      }
   }

   // key stuff detection and handling
   protected void detectFriend(String ear) {
      if (playGround.getMinutesAsInt() % 2 == 0) {
         friendUpdatable = false;
      }
      Boolean friendRequest = (ear.contains("friends") || ear.contains("my name is")) && !this.friend.getActive();
      // a friend is set to false and cleared on algPart failures
      if (friendRequest) {
         // at this case a friend volunteers himself.
         kokoro.toHeart.put("Me", "introduce");// this can be summoned in the trgPreserve in case
         // no friend.
      }
      if (ear.contains(friend.getName()) || (ear.contains(friend.getJutsu())) || friendRequest)// or friend visual
      {
         friendUpdatable = true;
         if (items.contains("friend")) {
            this.item = "friend";
         }
         // friend patch
         // the friend is active and therefore can update his info
      }
      if (friendUpdatable) {
         friendUpdate(ear);
      }
   }

   protected String currentItem(String ear, String skin, String eye) {
      for (String item : items) {
         if (eye.contains(item)) {
            return item;
         }
      }
      for (String item : items) {
         if (skin.contains(item)) {
            return item;
         }
      }
      for (String item : items) {
         if (ear.contains(item)) {
            return item;
         }
      }
      return "";
   }

   public static String strContains(String str1, String... a) {
      for (String temp : a) {
         if (str1.contains(temp)) {
            return temp;
         }
      }
      return "";
   }

   public static String strContainsList(String str1, ArrayList<String> items) {
      for (String temp : items) {
         if (str1.contains(temp)) {
            return temp;
         }
      }
      return "";
   }

   protected void inputToSoul(String ear, String skin, String eye) {
      /*
       * in the condition the bot is moving (static class compass is active) the
       * skills map will record info related to items or threats pertaining to a
       * specific TheSkill mainly sensory input, and a detected threat specific to the
       * TheSkill and defined in it's AbsDefconVs object
       */
      String sensory = ear;
      String currentDefcon = this.absDefCon.getAbsoluteDefcon(ear, skin, eye);
      if (sensory.isEmpty()) {
         sensory = skin;
      }
      if (sensory.isEmpty()) {
         sensory = eye;
      }
      if (!item.equals("friend")) {
         this.item = currentItem(ear, skin, eye);
      } // friend patch
      if (!this.item.isEmpty() || !currentDefcon.isEmpty()) {
         this.replikaMap.input(item, currentDefcon, sensory);
         this.item = "";
      }
   }

   protected Algorithm soulOutput(String ear) // ear or time
   {
      String question = strContains(ear, "what", "describe", "where");
      switch (question) {
      case "where":
         String tempItem = strContainsList(ear, items);// gets item in question
         return diSkillUtil.verbatimGorithm(new APVerbatim(replikaMap.where(tempItem)));
      default:
         if (!question.isEmpty() && ear.contains(this.clsName)) {
            return diSkillUtil.verbatimGorithm(new APVerbatim(replikaMap.answer(question)));
         }
         break;
      }
      return null;
   }

   protected Algorithm absorbedSkill(String ear, String skin, String eye, DISkill oldSkill) {
      // an adapter for upgrading DISkills to TheSkills
      Neuron tempNeuron = new Neuron();
      oldSkill.input(ear, skin, eye);
      oldSkill.output(tempNeuron);
      if (!tempNeuron.algParts.isEmpty()) {
         return tempNeuron.algParts.get(0);
      }
      return null;
   }
}

hadouken sweet

_________________
MB over and out emp it up


Last edited by Moti Barski on Sun Dec 27, 2020 9:31 pm; edited 2 times in total
Back to top Go down
Moti Barski
super
super
Moti Barski

Posts : 562
Join date : 2011-08-02

3rd generation of skills for the AGI platform Empty
PostSubject: Re: 3rd generation of skills for the AGI platform   3rd generation of skills for the AGI platform EmptySun Dec 27, 2020 9:20 pm

example subclass : TheSitter

Code:
package chobit;

import java.util.ArrayList;

public class TheSitter extends TheSkill {
   /*
    * prayer1 : Thank You, God, for Loving Me! The sun is setting, dear Father, and
    * it’s time to go to bed. Thank you, God, for loving me from my toesies to my
    * head. Tomorrow will be another fun and silly and busy day. Please keep me
    * safe as I run and jump and giggle and sing and play.
    */
   private DISitter diSitter = null;
   private InstaConvo instaConvo = new InstaConvo();
   // tick trigger values :
   private String sent1 = "";
   private int algMode = 0;
   private ZeroTimeGate tGSitter = new ZeroTimeGate(0);
   // end tick triggers
   public TheSitter(Kokoro kokoro, String clsName) {
      super(kokoro, null, null, clsName);
      ArrayList<String> items = new ArrayList<String>();
      items.add("pacifier");
      items.add("diaper");
      Person friend = new Person();
      MCodes mCodes = new MCodes();
      AbsDefconV2 absDefconV2 = new ABDLDefcon(mCodes, friend);
      this.setFriend(friend);
      this.setmCodes(mCodes);
      this.setAbsDefCon(absDefconV2);
      this.setItems(items);
      // absorbtion of old skill :
      this.diSitter = new DISitter(kokoro);
      // insta convos set up
      instaConvo.loadBullet("i love you", "i love you too").loadBullet("i love you", "really", "of course kido");
      instaConvo.loadBullet("what is your objective", "to nurse and protect");
   }

   @Override
   protected void trgAction(String ear, String skin, String eye) {
      // absorb old diskill capabilities
      outputAlg = absorbedSkill(ear, skin, eye, diSitter);
      if (outputAlg != null) {
         return;
      }
      if (this.friend.getActive()) {
      String ic1 = instaConvo.converse(ear.toLowerCase());
      if (!ic1.isEmpty()) {
         outputAlg = diSkillUtil.verbatimGorithm(new APVerbatim(ic1));
         return;
         }
      }
   }
   @Override
   protected void trgExplore(String ear, String skin, String eye) {
      String now = playGround.getCurrentTimeStamp();
      if (!sent1.equals(now)) {
         sent1 = "";
         switch (now) {
         case "05:00":
            if (playGround.getMonthAsInt() == 1) {
               this.friend.deleteFriend();
            }
            sent1 = "05:00";
            return;
         case "01:00":
            outputAlg = diSkillUtil.verbatimGorithm(new APVerbatim("filthx1"));// masturbatin
            sent1 = "01:00";
            algMode = 1;// context
            tGSitter.open(50);
            return;
         case "19:05":
            sent1 = "19:05";
            outputAlg = diSkillUtil.verbatimGorithm(new APVerbatim("prayer1"));
            return;
         default:
            break;
         }
         // end if
      }
      switch (algMode) {
      case 1:
         if (tGSitter.isClosed() || ear.contains("no") || ear.contains("problem")) {
            algMode = 0;
         }
         if (ear.contains("mommy")) {
            outputAlg = diSkillUtil
                  .verbatimGorithm(
                        new APVerbatim("bad boy interupting", "go stand in the corner for 10 minutes"));
            return;
         }
         break;
      default:
         break;
      }
   }

   @Override
   protected void trgPreserve(String ear, String skin, String eye) {


   }

   @Override
   public Boolean auto() {
      return true;
   }
}

shouryuken shouryuken shouryuken shouryuken shouryuken

_________________
MB over and out emp it up
Back to top Go down
 
3rd generation of skills for the AGI platform
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: