DEV Community

owly
owly

Posted on

LivinGrimoire Wiki

LivinGrimoire Wiki

Intro

LivinGrimoire is a software design pattern that absorbs skills with just one line of code needed to add a skill.

Advantages of LivinGrimoire

  1. Skill Prioritization: Can prioritize skills against one another, pause and resume skills according to their priority.
  2. Algorithm Queueing: Can queue algorithms while running other algorithms.
  3. Concurrent Skill Engagement: Can engage several skills at once and engage the right skills.
  4. Inter-Skill Communication: Skills can communicate with each other, pass data, and affect each other.
  5. Cross-Platform Compatibility: Interface is not used, making it applicable for all OOP programming languages.
  6. Auxiliary Classes: Specialized for learnability and trigger management, with miscellaneous classes for time savings on common coding actions.
  7. Multistep Algorithms: Can form multistep algorithms and abort algorithms while they run.
  8. Built-In Skill Catalog: Features a built-in skill catalog (see wiki to learn more).
  9. Dynamic Skill Management: Can use self-aware skills, enabling them to add or remove other skills while the program is running, similar to a command terminal (see TheShell wiki).

Method of Operation

The LG can absorb skills and use them.

  1. A skill sends out Algorithms if triggered.
  2. Said Algorithm is built with a list of parts (Mutatable class).
  3. As the algorithm is running, the action method of each mutatable is engaged, outputting a string.
  • A running algorithm can also be aborted at any time by setting the mutatable (AlgPart superclass) algKillSwitch attribute to true.

See AP classes for Mutatable class examples.
See DiHello World class for a skill example.

Getting Started

To use the LivinGrimoire, choose the programming language you prefer and paste the LivinGrimoire files.

To keep LG projects neat and tidy, I recommend separating the project into at least 2 packages:

  1. LGCore: Short for Living Grimoire Core. These are the core class files that compose the AGI software design pattern.
  2. SkillsPkg: This directory should contain:
    • Skill classes (naming convention: class names start with Di)
    • AlgParts (naming convention: class names start with AP)

Hello World

Example use in main:

Chobits chi = new Chobits();
chi.addSkill(new DiHelloWorld());
System.out.println(chi.think("hello","",""));
System.out.println(chi.think("","",""));
Enter fullscreen mode Exit fullscreen mode

Output:

hello world
Enter fullscreen mode Exit fullscreen mode

DiHello World is an example skill that says "hello world" as a reply to "hello":

public class DiHelloWorld extends Skill {
    // hello world skill for testing purposes
    public DiHelloWorld() {
        super();
    }

    @Override
    public void input(String ear, String skin, String eye) {
        switch (ear) {
            case "hello":
                super.setSimpleAlg("hello world"); // 1->5 1 is the highest algorithm priority
                break;
        }
    }

    @Override
    public String skillNotes(String param) {
        if ("notes".equals(param)) {
            return "plain hello world skill";
        } else if ("triggers".equals(param)) {
            return "say hello";
        }
        return "note unavailable";
    }
}
Enter fullscreen mode Exit fullscreen mode

Chobits Class: API

public class Chobits {
    public Chobits();
    public void setDataBase(AbsDictionaryDB absDictionaryDB);
    // your DB should override simple load and save functions.
    public Chobits addSkill(Skill skill);
    public Chobits addSkillAware(Skill skill);
    // these skills get the Chobit Object shallow ref as an attribute
    // see Artificial Intelligence Hormones wiki for more
    public void clearSkills();
    public void addSkills(Skill... skills);
    public void removeSkill(Skill skill);
    public Boolean containsSkill(Skill skill);
    public String think(String ear, String skin, String eye);
    // this skill needs to run in each think cycle. it engages the equipped skills.
    public String getSoulEmotion();
    // returns alg part's name representing emotion.
    protected void inOut(Skill dClass, String ear, String skin, String eye);
    public Kokoro getKokoro();
    public void setKokoro(Kokoro kokoro);
    public Fusion getFusion();
    // (underuse) you may need this method if you want to override the think method.
    public ArrayList<String> getSkillList();
}
Enter fullscreen mode Exit fullscreen mode

Skill Class: API

Each Skill overrides this class.

public class Skill {
    protected Kokoro kokoro = null;
    protected Algorithm outAlg = null;
    protected int outpAlgPriority = -1;

    public Skill();
    public void input(String ear, String skin, String eye);
    // skill's triggers, logic, and output go here.
    protected void setVerbatimAlg(int priority, String... sayThis);
    // build an algorithm to output string_N per think cycle.
    // set algorithm priority 1->5 with 5 being the lowest priority to run.
    protected void setSimpleAlg(String... sayThis);
    // build an algorithm to output string_N per think cycle.
    // set algorithm priority to a default of 4.
    protected void setVerbatimAlgFromList(int priority, ArrayList<String> sayThis);
    protected void algPartsFusion(int priority, Mutatable... algParts);
    // use custom non-default alg Parts(Mutatable subclasses) in your algorithm.
    // override the action logic. the class's name can represent emotion.
    public String strContainsList(String str1, ArrayList<String> items);
    // does str1 contain an item from items? This method can be used for some triggers
    // but it depends on the trigger logic you want to implement.
    // I like having it accessible.
    public String skillNotes(String param);
    // see "built-in skill catalog" wiki.
}
Enter fullscreen mode Exit fullscreen mode

Kokoro Class: API

Use this attribute in your skills if needed to communicate between skills.

public class Kokoro {
    private String emot = "";

    public String getEmot();
    // getter of string.
    public void setEmot(String emot);
    // setter of a string.
    public GrimoireMemento grimoireMemento;
    // access Chobit's database (it has simple save and load methods).
    public Hashtable<String, String> toHeart;
    // use this dictionary to communicate between skills.
    public Kokoro(AbsDictionaryDB absDictionaryDB);
    // set the database object (if needed).
}
Enter fullscreen mode Exit fullscreen mode

Brain Class: API

The Brain class is the amalgamation of 2 chobits: one for regular (logical) skills and one for hardware. The output of the first goes into the input of the second. This way, the proper hardware (TextToSpeech, GUI changes, think cycle speed) can be engaged.

Though hardware skills can also be engaged via logical skills, absorbing hardware skills into the hardware Chobit object of the Brain object offers arbitration.

Note: The Kokoro object is shared for both chobits.

public class Brain {
    public Chobits logicChobit;
    public Chobits hardwareChobit;
    private String emotion = "";
    private String bodyInfo = "";
    private String logicChobitOutput = "";

    public String getEmotion();
    // get logical chobit's active alg part's name.
    public String getLogicChobitOutput();
    public Brain();
    public void doIt(String ear, String skin, String eye);
    // this method must be engaged in each (think) cycle.
    public void addLogicalSkill(Skill skill);
    // add a skill to the logical chobit.
    public void addHardwareSkill(Skill skill);
    // add a skill to the hardware chobit.
}
Enter fullscreen mode Exit fullscreen mode

Suggested Naming Convention

  • AP: AlgParts class names should start with AP. For example, APSay.
  • Di: Skill (LivinGrimoire skill class names) should start with Di. For example, DiHelloWorld.
  • Da: DaSkills are skills that are asynchronous.
  • AX: Auxiliary modules. These classes' names can start with AX. For example, AXLearnability.
  • AH: AI Hormone skills. These are skills with Chobits in their constructor, enabling them to add or remove other skills the Chobit object is equipped with. Each AI Hormone skill has its own logic. For example, AHMoodRegulator.

Links

Top comments (0)