Chatbot Control Script
From Blue Mars Developer Guidebook
The control script is stored as the value of the three user variables $precode $code and $postcode. They are concatenated together when used and exist separately as a documentation aid to the user. Logically $code contains how to generate the actual normal output. The others are optional things you do before and after (like generating emotions).
Topic script can alter the code variables at will, with the changes taking affect on the next input sentence processed by the chatbot.
The CHAT-L engine has a number of routines for how to access topic chat and the control script specifies which routines to execute under what conditions. Calling a routine consists of naming: when it can be run, how probable it is to run, what it is to run, and a possible argument to the routine. Each call must be separated by some amount of whitespace.
The codes for when it can be run are:
- - means only if we have not generated a normal output yet
- + means only if we have generated a normal output
- +- or -+ means always
- is the default, so if you do not provide one of these characters, then the unit will run only if no reply has been generated yet. But it is better practice to always supply the code.
Generating a normal reply means not creating a reply via ^preprint. ^Preprint is used to insert extra stuff in front, but doesn't count as main output.
How probable is a digit 1-9. It is the probability out of 10 that it runs. The default is always, so if you provide no digit, it will run if allowed with 100% probability. There is no point in using 0.
What to do is the name of a routine. Routines named topicXXX require a topic name as argument, encased in parens. Routines with the words Responder, Gambit, or continuation' will execute corresponding CHAT-L statement types. Routines with the word current mean the topic that was the present topic at the time the sentence was being responded to. It does not matter if that topic is no longer on the stack due to the execution of other routines, the topic being referred to is the original one. Routines with the word keyword refer to topics that have keyword matches with the current input.
Some routines are required of all CHAT-L implementations. Others are optional. If a routine called does not exist, the system merely ignores the call.
The miniaml required routines are:
- continuation – check for a continuation responder
- currentResponder- try responder in current topic
- currentGambit – try gambit in current topic
- keywordResponder – try responder in new topic having matching keywords -
- keywordGambit – try gambit in new topic having matching keywords -
- priorGambit- gambit in prior topic (popping topics from the stack to get there)
- topicResponder – try responder in named topic (delimiter +) -
- topicGambit – try gambit in named topic (delimiter +) -
- randomGambit – try gambit in random topic
Additional routines supported by this implementation include:
- quip – generate random quip –
- endIfMore – stop processing on this sentence if MORE sentences follow in input
- currentInput –gambit in current topic if topic’s keywords exist in input
The system maintains a stack of current topics. It can return to them if they are not too stale. If a responder matches from a topic buried on the stack, the stack entry will be deleted when the topic becomes current.
A note about the continuation function. If it matches on the first sentence of user input, it will do nothing if applied to a second sentence. On the other hand, if it fails to match on the first sentence, it can still try to match on the second.
Control script can also use [ ] to indicate a group of units, which is prefixed with the run and probability codes. So you can decide to run a group of units if no answer has yet been found and with a certain probability, but each unit inside the group will also independently be able to test whether an answer has been found yet and run its own probability.
A typical code set is:
- $precode= +-topicResponder(~XINTENT)
- $code= -continuation -currentResponder -keywordResponder -topicResponder(~xopinion) -topicResponder(~QUERY_TOM) -currentInput -6[-topicResponder(~ELIZA_ALL)] -keywordGambit -endIfMore -1quip -currentGambit -priorGambit -topicGambit(~ABOUT_YOU) -randomGambit -topicResponder(~XNORESPONSE)
- $postcode= +-topicResponder(~XTRANSITION) +-topicResponder(~XEMOTIONENGINE)
Which says:
- Always preprocess with topics ~XINTENT
- Always postprocess with topcis ~XTRANSITION and ~XEMOTIONENGINE
For normal output generation:
- try to use a continuation where you left off
- try to respond from the current topic
- try to respond using some other keyword-related topic
- try the keywordless ~XOPINION topic
- try the sytem special features ~QUERY_TOM topic
- If his input has keywords of the current topic, gambit from it (currentInput)
If these don’t provide a direct match to the input, we have free will.
- 60% of the time try to quibble instead of moving the conversation along
- Try a gambit from a keyword-related topic
- if there is another input sentence, stop trying (we let the next sentence guide us)
- make a quip 10% of the time
- gambit from current topic I
- gambit from prior topic
- gambit from random topic
- make a generic failed to respond message
