this classes enable memory for algParts mutations.


Code:

package chobit;
public abstract class AbsAlgPart {
   // one part of an algorithm, it is a basic simple action or sub goal
   public abstract String action(String ear, String skin, String eye); // return action string
   public abstract Boolean itemize(); // equip with item ?
    public abstract enumFail failure(String input); // failure type
    public abstract Boolean completed(); // has finished ?
    public abstract AbsAlgPart clone();
   public int getMutationLimit() {
      /*
       * override this to the number of mutations a mutation series can perform, so at
       * least to 1 if you want mutations enabled.
       */
      return 0;
   }

   public String myName() {
      return this.getClass().getSimpleName();
   }
}


Code:

package chobit;

public class Chi extends AbsAlgPart implements Mutatable {
   /*
    * an adaptor pattern to the alg part, it also has the kokoro consiousness
    * object to be aware throughout the program of what is happening all action
    * data goes through this soul.
    */
   public Kokoro kokoro;
   public String ofSkill;
   public AbsAlgPart aPart;

   public Chi(chobit.Kokoro kokoro, String ofSkill, AbsAlgPart aPart) {
      super();
      this.kokoro = kokoro;
      this.ofSkill = ofSkill;
      this.aPart = kokoro.grimoireMemento.load(aPart);
   }

   public String actualAction(String ear, String skin, String eye) {
      return aPart.action(ear, skin, eye);
   }
   @Override
   public String action(String ear, String skin, String eye) {
      kokoro.in(this);
      String result = actualAction(ear, skin, eye);
      kokoro.out(completed(), failure(""));
      return result;
   }

   @Override
   public Boolean itemize() {
      // TODO Auto-generated method stub
      return aPart.itemize();
   }

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

   @Override
   public Boolean completed() {
      // TODO Auto-generated method stub
      return aPart.completed();
   }

   @Override
   public AbsAlgPart clone() {
      // TODO Auto-generated method stub
      return new Chi(kokoro, this.ofSkill, aPart.clone());
   }
   @Override
   public int getMutationLimit() {
      // TODO Auto-generated method stub
      return aPart.getMutationLimit();
   }

   @Override
   public AbsAlgPart mutation() {
      Mutatable mutant = (Mutatable) aPart;
      AbsAlgPart tempAP = mutant.mutation();
      kokoro.grimoireMemento.reqquipMutation(tempAP.getClass().getSimpleName());
      return new Chi(kokoro, this.ofSkill, tempAP);
   }

   @Override
   public String myName() {
      // TODO Auto-generated method stub
      return aPart.myName();
   }
}


Code:

package chobit;
//D class responsible for exploring :
// learning, mutating algorithms, requiping APs with objects or skill mods
// the sould resides here

public class DExplorer extends AbsCmdReq implements Neuronable {
    private int failureCounter = 0;
    private String prevAP = "";
    @Override
    public void output(Neuron noiron) {
        // TODO Auto-generated method stub

    }

    @Override
   public void input(String ear, String skin, String eye) {
        // TODO Auto-generated method stub

    }

   public void mutate(Cerabellum cera, enumFail failure) {
        String AP = cera.getEmot();
      /*
       * group relies on a naming convention each class in a mutation series must have
       * the same class name concated with a number : APMoan1, APMoan2, APMaon3 ...
       */
      AP = AP.replaceAll("\\d+", "");
        // give up ? :
        if (prevAP.contains(AP) && !failure.toString().equals(enumFail.ok.toString())) {
            failureCounter++;
         if (failureCounter > cera.getMutationLimitOfActiveAlgPart()) {
            cera.setActive(false);
            // this.failureCounter = 0;
            }
        }
        else {
            if (!prevAP.contains(AP)) {
                failureCounter = 0;
            }
        }
        prevAP = AP;
        switch (failure) {
            case fail:
                Mutatable mutant = (Mutatable) cera.alg.getAlgParts().get(cera.getAt());
                cera.alg.getAlgParts().set(cera.getAt(), mutant.mutation());
                break;
      case cloudian:
         cera.setActive(false);
         break;
            default:
                break;
        }
    }
}


Code:

package chobit;

import java.util.Hashtable;

/* all action data goes through here
 * detects negatives such as : repetition, pain on various levels and failures
 * serves as a database for memories, convos and alg generations
 * can trigger revenge algs
 * checks for % of difference in input for exploration type algs
 * */
public class Kokoro {
   Hashtable<String, Integer> pain = new Hashtable<>();
   public GrimoireMemento grimoireMemento = new GrimoireMemento();
   public int getPain(String BijuuName) {
      return pain.getOrDefault(BijuuName, 0);
   }

   public void in(Chi chi) {
   }
   public void out(Boolean isCompleted, enumFail failure) {
   }
}


GrimoireMemento.java

Code:

package chobit;

import java.util.Hashtable;

public class GrimoireMemento {
   private Hashtable<String, String> rootToAPNumDic = new Hashtable<>();
   private Hashtable<String, AbsAlgPart> APNumToObjDic = new Hashtable<>();

   public GrimoireMemento() {
      super();
      // load DB to rootToAPNumDic
   }

   public AbsAlgPart load(AbsAlgPart obj) {
      /*
       * load final mutation from memory of obj
       */
      String objName = obj.getClass().getSimpleName();
      String objRoot = objName.replaceAll("\\d+", "");
      if (!rootToAPNumDic.containsKey(objRoot)) {
         rootToAPNumDic.put(objRoot, objName);
         return obj;
      }

      if (rootToAPNumDic.get(objRoot).equals(objName)) {
         return obj;
      } else {
         String APNum = rootToAPNumDic.get(objRoot);
         if (APNumToObjDic.containsKey(APNum)) {
            return APNumToObjDic.get(APNum).clone();
         } else {
            loadMutations(obj, objName, objRoot);
            return APNumToObjDic.get(APNum).clone();
         }
      }
   }

   public void reqquipMutation(String mutationAPName) {
      // save mutation
      rootToAPNumDic.put(mutationAPName.replaceAll("\\d+", ""), mutationAPName);
      // save to DB
   }

   private void loadMutations(AbsAlgPart obj, String objName, String objRoot) {
      // make sure all the AP mutation sets of obj are present
      // this assumes the last mutation mutates into the prime mutation
      Mutatable mutant;
      String end = objName;
      do {
         APNumToObjDic.put(obj.getClass().getSimpleName(), obj.clone());
         mutant = (Mutatable) obj;
         obj = mutant.mutation();
      }
      while (!end.equals(obj.getClass().getSimpleName()));
   }
}
:AIP: