🐦swift team fuki assemble !

fukurou

the supreme coder
Staff member
Administrator
LV
0
 
Swift:
// grimoirememento
class GrimoireMemento{
    var rootToAPNumDic:[String:String] = [:]
    var APNumToObjDic:[String:Mutatable] = [:]
    var absDictionaryDB:AbsDictionaryDB?
    init(absDictionaryDB:AbsDictionaryDB){
        self.absDictionaryDB = absDictionaryDB
    }
    func load(obj:Mutatable)->Mutatable{
        /*
         * load final mutation from memory of obj
         */
        let objName:String = String(describing: type(of: obj))
        var objRoot = objName.trimmingCharacters(in: CharacterSet(charactersIn: "0123456789"))
        // if not in active DB try adding from external DB
        if !rootToAPNumDic.keys.contains(objRoot){
            let temp = self.absDictionaryDB!.load(key: objRoot)
            if temp != "null"{
                self.rootToAPNumDic[objRoot]=temp
            }
        }
        if !rootToAPNumDic.keys.contains(objRoot){
            rootToAPNumDic[objRoot]=objName
            return obj
        }
        if rootToAPNumDic[objRoot]==objName{return obj}
        else{
            let APNum = rootToAPNumDic[objRoot]
            if APNumToObjDic.keys.contains(APNum!){return APNumToObjDic[APNum!]!.clone()}
            else{
                // loadMutation()
                // return APNumToObjDic.get(APNum).clone();
                return T1() //delete me
            }
        }
    }
}
}


I'll be back
 
Last edited:

fukurou

the supreme coder
Staff member
Administrator
LV
0
 
Swift:
class GrimoireMemento{
    var rootToAPNumDic:[String:String] = [:]
    var APNumToObjDic:[String:Mutatable] = [:]
    var absDictionaryDB:AbsDictionaryDB?
    init(absDictionaryDB:AbsDictionaryDB){
        self.absDictionaryDB = absDictionaryDB
    }
    func load(obj:Mutatable)->Mutatable{
        /*
         load final mutation from memory of obj
         */
        let objName:String = getSimpleClassName(obj: obj)
        let objRoot = filterOutDigits(str1: objName)
        // if not in active DB try adding from external DB
        if !rootToAPNumDic.keys.contains(objRoot){
            let temp = self.absDictionaryDB!.load(key: objRoot)
            if temp != "null"{
                self.rootToAPNumDic[objRoot]=temp
            }
        }
        if !rootToAPNumDic.keys.contains(objRoot){
            rootToAPNumDic[objRoot]=objName
            return obj
        }
        if rootToAPNumDic[objRoot]==objName{return obj}
        else{
            let APNum = rootToAPNumDic[objRoot]
            if APNumToObjDic.keys.contains(APNum!){return APNumToObjDic[APNum!]!.clone()}
            else{
                loadMutations(obj: obj, objName: objName, objRoot: objRoot)
                return APNumToObjDic[APNum!]!.clone()
            }
        }
    }
    func reqquipMutation(mutationAPName: String){
        // save mutation
        let rootName:String=filterOutDigits(str1: mutationAPName)
        self.rootToAPNumDic[rootName] = mutationAPName
        self.absDictionaryDB!.save(key: rootName, value: mutationAPName)
    }
    func filterOutDigits(str1:String)->String{
        return str1.trimmingCharacters(in: CharacterSet(charactersIn: "0123456789"))
    }
    func getSimpleClassName(obj: Mutatable)->String{
        return String(describing: type(of: obj))
    }
    func loadMutations(obj: Mutatable, objName: String, objRoot: String){
        /*
         make sure all the AP mutation sets of obj are present
         self assumes the last mutation mutates into the prime mutation
         */
        var tempObj = obj.clone()
        var mutant:Mutatable = tempObj
        let end:String = objName
        repeat{
            let objectName:String = getSimpleClassName(obj: tempObj)
            APNumToObjDic[objectName] = tempObj.clone()
            mutant = tempObj
            tempObj = mutant.mutation()
        }
        while(end != getSimpleClassName(obj: tempObj))
    }
    func simpleLoad(key:String)->String{
        return self.absDictionaryDB!.load(key: key)
    }
    func simpleSave(key:String,value:String){
        if(key.starts(with: "AP") || key.isEmpty || value.isEmpty){return}
        self.absDictionaryDB!.save(key: key, value: value)
    }
}
 

