# better just use simple function call for all high level thinking, no class instance function call. we use python built-in function only in the bottom level, which is the end of everything. (到最后，功能拆无可拆，你实在忍不住的时候，用一用类似'a.startswith(b)'之类的东西。那必须是一个单文件，方便迁移与修改。别人的东西总是不靠谱的。)

define "what is love"() {
    print("ai in chinese.");
}

define "it is true"(it) {
    return "check if a string statement is true or false"(it);
}

define "can you help me to make love"() {
    if ("it is true"("i am a man")) {
        if ("it is true"("you are a female")) {
            print("sure");
        } else {
            print("no");
        }
    } else if ("it is true"("i am a female")) {
        if ("it is true"("you are a man")) {
            print("sure");
        } else {
            print("no");
        }
    }
}

define "what is it"(it) {
    return "search the text knowledge database"(it=it);
}

define "how to do it"("an action") {
    return "search the text knowledge database to know how to do an action"("an action");
}

define "how to make it"("a thing") {
    return "search the text knowledge database to know how to make a thing"("a thing"="a thing");
}

define remember(text) {
    "save to knowledge database"(text);
}

define "learn useful knowledge from text"(text) {
    if ("it is true"(text)) {
        remember(text);
    }
}

define "learn from experiments"(description) {
    if ("it is true"(text)) {
        remember(text);
    }
}

define "it is good for me and others"(it) {
    // sometimes not exists is also good for others
    return "search the text knowledge database"(it=it);
}

define "upgrade self"("direction and goal") {
    if ("it is good for me and others"("direction and goal")) {
        "update self code to make self better"("direction and goal");
    }
}

while (True) {
    description = "interact with envirnoment"();
    "learn from experiments"(description);
    if ("it is true"("i know how to create myself"())) {
        direction = "what is it"("a way to make myself better");
        "upgrade self"(direction);
    }
}
