- Регистрация
- 9 Май 2015
- Сообщения
- 1,483
- Баллы
- 155

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

The personality directory structure is plug and play minimalist Livingrimoire directory
structure that does not require dynamic dispatch support for programming languages like Swift.
Paste in the livingrimoire packet directory, a DLC directory, and the main file.
To add skills:
Add the skill files into the DLC directory, and edit the personality
file, in which you add each skill with 1 line of code.
While in the Structure Supreme, skills can be added by only copy-pasting files into the DLC directory,
the personality structure also requires editing the personality file.
A merit to this is a clear view of all the skills inside a centralized location,
as well as the ability to package a complete set of skills in one go.

Feature | Structure Personality | Structure Supreme |
---|---|---|
Skill Addition | Manual (edit personality) | Automatic (drop-in DLC files) |
Centralized Skill Overview | ![]() ![]() | ![]() |
Packaging Skills | ![]() | ![]() |
Language Compatibility | ![]() | ![]() |
Runtime Skill Loading | ![]() | ![]() |



import Foundation
let brain = Brain()
loadPersonality(brain)
let brainQueue = DispatchQueue(label: "com.livingrimoire.queue")
let tickInterval: TimeInterval = 2
func brainLoop() {
while true {
let message = readLine() ?? ""
brain.think(message)
if message.lowercased() == "exit" {
print("Exiting...")
exit(0)
}
}
}
func tickLoop() {
var nextTick = Date().timeIntervalSince1970
while true {
let now = Date().timeIntervalSince1970
if now >= nextTick {
brainQueue.async {
brain.think()
}
nextTick += tickInterval
}
Thread.sleep(forTimeInterval: 0.01)
}
}
DispatchQueue.global().async { tickLoop() }
brainLoop()

import Foundation
func loadPersonality(_ brain: Brain) {
brain.addSkill(DiHelloWorld()) // hello world skill
brain.addSkill(DiTime()) // time utility skill
brain.addSkill(DiSysOut()) // output to console skill
// brain.chained(DiHelloWorld()).chained(DiTime()).chained(DiSysOut()) // alternative method to add the skills in 1 LOC
}
Would you like to know more?

Источник: