battle programming a forum for elite programmers with extreme will power to sharpen theire skills
 
HomeSearchRegisterLog in
Post new topic   Reply to topicShare
 

 upgrades to the platform

Go down 
AuthorMessage
Moti Barski
super
super
Moti Barski

Posts : 429
Join date : 2011-08-02

upgrades to the platform Empty
PostSubject: upgrades to the platform   upgrades to the platform EmptyMon Dec 09, 2019 11:19 am

AbsAlgPart.java :

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;
   }
}

Chi.java :

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 = 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() {
      // TODO Auto-generated method stub
      Mutatable mutant = (Mutatable) aPart;
      return new Chi(kokoro, this.ofSkill, mutant.mutation());
   }

}

DExplorer.java :

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);
            }
        }
        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;
        }
    }
}

and therefore also APMoan0 is modified:

Code:
package chobit;


import java.util.ArrayList;
import java.util.Random;

public class APMoan0 extends AbsAlgPart implements Mutatable {
    protected Random rand = new Random();
    protected final int failed = 3;
    protected enumFail failure = enumFail.ok;
    protected boolean isComplete = false;
    protected ArrayList<String> interactions;
    protected ArrayList<String> moans;
    protected ArrayList<String> groans;
    protected ArrayList<String> moanList;
    protected int noInputCounter = 0;

    public APMoan0() {
        super();
        moanList = new ArrayList<>();
        moanList.add("1");
        moanList.add("2");
        interactions = new ArrayList<>();
        moans = new ArrayList<>();
        groans = new ArrayList<>();
    }

    @Override
    public AbsAlgPart mutation() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
   public String action(String ear, String skin, String eye) {
      if (!ear.equals("")) {
            noInputCounter = 0;
        }
      if (ear.contains("thank you")) {
            isComplete = true;
            return "fuck you very much";
        }
      if (ear.equals("")) {
            noInputCounter++;
            if (noInputCounter > failed) {
                failure = enumFail.fail;
            }
        } //
      else if (interactions.contains(ear)) {
            return moans.get(rand.nextInt(moans.size()));
        }
        return groans.get(rand.nextInt(groans.size()));
    }

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

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

    @Override
    public AbsAlgPart clone() {
        // TODO Auto-generated method stub
        return null;
    }

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

   @Override
   public int getMutationLimit() {
      // TODO Auto-generated method stub
      return 1;
   }

}

_________________
MB over and out emp it up
Back to top Go down
Moti Barski
super
super
Moti Barski

Posts : 429
Join date : 2011-08-02

upgrades to the platform Empty
PostSubject: Re: upgrades to the platform   upgrades to the platform EmptyMon Dec 09, 2019 11:59 am

Cerabellum

Code:
package chobit;


public class Cerabellum {
    // runs an algorithm
    private int fin;
    private int at;
    private enumFail failType;
   private Boolean incrementAt = false;

   public void advanceInAlg() {
      if (incrementAt) {
         incrementAt = false;
         at++;
         if (at == fin) {
            isActive = false;
         }
      }
   }

    public int getAt() {
        return at;
    }

    public Algorithm alg;
    private boolean isActive = false;
    private String emot = "";

    public String getEmot() {
        return emot;
    }
    public boolean setAlgorithm(Algorithm algorithm) {
      if (!isActive && (algorithm.getAlgParts() != null)) {
            this.alg = algorithm;
            this.at = 0;
            this.fin = algorithm.getSize();
            this.isActive = true;
            this.emot = alg.getAlgParts().get(at).getClass().getSimpleName(); // updated line
            return false;
        }
        return true;
    }

    public boolean isActive() {
        return isActive;
    }

   public boolean setActive(Boolean b1) {
      return isActive = b1;
   }
    public void setActive(boolean isActive) {
        this.isActive = isActive;
    }

   public String act(String ear, String skin, String eye) {
        String axnStr = "";
        if (!isActive) {
            return axnStr;
        }
        if (at < fin) {
         axnStr = alg.getAlgParts().get(at).action(ear, skin, eye);
            this.emot = alg.getAlgParts().get(at).getClass().getSimpleName();
            if (alg.getAlgParts().get(at).completed()) {
            incrementAt = true;
            // at++;
            // if (at == fin) {
            // isActive = false;
            // }
            }
        }
        return axnStr;
    }

   public int getMutationLimitOfActiveAlgPart() {
      return alg.getAlgParts().get(at).getMutationLimit();
   }
    public enumFail getFailType() {
        return alg.getAlgParts().get(at).failure("");
    }
}

_________________
MB over and out emp it up
Back to top Go down
 
upgrades to the platform
Back to top 
Page 1 of 1

Permissions in this forum:You can reply to topics in this forum
battle programmers alliance :: battle programming alliance :: the LivinGrimoire-
Post new topic   Reply to topicJump to: