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
 

 upgraded Me class for self awareness

Go down 
AuthorMessage
Moti Barski
super
super
Moti Barski

Posts : 562
Join date : 2011-08-02

upgraded Me class for self awareness Empty
PostSubject: upgraded Me class for self awareness   upgraded Me class for self awareness EmptyTue Apr 20, 2021 9:50 pm

Code:
import java.util.ArrayList;

public class ME extends DiSkillV2 {
   public Permission permission;
   public Person person = new Person();
   private DISkillUtils diSkillUtil = new DISkillUtils();
   private String cryReason = "i am not crying";
   private CountDownGate cdg = new CountDownGate(10);

   public ME(Kokoro kokoro, Permission permission) {
      super(kokoro);
      this.permission = permission;
      this.person.setName(this.permission.getLv1Name());
      this.person.setJutsu("hadouken");
      cdg.setToOff();
   }

   @Override
   public void input(String ear, String skin, String eye) {
      cdg.countingDown();
      // handle stand by phase
      if (kokoro.standBy) {
         String soulMsg = kokoro.toHeart.getOrDefault("Me", "");
         if (soulMsg.contains("shiku shiku")) {
            cryReason = soulMsg.replace("shiku shiku", "");
            cdg.reset();
         }
         kokoro.toHeart.put("Me", "");
         switch (soulMsg) {
         case "introduce":
            outAlg = algDispenser(0);
            return;
         case "attention":
            outAlg = algDispenser(1);
         case "general":
            outAlg = algDispenser(2);
         default:
            if (soulMsg.isEmpty()) {
               outAlg = algDispenser(1);
            } else {
               outAlg = diSkillUtil.verbatimGorithm("r_me", new APVerbatim(soulMsg));
            }
            return;
         }
      }
      // handle audio input
      switch (ear) {
      case "why are you crying":
         if (cdg.countingDown()) {
            outAlg = diSkillUtil.verbatimGorithm("r_me", new APVerbatim(cryReason));
         } else {
            outAlg = diSkillUtil.verbatimGorithm("r_me",
                  new APVerbatim(this.permission.getLv1Name() + " " + "is not crying"));
         }
         resetCryReason();
         break;
      case "why did you cry":
      case "why have you been crying":
         if (cdg.countingDown()) {
            outAlg = diSkillUtil.verbatimGorithm("r_me", new APVerbatim("shiku shiku"));
         } else {
            outAlg = diSkillUtil.verbatimGorithm("r_me", new APVerbatim(cryReason.replace("am", "was")));
         }
         resetCryReason();
         break;
      default:
         break;
      }
   }

   private Algorithm algDispenser(int num) {
      switch (num) {
      case 0:
         // introduce give details and befriend
         ArrayList<String> list1 = new ArrayList<>();
         list1.add("my name is " + this.person.getName());
         list1.add(person.getJutsu() + " " + person.getJutsu());
         list1.add("lets be friends");
         return diSkillUtil.verbatimGorithm("r_me", new APVerbatim(list1));
      case 1:
         // general attention 1
         return diSkillUtil.verbatimGorithm("r_me", new APVerbatim(person.getJutsu() + " " + person.getJutsu()));
      case 2:
         // seeking friend
         return diSkillUtil.verbatimGorithm("r_me", new APVerbatim("my name is " + this.person.getName()));
      default:
         break;
      }
      return null;
   }

   private void resetCryReason() {
      cryReason = "i am not crying";
      cdg.setToOff();
   }
}

new auxilary class :

Code:
public class CountDownGate {
   private int cycler = 0;
   private int limit;

   public CountDownGate(int limit) {
      super();
      this.limit = limit;
      cycler = limit;
   }

   public int getLimit() {
      return limit;
   }

   public void setLimit(int limit) {
      this.limit = limit;
   }
   public Boolean countingDown() {
      cycler--;
      if (cycler < 1) {
         cycler = -1;
         return false;
      }
      return true;
   }

   public void reset() {
      cycler = limit;
   }

   public void setToOff() {
      cycler = 0;
   }
}

you should use this code :
kokoro.toHeart.put("Me", "shiku shiku i am hungry");//pattern : shiku shiku reason
it sends a cry command to the self class (Me), which manages bottleneck requests.

_________________
MB over and out emp it up
Back to top Go down
 
upgraded Me class for self awareness
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: