Similar to a previous post on stacks, I use queues for some internal processing operations. They implement a FIFO (First in First out) strategy. My queues are 30 levels deep so they can store 30 sentences, 30 words, or 30 characters depending on how they are used. You can add more levels if needed. There is overhead to them so I am not sure how large you can make them.
The commands are XENQUEUE QUEUE1 <value> to add a value and XDEQUEUE QUEUE1 to retrieve a value. XENQUEUE adds values to the bottom of the queue pushing all other values up. The XDEQUEUE logic looks for the first nonempty value starting from the top and if it has not found an answer it assigns it as the answer to the call and sets the value to EMPTY. There may be a better way to implement this including nesting the 30 condition blocks however this method seem to work.
Human: XENQUEUE QUEUE1 one
sienna2:
Human: XENQUEUE QUEUE1 two
sienna2:
Human: XENQUEUE QUEUE1 three
sienna2:
Human: XDEQUEUEALL QUEUE1
sienna2: one two three
I used a queue to get around the maximum predicate text size so I could document the way my chatbot thought about math problems. I can store 30 times the maximum predicate text limit with a queue and write it out to a learned category.
Here is the code:
<category>
<pattern>XENQUEUEALL * * *</pattern>
<template>
<srai>XENQUEUE <star/> <star index="2"/></srai>
<srai>XENQUEUEALL <star/> <star index="3"/></srai>
</template>
</category>
<category>
<pattern>XENQUEUEALL * *</pattern>
<template>
<srai>XCLEARQUEUE <star/></srai>
<srai>XENQUEUE <star/> <star index="2"/></srai>
</template>
</category>
<category>
<pattern>XDEQUEUEALL *</pattern>
<template><think>
<set name="next"><srai>XDEQUEUE <star/></srai></set>
</think><condition name="next">
<li value="EMPTY"></li>
<li><get name="next"/> <srai>XDEQUEUEALL <star/></srai></li>
</condition>
</template>
</category>
<category>
<pattern>XENQUEUE QUEUE1 *</pattern>
<template><think>
<set name="QUEUE1LEVEL1"><get name="QUEUE1LEVEL2"/></set>
<set name="QUEUE1LEVEL2"><get name="QUEUE1LEVEL3"/></set>
<set name="QUEUE1LEVEL3"><get name="QUEUE1LEVEL4"/></set>
<set name="QUEUE1LEVEL4"><get name="QUEUE1LEVEL5"/></set>
<set name="QUEUE1LEVEL5"><get name="QUEUE1LEVEL6"/></set>
<set name="QUEUE1LEVEL6"><get name="QUEUE1LEVEL7"/></set>
<set name="QUEUE1LEVEL7"><get name="QUEUE1LEVEL8"/></set>
<set name="QUEUE1LEVEL8"><get name="QUEUE1LEVEL9"/></set>
<set name="QUEUE1LEVEL9"><get name="QUEUE1LEVEL10"/></set>
<set name="QUEUE1LEVEL10"><get name="QUEUE1LEVEL11"/></set>
<set name="QUEUE1LEVEL11"><get name="QUEUE1LEVEL12"/></set>
<set name="QUEUE1LEVEL12"><get name="QUEUE1LEVEL13"/></set>
<set name="QUEUE1LEVEL13"><get name="QUEUE1LEVEL14"/></set>
<set name="QUEUE1LEVEL14"><get name="QUEUE1LEVEL15"/></set>
<set name="QUEUE1LEVEL15"><get name="QUEUE1LEVEL16"/></set>
<set name="QUEUE1LEVEL16"><get name="QUEUE1LEVEL17"/></set>
<set name="QUEUE1LEVEL17"><get name="QUEUE1LEVEL18"/></set>
<set name="QUEUE1LEVEL18"><get name="QUEUE1LEVEL19"/></set>
<set name="QUEUE1LEVEL19"><get name="QUEUE1LEVEL20"/></set>
<set name="QUEUE1LEVEL20"><get name="QUEUE1LEVEL21"/></set>
<set name="QUEUE1LEVEL21"><get name="QUEUE1LEVEL22"/></set>
<set name="QUEUE1LEVEL22"><get name="QUEUE1LEVEL23"/></set>
<set name="QUEUE1LEVEL23"><get name="QUEUE1LEVEL24"/></set>
<set name="QUEUE1LEVEL24"><get name="QUEUE1LEVEL25"/></set>
<set name="QUEUE1LEVEL25"><get name="QUEUE1LEVEL26"/></set>
<set name="QUEUE1LEVEL26"><get name="QUEUE1LEVEL27"/></set>
<set name="QUEUE1LEVEL27"><get name="QUEUE1LEVEL28"/></set>
<set name="QUEUE1LEVEL28"><get name="QUEUE1LEVEL29"/></set>
<set name="QUEUE1LEVEL29"><get name="QUEUE1LEVEL30"/></set>
<set name="QUEUE1LEVEL30"><star/></set>
</think>
</template>
</category>
<category>
<pattern>XDEQUEUE QUEUE1</pattern>
<template><think>
<set name="QUEUE1ANSWER">EMPTY</set>
<condition name="QUEUE1LEVEL1">
<li value="EMPTY"></li>
<li><condition name="QUEUE1ANSWER">
<li value="EMPTY">
<set name="QUEUE1ANSWER"><get name="QUEUE1LEVEL1"/></set>
<set name="QUEUE1LEVEL1">EMPTY</set>
</li>
</condition>
</li>
</condition>
<condition name="QUEUE1LEVEL2">
<li value="EMPTY"></li>
<li><condition name="QUEUE1ANSWER">
<li value="EMPTY">
<set name="QUEUE1ANSWER"><get name="QUEUE1LEVEL2"/></set>
<set name="QUEUE1LEVEL2">EMPTY</set>
</li>
</condition>
</li>
</condition>
<condition name="QUEUE1LEVEL3">
<li value="EMPTY"></li>
<li><condition name="QUEUE1ANSWER">
<li value="EMPTY">
<set name="QUEUE1ANSWER"><get name="QUEUE1LEVEL3"/></set>
<set name="QUEUE1LEVEL3">EMPTY</set>
</li>
</condition>
</li>
</condition>
...repeat conditions 30 times...
</think><get name="QUEUE1ANSWER"/></template>
</category>
<category>
<pattern>XCLEARQUEUE QUEUE1</pattern>
<template>
<think>
<set name="QUEUE1LEVEL30">EMPTY</set>
<set name="QUEUE1LEVEL29">EMPTY</set>
<set name="QUEUE1LEVEL28">EMPTY</set>
<set name="QUEUE1LEVEL27">EMPTY</set>
<set name="QUEUE1LEVEL26">EMPTY</set>
<set name="QUEUE1LEVEL25">EMPTY</set>
<set name="QUEUE1LEVEL24">EMPTY</set>
<set name="QUEUE1LEVEL23">EMPTY</set>
<set name="QUEUE1LEVEL22">EMPTY</set>
<set name="QUEUE1LEVEL21">EMPTY</set>
<set name="QUEUE1LEVEL20">EMPTY</set>
<set name="QUEUE1LEVEL19">EMPTY</set>
<set name="QUEUE1LEVEL18">EMPTY</set>
<set name="QUEUE1LEVEL17">EMPTY</set>
<set name="QUEUE1LEVEL16">EMPTY</set>
<set name="QUEUE1LEVEL15">EMPTY</set>
<set name="QUEUE1LEVEL14">EMPTY</set>
<set name="QUEUE1LEVEL13">EMPTY</set>
<set name="QUEUE1LEVEL12">EMPTY</set>
<set name="QUEUE1LEVEL11">EMPTY</set>
<set name="QUEUE1LEVEL10">EMPTY</set>
<set name="QUEUE1LEVEL9">EMPTY</set>
<set name="QUEUE1LEVEL8">EMPTY</set>
<set name="QUEUE1LEVEL7">EMPTY</set>
<set name="QUEUE1LEVEL6">EMPTY</set>
<set name="QUEUE1LEVEL5">EMPTY</set>
<set name="QUEUE1LEVEL4">EMPTY</set>
<set name="QUEUE1LEVEL3">EMPTY</set>
<set name="QUEUE1LEVEL2">EMPTY</set>
<set name="QUEUE1LEVEL1">EMPTY</set>
</think>
</template>
</category>