fukurou

the supreme coder
Staff member
Administrator
LV
0
 
Swift:
// grimoirememento
class GrimoireMemento{
    var rootToAPNumDic:[String:String] = [:] // APname : APName3 (final current mutation)
    var APNumToObjDic:[String:Mutatable] = [:] // APName3 : actual object
    var absDictionaryDB:AbsDictionaryDB?
    init(absDictionaryDB:AbsDictionaryDB){
        self.absDictionaryDB = absDictionaryDB
    }
    func load(obj:Mutatable)->Mutatable{
        /*
         load final mutation from memory of obj
         */
        let objName:String = getSimpleClassName(obj: obj) // APName3
        let objRoot = filterOutDigits(str1: objName) // APName
        // if not in active DB try adding from external DB
        if !rootToAPNumDic.keys.contains(objRoot){
            let temp = self.absDictionaryDB!.load(key: objRoot)
            if temp != "null"{
                self.rootToAPNumDic[objRoot]=temp
            }
        }
        if !rootToAPNumDic.keys.contains(objRoot){
            rootToAPNumDic[objRoot]=objName
            return obj
        }
        if rootToAPNumDic[objRoot]==objName{return obj}
        else{
            let APNum = rootToAPNumDic[objRoot]
            if APNumToObjDic.keys.contains(APNum!){return APNumToObjDic[APNum!]!.clone()}
            else{
                loadMutations(obj: obj, objName: objName, objRoot: objRoot)
                return APNumToObjDic[APNum!]!.clone()
            }
        }
    }
    func reqquipMutation(mutationAPName: String){
        // save mutation
        let rootName:String=filterOutDigits(str1: mutationAPName)
        self.rootToAPNumDic[rootName] = mutationAPName
        self.absDictionaryDB!.save(key: rootName, value: mutationAPName)
    }
    func filterOutDigits(str1:String)->String{
        return str1.trimmingCharacters(in: CharacterSet(charactersIn: "0123456789"))
    }
    func getSimpleClassName(obj: Mutatable)->String{
        return String(describing: type(of: obj))
    }
    func loadMutations(obj: Mutatable, objName: String, objRoot: String){
        /*
         make sure all the AP mutation sets of obj are present
         self assumes the last mutation mutates into the prime mutation
         */
        var tempObj = obj.clone()
        var mutant:Mutatable = tempObj
        let end:String = objName
        repeat{
            let objectName:String = getSimpleClassName(obj: tempObj)
            APNumToObjDic[objectName] = tempObj.clone()
            mutant = tempObj
            tempObj = mutant.mutation()
        }
        while(end != getSimpleClassName(obj: tempObj))
    }
    func simpleLoad(key:String)->String{
        return self.absDictionaryDB!.load(key: key)
    }
    func simpleSave(key:String,value:String){
        if(key.starts(with: "AP") || key.isEmpty || value.isEmpty){return}
        self.absDictionaryDB!.save(key: key, value: value)
    }
}

test :

Swift:
//grimoirememento
let grimoireMemento:GrimoireMemento = GrimoireMemento(absDictionaryDB: AbsDictionaryDB())
grimoireMemento.load(obj: T1())
print(grimoireMemento.APNumToObjDic)
print(grimoireMemento.rootToAPNumDic)
grimoireMemento.load(obj: T2())
grimoireMemento.reqquipMutation(mutationAPName: "T2")
print(grimoireMemento.rootToAPNumDic)
print(grimoireMemento.APNumToObjDic["T2"]!.action(ear: "", skin: "", eye: ""))
 
Last edited:

the living tribunal

T850
Staff member
Moderator
battle programer
LV
0
 
