~/ learn/ comp-456/ cards/ The blackboard architecture
1 of 3

Simulate a blackboard: each knowledge source fires when its trigger condition holds on the blackboard, posts a new level, and the scheduler loops until nothing more can contribute.

Simulate a blackboard: each knowledge source fires when its trigger condition holds on the blackboard, posts a new level, and the scheduler loops until nothing more can contribute.

Answer

def run_blackboard(blackboard, knowledge_sources): changed = True while changed: changed = False for name, trigger, contribute in knowledge_sources: if trigger(blackboard): level, value = contribute(blackboard) blackboard[level] = value print(f"{name} posts {level} = {value}") changed = True print("scheduler: no source can contribute -- done") sources = [ ("KS-signal", lambda b: "signal" in b and "phonemes" not in b, lambda b: ("phonemes", ["k", "ae", "t"])), ("KS-word", lambda b: "phonemes" in b and "word" not in b, lambda b: ("word", "cat")), ("KS-phrase", lambda b: "word" in b and "phrase" not in b, lambda b: ("phrase", "the cat")), ] run_blackboard({"signal": "raw"}, sources)

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/c8dd5aa7-e75b-4340-94ab-fa9d3e6eb4e1/flashcard utf-8 LF