Lesson 09 — The medium and the bridge (advanced)
The AI modules are Advantage™ components. A user defined program loads the medium (the center); the medium holds modules and owns the bridge that carries messages in both directions. Reference: modules README. Example program: user-program/UserProgram.sleela.
Read it first
Run UserProgram.sleela, then read the order of events: the program loads only
the modules it wants; modules announce ready on their own; the program asks and
gets replies; the evaluator volunteers a cardinal-veto event nobody asked for.
Three directions
- Program to module:
askwaits for the reply;telldoes not. - Module to program: replies plus unsolicited events, handed to your listener on
pump. - Module to module:
linkthe trader to the evaluator and each accepted trade is judged; a NO withdraws it. The trader reportstrade-judgedupward.
Safety you should be able to explain
Bounded queues (refuse, count, never grow); reserved names; error replies for
unknown modules and topics; a 100,000-message pump cap against ping-pong; a closed
bridge after shutdown. Why is refusing better than blocking here?
Exercises
- Write your own module (implement
SLAdvModule) that counts everytrade-judgedevent. How does it hear them if events go toprogram? - Load only the evaluator and judge 1,000 trades. What does the ledger say?
- Make two of your modules answer each other and watch
wasSaturated(). - Moral verdicts for high speed trades are YES, never COMPLETE. Which two time points fail, and is that the right outcome?