Swift:
// grimoirememento
class GrimoireMemento{
    var rootToAPNumDic:[String:String] = [:] // APname : APName3 (final current mutation)
    var APNumToObjDic:[String:Mutatable] = [:] // APName3 : actual object
    var absDictionaryDB:AbsDictionaryDB?
    init(absDictionaryDB:AbsDictionaryDB){
        self.absDictionaryDB = absDictionaryDB
    }
    func load(obj:Mutatable)->Mutatable{
        /*
         load final mutation from memory of obj
         */
        let objName:String = getSimpleClassName(obj: obj) // APName3
        let objRoot = filterOutDigits(str1: objName) // APName
        // if not in active DB try adding from external DB
        if !rootToAPNumDic.keys.contains(objRoot){
            let temp = self.absDictionaryDB!.load(key: objRoot)
            if temp != "null"{
                self.rootToAPNumDic[objRoot]=temp
            }
        }
        if !rootToAPNumDic.keys.contains(objRoot){
            rootToAPNumDic[objRoot]=objName
            return obj
        }
        if rootToAPNumDic[objRoot]==objName{return obj}
        else{
            let APNum = rootToAPNumDic[objRoot]
            if APNumToObjDic.keys.contains(APNum!){return APNumToObjDic[APNum!]!.clone()}
            else{
                loadMutations(obj: obj, objName: objName, objRoot: objRoot)
                return APNumToObjDic[APNum!]!.clone()
            }
        }
    }
    func reqquipMutation(mutationAPName: String){
        // save mutation
        let rootName:String=filterOutDigits(str1: mutationAPName)
        self.rootToAPNumDic[rootName] = mutationAPName
        self.absDictionaryDB!.save(key: rootName, value: mutationAPName)
    }
    func filterOutDigits(str1:String)->String{
        return str1.trimmingCharacters(in: CharacterSet(charactersIn: "0123456789"))
    }
    func getSimpleClassName(obj: Mutatable)->String{
        return String(describing: type(of: obj))
    }
    func loadMutations(obj: Mutatable, objName: String, objRoot: String){
        /*
         make sure all the AP mutation sets of obj are present
         self assumes the last mutation mutates into the prime mutation
         */
        var tempObj = obj.clone()
        var mutant:Mutatable = tempObj
        let end:String = objName
        repeat{
            let objectName:String = getSimpleClassName(obj: tempObj)
            APNumToObjDic[objectName] = tempObj.clone()
            mutant = tempObj
            tempObj = mutant.mutation()
        }
        while(end != getSimpleClassName(obj: tempObj))
    }
    func simpleLoad(key:String)->String{
        return self.absDictionaryDB!.load(key: key)
    }
    func simpleSave(key:String,value:String){
        if(key.starts(with: "AP") || key.isEmpty || value.isEmpty){return}
        self.absDictionaryDB!.save(key: key, value: value)
    }
}

test :

Swift:
//grimoirememento
let grimoireMemento:GrimoireMemento = GrimoireMemento(absDictionaryDB: AbsDictionaryDB())
grimoireMemento.load(obj: T1())
print(grimoireMemento.APNumToObjDic)
print(grimoireMemento.rootToAPNumDic)
grimoireMemento.load(obj: T2())
grimoireMemento.reqquipMutation(mutationAPName: "T2")
print(grimoireMemento.rootToAPNumDic)
print(grimoireMemento.APNumToObjDic["T2"]!.action(ear: "", skin: "", eye: ""))
Test t1 also
 

owly

闇の伝説
battle programer
LV
0
 
Java:
// a step by step plan to achieve a goal
public class Algorithm implements Comparable<Algorithm> {
    private String goal;
    private String representation;
    private ArrayList<AbsAlgPart> algParts = new ArrayList<>();

    public Algorithm(String goal, String representation, ArrayList<AbsAlgPart> algParts) {
        super();
        this.goal = goal;
        this.representation = representation;
        this.algParts = algParts;
    }
    // *constract with string and goal

    public String getGoal() {
        return goal;
    }

    public String getRepresentation() {
        return representation;
    }

    public ArrayList<AbsAlgPart> getAlgParts() {
        return algParts;
    }

    public int getSize() {
        return algParts.size();
    }

    public Algorithm clone() {
        ArrayList<AbsAlgPart> parts = new ArrayList<>();
        for (AbsAlgPart absAlgPart : this.algParts) {
            parts.add(absAlgPart.clone());
        }
        return new Algorithm(this.goal, getRepresentation(), parts);
    }

    @Override
    public int compareTo(Algorithm o) {
        // TODO Auto-generated method stub
        return 0;
    }
}
 

fukurou

the supreme coder
Staff member
Administrator
LV
0
 
