👨‍💻 dev core diet

development

fukurou

the supreme coder
ADMIN
Python:
class Skill:
    def __init__(self) -> None:
        # Initialize protected attributes
        self.kokoro: Optional['Kokoro'] = None  # Shallow reference for interskill communication
        self.outAlg: Optional['Algorithm'] = None  # Skill's output
        self.outpAlgPriority: int = -1  # DEFCON levels 1->5

    def input(self, ear: str, skin: str, eye: str) -> None:
        # Implement skill triggers and algorithmic logic here
        pass

    def output(self, noiron: 'Neuron') -> None:
        # Extract and run the skill algorithm if available
        if self.outAlg is not None:
            noiron.insertAlg(self.outpAlgPriority, self.outAlg)
            self.outpAlgPriority = -1
            self.outAlg = None

    def setKokoro(self, kokoro: 'Kokoro') -> None:
        # Set Kokoro for interskill communication
        self.kokoro = kokoro

    def setVerbatimAlg(self, priority: int, *sayThis: str) -> None:
        # Build a simple output algorithm to speak string by string per think cycle
        self.outAlg = Algorithm(APVerbatim(*sayThis))
        self.outpAlgPriority = priority  # DEFCON levels 1->5

    def setSimpleAlg(self, *sayThis: str) -> None:
        # Shortcut to build a simple algorithm
        self.outAlg = Algorithm(APVerbatim(*sayThis))
        self.outpAlgPriority = 4  # Default priority of 4

    def setVerbatimAlgFromList(self, priority: int, sayThis: List[str]) -> None:
        # Build a simple output algorithm to speak string by string per think cycle using a list
        self.outAlg = Algorithm(APVerbatim(sayThis))
        self.outpAlgPriority = priority  # DEFCON levels 1->5

    def pendingAlgorithm(self) -> bool:
        # Check if an algorithm is pending
        return self.outAlg is not None

    def skillNotes(self, param: str) -> str:
        # Provide skill notes
        return "notes unknown"
 

fukurou

the supreme coder
ADMIN
Java:
    public void algPartsFusion(int priority, Mutatable... algParts) {
        this.outAlg = new Algorithm(algParts);
        this.outpAlgPriority = priority; // 1->5, 1 is the highest algorithm priority
    }
 

fukurou

the supreme coder
ADMIN
Swift:
class APVerbatim: Mutatable {
    private var sentences: [String] = []

    init(sentences: String...) {
        self.sentences.append(contentsOf: sentences)
    }

    init(list1: [String]) {
        self.sentences = list1
    }

    override func action(ear: String, skin: String, eye: String) -> String {
        // Return the next sentence and remove it from the list
        if !self.sentences.isEmpty {
            return self.sentences.removeFirst()
        }
        return "" // Return empty string if no sentences left
    }

    override func completed() -> Bool {
        // Check if all sentences have been processed
        return self.sentences.isEmpty
    }
}
 

fukurou

the supreme coder
ADMIN
Swift:
class Algorithm {
    private var algParts: [Mutatable] = []

    init(algParts: [Mutatable]) {
        self.algParts = algParts
    }

    init(_ algParts: Mutatable...) {
        self.algParts = algParts
    }

    func getAlgParts() -> [Mutatable] {
        return algParts
    }

    func getSize() -> Int {
        return algParts.count
    }
}
 

fukurou

the supreme coder
ADMIN
Swift:
class Skill {
    protected var kokoro: Kokoro? = nil // Consciousness, shallow ref class to enable interskill communications
    protected var outAlg: Algorithm? = nil // Skills output
    protected var outpAlgPriority: Int = -1 // DEFCON levels 1->5

    init() {
        super.init()
    }

    // Skill triggers and algorithmic logic
    func input(ear: String, skin: String, eye: String) {
        // Implement skill triggers and algorithmic logic here
    }

    // Extraction of skill algorithm to run (if there is one)
    func output(noiron: Neuron) {
        if let outAlg = self.outAlg {
            noiron.insertAlg(outpAlgPriority, outAlg)
            self.outpAlgPriority = -1
            self.outAlg = nil
        }
    }

    func setKokoro(kokoro: Kokoro) {
        // Use this for telepathic communication between different chobits objects
        self.kokoro = kokoro
    }

    // In skill algorithm building shortcut methods:
    protected func setVerbatimAlg(priority: Int, sayThis: String...) {
        // Build a simple output algorithm to speak string by string per think cycle
        // Uses varargs param
        self.outAlg = Algorithm(APVerbatim(sayThis: sayThis))
        self.outpAlgPriority = priority // 1->5, 1 is the highest algorithm priority
    }

    protected func setSimpleAlg(sayThis: String...) {
        // Based on the setVerbatimAlg method
        // Build a simple output algorithm to speak string by string per think cycle
        // Uses varargs param
        self.outAlg = Algorithm(APVerbatim(sayThis: sayThis))
        self.outpAlgPriority = 4 // Default priority of 4
    }

    protected func setVerbatimAlgFromList(priority: Int, sayThis: [String]) {
        // Build a simple output algorithm to speak string by string per think cycle
        // Uses list param
        self.outAlg = Algorithm(APVerbatim(list1: sayThis))
        self.outpAlgPriority = priority // 1->5, 1 is the highest algorithm priority
    }

    func algPartsFusion(priority: Int, algParts: Mutatable...) {
        self.outAlg = Algorithm(algParts: algParts)
        self.outpAlgPriority = priority // 1->5, 1 is the highest algorithm priority
    }

    func pendingAlgorithm() -> Bool {
        // Is an algorithm pending?
        return self.outAlg != nil
    }

    func skillNotes(param: String) -> String {
        return "notes unknown"
    }
}
 

fukurou

