AbsAlgPart.java :
Chi.java :
DExplorer.java :
and therefore also APMoan0 is modified:
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;
}
}