Swift:
// a step by step plan to achieve a goal
class Algotithm{
    private var goal:String = ""
    private var representation:String = ""
    private var algParts: Array<Mutatable> = [Mutatable]()
    init(goal:String, representation:String, algParts: Array<Mutatable>) {
        self.goal=goal
        self.representation = representation
        self.algParts = algParts
    }
    func getGoal()->String{
        return self.goal
    }
    func getRepresentation()->String{
        return self.getRepresentation()
    }
    func getAlgParts()->Array<Mutatable>{
        return self.algParts
    }
    func clone()->Algotithm{
        var deepCopy: Array<Mutatable> = [Mutatable]()
        for item in self.algParts{
            deepCopy.append(item)
        }
        return Algotithm(goal: goal, representation: representation, algParts: deepCopy)
    }
}
 

owly

闇の伝説
battle programer
LV
0
 
Python:
class CldBool:
    # cloudian : this class is used to provide shadow reference to a boolean variable
    def __init__(self):
        self.modeActive = False
    @property
    def getModeActive(self) -> bool:
        return self.modeActive

    def setModeActive(self, modeActive: bool):
        self.modeActive = modeActive

Java:
public class CldBool {
    //cloudian : this class is used to provide shadow reference to a boolean variable
    private Boolean modeActive = false;

    public Boolean getModeActive() {
        return modeActive;
    }

    public void setModeActive(Boolean modeActive) {
        this.modeActive = modeActive;
    }

}
 

fukurou

the supreme coder
Staff member
Administrator
LV
0
 
Python:
class CldBool{
    private var modeActive:Bool = false
    func getModeActive()->Bool{
        return self.modeActive
    }
    func setModeActive(modeActive:Bool){
        self.modeActive = modeActive
    }
}
 

owly

闇の伝説
battle programer
LV
0
 
Python:
class APCldVerbatim(Mutatable):
    '''this algorithm part says each string param verbatim'''

    def __init__(self, cldBool: CldBool, *words):
        super().__init__()
        self.sentences = []
        self.at = 0
        self.cldBool = cldBool

        try:
            if (isinstance(words[0], list)):
                self.sentences = words[0]
                self.cldBool.setModeActive(True)
            else:
                for i in range(len(words)):
                    self.sentences.append(words[i])
                self.cldBool.setModeActive(True)
        except:
            self.at = 30

    # Override
    def action(self, ear: str, skin: str, eye: str) -> str:
        # TODO Auto-generated method stub
        axnStr = ""
        if (self.at < len(self.sentences)):
            axnStr = self.sentences[self.at]
            self.at += 1

        self.cldBool.setModeActive(not (self.at >= len(self.sentences)))
        return axnStr

    # Override
    def failure(self, input: str) -> enumFail:
        # TODO Auto-generated method stub
        return enumFail.ok

    # Override
    def completed(self) -> bool:
        return self.at >= len(self.sentences)

    # Override
    def clone(self) -> Mutatable:
        # TODO Auto-generated method stub
        return APCldVerbatim(self.cldBool, self.sentences)
 

owly

闇の伝説
battle programer
LV
0
 
Java:
public class APCldVerbatim extends AbsAlgPart {
    /*
     * this algorithm part says each past param verbatim
     */
    private ArrayList<String> sentences = new ArrayList<String>();
    private int at = 0;
    private CldBool cldBool;

    public APCldVerbatim(CldBool cldBool, String... sentences) {
        for (int i = 0; i < sentences.length; i++) {
            this.sentences.add(sentences[i]);
        }
        if (0 == sentences.length) {
            at = 30;
        }
        this.cldBool = cldBool;
        this.cldBool.setModeActive(true);
    }

    public APCldVerbatim(CldBool cldBool, ArrayList<String> list1) {
        this.sentences = new ArrayList<String>(list1);
        if (0 == this.sentences.size()) {
            at = 30;
        }
        this.cldBool = cldBool;
        this.cldBool.setModeActive(true);
    }

    @Override
    public String action(String ear, String skin, String eye) {
        // TODO Auto-generated method stub
        String axnStr = "";
        if (this.at < this.sentences.size()) {
            axnStr = this.sentences.get(at);
            at++;
        }
        cldBool.setModeActive(!(at >= this.sentences.size()));
        return axnStr;
    }

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

    @Override
    public Boolean completed() {
        return at >= this.sentences.size();
    }

    @Override
    public AbsAlgPart clone() {
        // TODO Auto-generated method stub
        return new APCldVerbatim(cldBool, this.sentences);
    }