the supreme coder
ADMIN
Code:
module AbsDictionaryDB

type SaveFunction = string -> string -> unit
type LoadFunction = string -> string

let createDictionaryDB (saveFunc: SaveFunction) (loadFunc: LoadFunction) =
    { new obj() with
        member _.Save = saveFunc
        member _.Load = loadFunc }
        
// Example usage
let saveToDb key value =
    printfn "Saved: Key = %s, Value = %s" key value

let loadFromDb key =
    printfn "Loaded: Key = %s" key
    "YourValueHere"

let myDb = createDictionaryDB saveToDb loadFromDb

// Use it!
myDb.Save "Hello" "World"
myDb.Load "Hello"
 

fukurou

the supreme coder
ADMIN
Code:
module AbsDictionaryDB

open System.Collections.Generic

type DictionaryDB(saveFunc, loadFunc) =
    let db = Dictionary<string, string>()

    member _.Save key value = saveFunc db key value
    member _.Load key = loadFunc db key

// Example save/load logic
let defaultSave (db: Dictionary<string, string>) key value =
    db.[key] <- value
    printfn "Default Save: Key = %s, Value = %s" key value

let defaultLoad (db: Dictionary<string, string>) key =
    if db.ContainsKey(key) then
        printfn "Default Load: Key = %s, Value = %s" key db.[key]
        db.[key]
    else
        printfn "Key not found: %s" key
        ""

// Custom save/load logic for a new instance
let customSave (db: Dictionary<string, string>) key value =
    db.[key] <- value
    printfn "Custom Save: Key = %s (custom logic applied!)" key

let customLoad (db: Dictionary<string, string>) key =
    if db.ContainsKey(key) then
        printfn "Custom Load: Key = %s, Value = %s (custom logic applied!)" key db.[key]
        db.[key]
    else
        printfn "Key not found (custom logic): %s" key
        ""

// Create instances with different logic
let defaultDb = DictionaryDB(defaultSave, defaultLoad)
let customDb = DictionaryDB(customSave, customLoad)

// Use the instances
defaultDb.Save "Hello" "World"
defaultDb.Load "Hello"

customDb.Save "CustomKey" "CustomValue"
customDb.Load "CustomKey"
 

fukurou

the supreme coder
ADMIN
C++:
class Skill {
protected:
    Kokoro* kokoro = nullptr;                     // Reference for interskill communication
    std::unique_ptr<Algorithm> outAlg = nullptr;  // Skill's output Algorithm
    int outpAlgPriority = -1;                     // Priority (1 -> 5, 1 being the highest)

public:
    Skill(); // Constructor

    // Skill triggers and algorithmic logic
    virtual void input(const std::string& ear, const std::string& skin, const std::string& eye);

    // Extraction of skill algorithm to run (if any)
    void output(Neuron& noiron);

    // Set Kokoro for interskill communication
    void setKokoro(Kokoro* kokoro);

    // Algorithm-building shortcut methods
protected:
    void setVerbatimAlg(int priority, const std::vector<std::string>& sayThis);
    void setSimpleAlg(const std::vector<std::string>& sayThis);
    void setVerbatimAlgFromList(int priority, const std::vector<std::string>& sayThis);
    void algPartsFusion(int priority, const std::vector<Mutatable*>& algParts);

public:
    bool pendingAlgorithm() const;
    virtual std::string skillNotes(const std::string& param) const;
};
 

fukurou

the supreme coder
ADMIN
C++:
// Constructor
Skill::Skill() {}

// Virtual input method (can be overridden in derived classes)
void Skill::input(const std::string& ear, const std::string& skin, const std::string& eye) {
    // No default implementation
}

// Output method: Passes the algorithm to Neuron
void Skill::output(Neuron& noiron) {
    if (outAlg) {
        noiron.insertAlg(outpAlgPriority, std::move(outAlg));
        outpAlgPriority = -1;
        outAlg = nullptr;
    }
}

// Set Kokoro for interskill communication
void Skill::setKokoro(Kokoro* kokoro) {
    this->kokoro = kokoro;
}

// Build a verbatim algorithm with specific priority
void Skill::setVerbatimAlg(int priority, const std::vector<std::string>& sayThis) {
    // Wrap APVerbatim in a vector of unique_ptr<Mutatable>
    std::vector<std::unique_ptr<Mutatable>> parts;
    parts.push_back(std::make_unique<APVerbatim>(sayThis));
    // Create Algorithm using the vector
    outAlg = std::make_unique<Algorithm>(std::move(parts));
    outpAlgPriority = priority;
}

// Build a simple output algorithm with default priority of 4
void Skill::setSimpleAlg(const std::vector<std::string>& sayThis) {
    setVerbatimAlg(4, sayThis);
}

// Build a verbatim algorithm from a list with specific priority
void Skill::setVerbatimAlgFromList(int priority, const std::vector<std::string>& sayThis) {
    setVerbatimAlg(priority, sayThis);
}

// Create an algorithm from a fusion of multiple Mutatables
void Skill::algPartsFusion(int priority, const std::vector<Mutatable*>& algParts) {
    // Convert raw pointers to unique_ptr for safe ownership transfer
    std::vector<std::unique_ptr<Mutatable>> parts;
    for (auto part : algParts) {
        parts.push_back(std::unique_ptr<Mutatable>(part));
    }
    // Create Algorithm using the vector
    outAlg = std::make_unique<Algorithm>(std::move(parts));
    outpAlgPriority = priority;
}

// Check if an algorithm is pending
bool Skill::pendingAlgorithm() const {
    return outAlg != nullptr;
}

// Default implementation for skill notes
std::string Skill::skillNotes(const std::string& param) const {
    return "notes unknown";
}
 
Top