Skip to content

Commit a90de71

Browse files
Update ChatScript-Advanced-User-Manual.md
1 parent 3e070ac commit a90de71

File tree

1 file changed

+49
-56
lines changed

1 file changed

+49
-56
lines changed

WIKI/ChatScript-Advanced-User-Manual.md

Lines changed: 49 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# ChatScript Advanced User's Manual
2-
3-
> © Bruce Wilcox, gowilcox@gmail.com brilligunderstanding.com
4-
5-
> Revision 1/28/2017 cs7.12
1+
# ChatScript Advanced User's Manual
2+
© Bruce Wilcox, gowilcox@gmail.com www.brilligunderstanding.com
3+
<br>Revision 1/28/2017 cs7.12
4+
<br><br>
65

76
* [Review](ChatScript-Advanced-User-Manual.md#review-overview-of-how-cs-works)
87
* [Advanced Concepts](ChatScript-Advanced-User-Manual.md#advanced-concepts)
@@ -102,14 +101,15 @@ CS just directly embeds the arguments in the string and any attempt to use
102101
the active string implicitly invokes the equivalent of sprintf.
103102

104103
User variables also come in permanent and transient forms.
105-
<br>**Permanent variables** start with a single `$` and are preserved across user interactions
106-
(are saved and restored from disk). You can see and alter their value from anywhere.
107104

108-
<br>**Transient variables** start with `$$` and completely disappear when a user interaction
109-
happens (are not saved to disk). You can see and alter their value from anywhere.
105+
- **Permanent variables**
106+
start with a single `$` and are preserved across user interactions (are saved and restored from disk). You can see and alter their value from anywhere.
110107

111-
<br>**Local variables** (described later) start with `$_` and completely disappear when a user interaction
112-
happens (are not saved to disk). You can see and alter their value only within the topic or outputmacro they are used.
108+
- **Transient variables**
109+
start with `$$` and completely disappear when a user interaction happens (are not saved to disk). You can see and alter their value from anywhere.
110+
111+
- **Local variables**
112+
(described later) start with `$_` and completely disappear when a user interaction happens (are not saved to disk). You can see and alter their value only within the topic or outputmacro they are used.
113113

114114

115115
### Facts
@@ -234,17 +234,16 @@ was this
234234
```
235235
^myfunction( $myvar 1)
236236
```
237-
then the effect of `^argument1 += 1` is as though `$myvar += 1` were done and `$myvar` would now be one
238-
higher. Of course, had you tried to do
239-
`^argument2 += 1` then that would be the illegal `1 += 1` and the assignment would fail.
237+
then the effect of `^argument1 += 1` is as though `$myvar += 1` were done and `$myvar` would now be one higher.
240238

239+
Of course, had you tried to do `^argument2 += 1` then that would be the illegal `1 += 1` and the assignment would fail.
241240

242241
```
243242
outputmacro: ^myfunction( $_argument1 $_argument2)
244243
$_argument1 += 1
245244
```
246245

247-
Use of $_ variables in the function definition is a call by value. All $_ variables are purely local and cannot
246+
Use of `$_` variables in the function definition is a call by value. All `$_` variables are purely local and cannot
248247
be seen outside of the function (or topic) they are used in. You can also mix call by reference and call by
249248
value arguments.
250249

@@ -299,7 +298,8 @@ Concepts can be built from other concepts that do not have specific words.
299298
Concept: ~myconcept (!thisword ~otherconcept)
300299
```
301300

302-
Note: the system has two kinds of concepts. Enumerated concepts are ones formed from an explicit list of members. Stuff in definitions of concept: ~xxx() are that. There are also internal concepts marked by the system. These include part of speech of a word (requires using the pos-tagger to decide from the input what part of speech it was of possibly several), grammatical roles, words from infinite sets like ~number and ~placenumber and ~weburl, and so forth.
301+
Note: the system has two kinds of concepts. Enumerated concepts are ones formed from an explicit list of members. Stuff in definitions of `concept: ~xxx()` are that.
302+
There are also internal concepts marked by the system. These include part of speech of a word (requires using the pos-tagger to decide from the input what part of speech it was of possibly several), grammatical roles, words from infinite sets like `~number` and `~placenumber` and `~weburl`, and so forth.
303303

304304
In a pattern of some kind, if you are referencing a sentence location using a match variable, you can match both kinds of concepts. But if you are not tied to a location in a sentence, you can't match internally computed ones. So something like
305305
```
@@ -323,13 +323,13 @@ When a topic is executing rules, it does not stop just because a rule matches. I
323323
executing rules until some rule generates ouput for the user or something issues an
324324
appropriate `^end` or `^fail` call. So you can do things like this:
325325
```
326-
u: (I love) $userloves = true
326+
u: ( I love ) $userloves = true
327327
328328
u: ( dog ) $animal = dog
329329
330-
u: ( love) Glad to hear it
330+
u: ( love ) Glad to hear it
331331
332-
u: ( dog) I hate dogs
332+
u: ( dog ) I hate dogs
333333
```
334334
and given _I love dogs_, the system will set $userloves and $animal and output glad to
335335
hear it.
@@ -344,27 +344,27 @@ topic: ~rust keep random [rust iron oxide]
344344
```
345345
The flags and their meanings are:
346346

347-
|flag | description |
348-
|-------------|-------------------------------------|
349-
|`Random` | search rules randomly instead of linearly
350-
|`NoRandom` | (default) search rules linearly
351-
|`Keep` | do not erase responders ever. Gambits (and rejoinders) are not affected by this
352-
|`Erase` | (default) erase responders that successfully generate output.<br>Gambits automatically erase unless you suppress them specifically.
353-
|`NoStay` | do not consider this a topic to remain in, leave it (except for rejoinders)
354-
|`Stay` | (default) make this a pending topic when it generates output
355-
|`Repeat` | allow rules to generate output which has been output recently
356-
|`NoRepeat` | (default) do not generate output if it matches output made recently
357-
|`Priority` | raise the priority of this topic when matching keywords
358-
|`Normal` | (default) give this topic normal priority when matching keywords
359-
|`Deprioritize`| lower the priority of this topic when matching keywords
360-
|`System` | this is a system topic. It is automatically `NoStay`, `Keep`.<br>`Keep` automatically applies to gambits as well. The system never looks to these topics for gambits. System topics can never be considered pending (defined shortly). They can not have themselves or their rules be enabled or disabled. Their status/data is never saved to user files.
361-
|`User` | (default) this is a normal topic
362-
|`NoBlocking` | should not perform any blocking tests on this topic in `:verify`
363-
|`NoPatterns` | should not perform any pattern tests on this topic in `:verify`
364-
|`NoSamples` | should not perform any sample tests on this topic in `:verify`
365-
|`NoKeys` | should not perform any keyword tests on this topic in `:verify`
366-
|`More` | normally if you try to redeclare a concept, you get an error. `MORE` tells CS you intend to extend the concept and allows additional keywords.
367-
|`Bot=name` | if this is given, only named bots are allowed to use this topic. See `ChatScript Multiple Bots manual`
347+
|flag | description
348+
|:----------------:|--------------
349+
|__`Random`__ | search rules randomly instead of linearly
350+
|__`NoRandom`__ | (default) search rules linearly
351+
|__`Keep`__ | do not erase responders ever. Gambits (and rejoinders) are not affected by this
352+
|__`Erase`__ | (default) erase responders that successfully generate output.<br>Gambits automatically erase unless you suppress them specifically.
353+
|__`NoStay`__ | do not consider this a topic to remain in, leave it (except for rejoinders)
354+
|__`Stay`__ | (default) make this a pending topic when it generates output
355+
|__`Repeat`__ | allow rules to generate output which has been output recently
356+
|__`NoRepeat`__ | (default) do not generate output if it matches output made recently
357+
|__`Priority`__ | raise the priority of this topic when matching keywords
358+
|__`Normal`__ | (default) give this topic normal priority when matching keywords
359+
|__`Deprioritize`__| lower the priority of this topic when matching keywords
360+
|__`System`__ | this is a system topic. It is automatically `NoStay`, `Keep`.<br>`Keep` automatically applies to gambits as well. The system never looks to these topics for gambits. System topics can never be considered pending (defined shortly). They can not have themselves or their rules be enabled or disabled. Their status/data is never saved to user files.
361+
|__`User`__ | (default) this is a normal topic
362+
|__`NoBlocking`__ | should not perform any blocking tests on this topic in `:verify`
363+
|__`NoPatterns`__ | should not perform any pattern tests on this topic in `:verify`
364+
|__`NoSamples`__ | should not perform any sample tests on this topic in `:verify`
365+
|__`NoKeys`__ | should not perform any keyword tests on this topic in `:verify`
366+
|__`More`__ | normally if you try to redeclare a concept, you get an error. `MORE` tells CS you intend to extend the concept and allows additional keywords.
367+
|__`Bot=name`__ | if this is given, only named bots are allowed to use this topic. See `ChatScript Multiple Bots manual`
368368

369369

370370
## Rules that erase and repeat
@@ -934,7 +934,7 @@ the `_` equivalent) is a single item, whereas ( take charge) is 4 items.
934934

935935
So the first rule will below will match faster than the second rule:
936936
```
937-
u: ( "I love you today when")
937+
u: ("I love you today when")
938938
939939
u: (I love you today when)
940940
```
@@ -1796,22 +1796,14 @@ and have the system automatically generate gestures during postprocessing on its
17961796
The stand-alone engine and the WEBINTERFACE/BETTER scripts automatically handle
17971797
the following oob outputs:
17981798

1799-
**Callback**: The webpage or stand-alone engine will wait for the designated milliseconds
1800-
and if the user has not begun typing will send in the oob message [callback] to CS. If user
1801-
begins typing before the timeout, the callback is cancelled.
1802-
e.g. `[callback=3000]` will wait 3 seconds.
1799+
- **Callback**
1800+
The webpage or stand-alone engine will wait for the designated milliseconds and if the user has not begun typing will send in the oob message [callback] to CS. If user begins typing before the timeout, the callback is cancelled. e.g. `[callback=3000]` will wait 3 seconds.
18031801

1804-
**Loopback**: The webpage or stand-alone engine will wait for the designated milliseconds
1805-
after every output from CS and if the user has not begun typing will send in the oob
1806-
message [loopback] to CS. If user begins typing before the timeout, the loopback is
1807-
cancelled for this output only, and will resume counting on the next output.
1808-
e.g. `[loopback=3000]` will wait 3 seconds after every output.
1802+
- **Loopback**
1803+
The webpage or stand-alone engine will wait for the designated milliseconds after every output from CS and if the user has not begun typing will send in the oob message [loopback] to CS. If user begins typing before the timeout, the loopback is cancelled for this output only, and will resume counting on the next output. e.g. `[loopback=3000]` will wait 3 seconds after every output.
18091804

1810-
**Alarm**: The webpage or stand-alone engine will wait for the designated milliseconds and
1811-
then send in the oob message [alarm] to CS. Input typing has no effect.
1812-
e.g. `[alarm=3000]` will wait 3 seconds and then send in the alarm.
1813-
CS can cancel any of these by sending an oob message with a milliseconds of 0.
1814-
e.g. `[loopback=0 callback=0 alarm=0]` cancels any pending callbacks into the future.
1805+
- **Alarm**
1806+
The webpage or stand-alone engine will wait for the designated milliseconds and then send in the oob message [alarm] to CS. Input typing has no effect. e.g. `[alarm=3000]` will wait 3 seconds and then send in the alarm. CS can cancel any of these by sending an oob message with a milliseconds of 0. e.g. `[loopback=0 callback=0 alarm=0]` cancels any pending callbacks into the future.
18151807

18161808

18171809
# System callback functions
@@ -2091,7 +2083,7 @@ Normally lower case words would break up a title.
20912083

20922084
# Common Script Idioms
20932085

2094-
## Selecting Specific Cases ^refine
2086+
## Selecting Specific Cases `^refine`
20952087

20962088
To be efficient in rule processing, I often catch a lot of things in a rule and then refine it.
20972089
```
@@ -2144,6 +2136,7 @@ u: (where * you * live) ^reuse(HOUSE)
21442136
The rule on disabling a rule after use is that the rule that actually generates the output gets disabled.
21452137
So the default behavior (if you don't set keep on the topic or the rule) is that if the question is asked first,
21462138
it reuses HOUSE.
2139+
21472140
Since we have given the answer, we don't want to repetitiously volunteer it, HOUSE gets disabled.
21482141
But, if the user repetitiously asks the question (maybe he forgot the answer), we will answer it again because the responder
21492142
didn't get disabled, just the gambit. And disabling applies to allowing a rule to try to

0 commit comments

Comments
 (0)