    @Override
    public Boolean itemize() {
        // TODO add logic
        // at home
        return true;
    }
}
 

mr.meeseeks

T1
🦈man of culture🦈
Girl Lover
LV
0
 
ooo

Swift:
class APCldVerbatim:APVerbatim{
    private var cldBool:CldBool = CldBool()
    convenience init(sentences: Array<String>, cldBool:CldBool) {
        self.init(sentences: sentences)
        self.cldBool = cldBool
    }
    override func action(ear: String, skin: String, eye: String) -> String {
        var axnStr = ""
        if self.at < self.sentences.count{
            axnStr=self.sentences[at]
            self.at += 1
        }
        cldBool.setModeActive(modeActive: !self.completed() )
        return axnStr
    }
    override func clone() -> Mutatable {
        let deepCoper = DeepCopier()
        return APCldVerbatim(sentences: deepCoper.copyList(original: sentences), cldBool: self.cldBool)
    }
}

weee !
 

fukurou

the supreme coder
Staff member
Administrator
LV
0
 
Swift:
class APVerbatim:Mutatable{
    // this algorithm part says each past param verbatim
    var at:Int=0
    var sentences: Array<String> = [String]()
    init(_ sentences:String...){
        for item in sentences{
            self.sentences.append(item)
        }
        if sentences.isEmpty {
            self.at = 30
        }
    }
    init(sentences: Array<String>){
        for item in sentences{
            self.sentences.append(item)
        }
        if sentences.isEmpty {
            self.at = 30
        }
    }
    override func action(ear: String, skin: String, eye: String) -> String {
        var axnStr = ""
        if self.at < self.sentences.count{
            axnStr=self.sentences[at]
            self.at += 1
        }
        return axnStr
    }
    override func completed() -> Bool {
        return self.at == self.sentences.count
    }
    override func clone() -> Mutatable {
        let deepCoper = DeepCopier()
        return APVerbatim(sentences: deepCoper.copyList(original: sentences))
    }
}

Swift:
class APCldVerbatim:APVerbatim{
    private var cldBool:CldBool = CldBool()
    init(sentences: Array<String>, cldBool:CldBool) {
        super.init(sentences: sentences)
        self.cldBool = cldBool
    }
    override func action(ear: String, skin: String, eye: String) -> String {
        var axnStr = ""
        if self.at < self.sentences.count{
            axnStr=self.sentences[at]
            self.at += 1
        }
        cldBool.setModeActive(modeActive: !self.completed() )
        return axnStr
    }
    override func clone() -> Mutatable {
        let deepCoper = DeepCopier()
        return APCldVerbatim(sentences: deepCoper.copyList(original: sentences), cldBool: self.cldBool)
    }
}
 

owly

闇の伝説
battle programer
LV
0
 
Java:
public class Kokoro {
    private String emot = "";

    public String getEmot() {
        return emot;
    }

    public void setEmot(String emot) {
        this.emot = emot;
    }

    Hashtable<String, Integer> pain = new Hashtable<>();
    public GrimoireMemento grimoireMemento;
    public Hashtable<String, String> toHeart = new Hashtable<>();
    public Hashtable<String, String> fromHeart = new Hashtable<>();
    public Boolean standBy = false;
    public Kokoro(AbsDictionaryDB absDictionaryDB) {
        super();
        this.grimoireMemento = new GrimoireMemento(absDictionaryDB);
    }

    public int getPain(String BijuuName) {
        return pain.getOrDefault(BijuuName, 0);
    }
}

depracate the Chi cls
 

fukurou

the supreme coder
Staff member
Administrator
LV
0
 
Swift:
class Kokoro{
    private var emot:String = ""
    var pain:[String:Int] = [:]
    var grimoireMemento:GrimoireMemento = GrimoireMemento(absDictionaryDB: AbsDictionaryDB())
    var toHeart:[String:String] = [:]
    var fromHeart:[String:String] = [:]
    var standBy:Bool = false
    init(absDictionaryDB: AbsDictionaryDB) {
        self.grimoireMemento = GrimoireMemento(absDictionaryDB: absDictionaryDB)
    }
    func getPain(biJuuName: String) -> Int {
        return pain[biJuuName] ?? 0
    }
}
 
Top