public class SkillHubAlgDispenser {
// super class to output an algorithm out of a selection of skills
// engage the hub with dispenseAlg and return the value to outAlg attribute
// of the containing skill (which houses the skill hub)
// this module enables using a selection of 1 skill for triggers instead of having the triggers engage on multible skill
// the methode is ideal for learnability and behavioral modifications
// use a learnability auxiliary module as a condition to run an active skill shuffle or change methode
// (rndAlg , cycleAlg)
// moods can be used for specific cases to change behavior of the AGI, for example low energy state
// for that use (moodAlg)
private ArrayList<DiSkillV2> skills = new ArrayList<DiSkillV2>();
private int activeSkill = 0;
private Neuron tempN = new Neuron();;
private Random rand = new Random();
public SkillHubAlgDispenser(DiSkillV2...skillsParams) {
for (DiSkillV2 skill : skillsParams)
{
skills.add(skill);
}
}
public SkillHubAlgDispenser addSkill(DiSkillV2 skill){
// builder pattern
skills.add(skill);
return this;
}
public Algorithm dispenseAlgorithm(String ear, String skin, String eye){
// return value to outAlg param of (external) summoner DiskillV2
skills.get(activeSkill).input(ear,skin,eye);
skills.get(activeSkill).output(tempN);
for (int i = 1; i < 6; i++) {
Algorithm temp = tempN.getAlg(i);
if (temp != null){
return temp;
}
}
return null;
}
public void randomizeActiveSkill(){
activeSkill = rand.nextInt(skills.size());
}
public void setActiveSkillWithMood(int mood){
// mood integer represents active skill
// different mood = different behavior
if ((mood>-1) && mood < (skills.size())){
activeSkill = mood;
}
}
public void cycleActiveSkill(){
// changes active skill
// I recommend this method be triggered with a Learnability or SpiderSense object
activeSkill++;
if (activeSkill == skills.size()){
activeSkill = 0;
}
}
public int getSize(){return skills.size();}
}
public class SkillBranch extends DiSkillV2 {
private Hashtable<String,Integer> skillRef = new Hashtable<>();
private SkillHubAlgDispenser skillHub = new SkillHubAlgDispenser();
private AXLearnability ml;
@Override
public void input(String ear, String skin, String eye) {
}
}
package AXJava;
public class AXLearnability {
private Boolean algSent = false;
// problems that may result because of the last deployed algorithm:
public UniqueItemSizeLimitedPriorityQueue defcons = new UniqueItemSizeLimitedPriorityQueue();// default size = 5
// major chaotic problems that may result because of the last deployed algorithm:
public UniqueItemSizeLimitedPriorityQueue defcon5 = new UniqueItemSizeLimitedPriorityQueue();
// goals the last deployed algorithm aims to achieve:
public UniqueItemSizeLimitedPriorityQueue goals = new UniqueItemSizeLimitedPriorityQueue();
// how many failures / problems till the algorithm needs to mutate (change)
public TrgTolerance trgTolerance;
public AXLearnability(int tolerance) {
this.trgTolerance = new TrgTolerance(tolerance);
trgTolerance.reset();
}
public void pendAlg(){
// an algorithm has been deployed
// call this method when an algorithm is deployed (in a DiSkillV2 object)
algSent = true;
trgTolerance.trigger();
}
public void pendAlgWithoutConfirmation(){
// an algorithm has been deployed
algSent = true;
//no need to await for a thank you or check for goal manifestation :
// trgTolerance.trigger();
// using this method instead of the default "pendAlg" is the same as
// giving importance to the stick and not the carrot when learning
// this method is mosly fitting work place situations
}
public Boolean mutateAlg(String input){
// recommendation to mutate the algorithm ? true/ false
if (!algSent) {return false;} // no alg sent=> no reason to mutate
if (goals.contains(input)){trgTolerance.reset();algSent = false;return false;}
// goal manifested the sent algorithm is good => no need to mutate the alg
if (defcon5.contains(input)) {trgTolerance.reset();algSent = false; return true;}
// ^ something bad happend probably because of the sent alg
// recommend alg mutation
if (defcons.contains(input)){algSent = false;
Boolean mutate= !trgTolerance.trigger();
if(mutate){
trgTolerance.reset();
}
return mutate;}
// ^ negative result, mutate the alg if this occures too much
return false;
}
public void resetTolerance(){
// use when you run code to change algorithms regardless of learnability
trgTolerance.reset();
}
}
public class SkillBranch extends DiSkillV2 {
// unique skill used to bind similar skills
/*
* contains collection of skills
* mutates active skill if detects conjuration
* mutates active skill if algorithm results in
* negative feedback
* positive feedback negates active skill mutation
* */
private Hashtable<String,Integer> skillRef = new Hashtable<>();
private SkillHubAlgDispenser skillHub = new SkillHubAlgDispenser();
private AXLearnability ml;
public SkillBranch(int tolerance) {
ml = new AXLearnability(tolerance);
}
@Override
public void input(String ear, String skin, String eye) {
// conjuration alg morph
if (skillRef.contains(ear)){
skillHub.setActiveSkillWithMood(skillRef.get(ear));
setSimpleAlg("hmm");
}
// machine learning alg morph
if (ml.mutateAlg(ear)){
skillHub.cycleActiveSkill();
setSimpleAlg("hmm");
}
// alg engage
outAlg = skillHub.dispenseAlgorithm(ear,skin,eye);
if (!(outAlg == null)){ml.pendAlg();}
}
public void addSkill(DiSkillV2 skill){
skillHub.addSkill(skill);
}
public void addReferencedSkill(DiSkillV2 skill, String conjuration){
// the conjuration string will engage it's respective skill
skillHub.addSkill(skill);
skillRef.put(conjuration, skillHub.getSize());
}
// learnability params
public void addDefcon(String defcon){ml.defcons.add(defcon);}
public void addGoal(String goal){ml.defcons.add(goal);}
// while alg is pending, cause alg mutation ignoring learnability tolerance:
public void addDefconLV5(String defcon5){ml.defcons.add(defcon5);}
}
package skills;
import AXJava.AXContextCmd;
import AXJava.DrawRnd;
import LivinGrimoire.DiSkillV2;
public class DiSmoothie0 extends DiSkillV2 {
private DrawRnd draw = new DrawRnd("grapefruits", "oranges", "apples", "peaches", "melons", "pears", "carrot");
private AXContextCmd cmd = new AXContextCmd();
public DiSmoothie0() {
cmd.contextCommands.add("recommend a smoothie");
cmd.commands.add("yuck");
cmd.commands.add("lame");
cmd.commands.add("nah");
cmd.commands.add("no");
}
@Override
public void input(String ear, String skin, String eye) {
if (cmd.engageCommand(ear)){
setSimpleAlg(String.format("%s and %s", draw.draw(), draw.draw()));
draw.reset();
}
}
}
package skills;
import AXJava.AXContextCmd;
import AXJava.DrawRnd;
import AXJava.Responder;
import LivinGrimoire.DiSkillV2;
public class DiSmoothie1 extends DiSkillV2 {
private Responder base = new Responder("grapefruits", "oranges", "apples", "peaches", "melons", "pears", "carrot");
private DrawRnd thickeners = new DrawRnd("bananas", "mango", "strawberry", "pineapple", "dates");
private AXContextCmd cmd = new AXContextCmd();
public DiSmoothie1() {
cmd.contextCommands.add("recommend a smoothie");
cmd.commands.add("yuck");
cmd.commands.add("lame");
cmd.commands.add("nah");
cmd.commands.add("no");
}
@Override
public void input(String ear, String skin, String eye) {
if (cmd.engageCommand(ear)){
setSimpleAlg(String.format("use %s as a base than add %s and %s", base.getAResponse(),thickeners.draw(),thickeners.draw()));
thickeners.reset();
}
}
}