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

 update to Chobit class, trully only one line to add a skill

Go down 
Moti Barski
Moti Barski

Posts : 568
Join date : 2011-08-02

update to Chobit class, trully only one line to add a skill Empty
PostSubject: update to Chobit class, trully only one line to add a skill   update to Chobit class, trully only one line to add a skill EmptyFri Jul 26, 2019 8:54 pm

copyrights moti barski

I made some changes and now, it only takes one line of code to add a skill to the AGI.

package chobit;

import java.util.ArrayList;
import java.util.Hashtable;

public class Chobit {
   protected String emot = ""; // emotion
   protected ArrayList<AbsCmdReq> dClassesLv1 = new ArrayList<>();
   protected ArrayList<AbsCmdReq> dClassesLv2 = new ArrayList<>();
   protected ArrayList<AbsCmdReq> dClassesLv3 = new ArrayList<>();
   // algorithms fusion (polymarization)
   protected Hashtable<String, Integer> AlgDurations = new Hashtable<>();
   protected Fusion fusion = new Fusion(AlgDurations);
   // region essential DClasses
   protected Permission permission = Permission.newInstance("xxx", "chii", "liron");
   protected DPermitter dPermitter = new DPermitter(permission);
   // endregion
   protected Neuron noiron;
   // sleep vars :
   protected InnerClass inner;
   protected DCFilter dcFilter = new DCFilter(); // used for the filter func
   protected Person activePerson = new Person();
   protected PrimoCera primoCera = new PrimoCera();
    public Chobit() {
      noiron = new Neuron();
      this.inner = new InnerClass(); // sleep var
      DAlarmer dAlarmer = new DAlarmer();
      // add a skill here, only 1 line needed !!!
      dClassesLv1.add(new Detective(fusion));
      dClassesLv1.add(new DJirachi());
      dClassesLv1.add(new DHungry());
      dClassesLv1.add(new DRules((new APSleep(24)), inner));
      dClassesLv1.add(new DSpeller());
      dClassesLv2.add(new DSayer());
      dClassesLv3.add(new DDirtyTalker());

   protected String doIt2(String ear, String skin, String eye) {
      for (AbsCmdReq dCls : dClassesLv1) {
         inOut(dCls, ear, skin, eye);
      if (dPermitter.getPermissionLevel() > 0) {
         // works with friends
         for (AbsCmdReq dCls : dClassesLv2) {
            inOut(dCls, ear, skin, eye);

      if (dPermitter.getPermissionLevel() > 1) {
         // only works with owner
         for (AbsCmdReq dCls : dClassesLv3) {
            inOut(dCls, ear, skin, eye);
      DCStrPair<String> result = new DCStrPair<String>();
      result = fusion.act(ear, skin, eye);
      this.emot = fusion.getEmot();
      return itemFilter(result);

    public String getEmot() {
      // emot (emotion for display)
        String x1 = emot;
        switch (this.emot) {
            case "APCuss ":
                x1 = "angry";
            case "APDirtyTalk":
                x1 = "grinny";
            case "APMoan":
                x1 = "horny";
            case "APSay":
                x1 = "speaking";
            case "APSleep0":
                x1 = "dreaming";
            case "APSleep":
                x1 = "asleep";
            case "APSpell":
                x1 = "blank";
        emot = "";
        return x1;

   protected String sleep() {
      // data save load should go here and run while chobit is sleeping
        return "haha I can sleep !";

   protected void inOut(AbsCmdReq dClass, String ear, String skin, String eye) {
      dClass.input(ear, skin, eye); // new

    protected class InnerClass {
        public String nemure() {
            return sleep();

   protected String itemFilter(DCStrPair<String> pair) {
      if (!pair.key.equals(dcFilter.prevKey)) {
         // fold prev key(item) with switch case :
         // tie bike, put phone in place...
         // dcFilter.ignoreCounter = 3; // longer tick for longer action
      // fold on key change;
      String result = "";
      // ter(item) cases
      switch (pair.key) {
      case "itemLess":
         result = pair.value;
      case "nyaa":
         if (!activePerson.getActive()) {
            // send SMS if target guy is not actively available/responding
         } else {
            result = pair.value + " nyaa";
         dcFilter.imutable = true; // constant action (no need to try other movements)
         // * dcFilter.ignoreCounter = 3; // longer tick for longer action
      return result;

   public String doIt(String ear, String skin, String eye) {
      if (dcFilter.danger.contains(ear) || dcFilter.danger.contains(eye)) {
         return doIt2(ear, skin, eye);
      if (dcFilter.ignoreCounter > 0) {
      } else if (dcFilter.imutable) {
         return doIt2(ear, skin, eye);
      } else if (eye.contains(dcFilter.pair.toString())) {
         primoCera.saveAction(dcFilter.pair.toString(), dcFilter.actioNum);
         // savekeyvalnum (successful actual action chosen)
      } else {
         if (dcFilter.actioNum > primoCera.getFinalActionCode()) {
            dcFilter.actioNum = 0;
         primoCera.saveAction(dcFilter.pair.toString(), dcFilter.actioNum);
         // save key++,num
         // the action did not result in the needed imidiate outcome, use a different
         // action next time
      return doIt2(ear, skin, eye);
   protected String translateIn() {
      return "";

   protected String translateOut() {
      return "";

all that is needed is to add it in the c'tor, and that is it !
in the prev ver you had to add it as a global var then add it in the doIt2 methode.

in all my years I haven't seen such a lazy style of programming as this one that I created


MB over and out emp it up
Back to top Go down
update to Chobit class, trully only one line to add a skill
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: