Patch: RS 1.17.3 - Topic Inheritence|Kirsle|casey@cuvou.net|1222037163|Kirsle|xx|0|69.227.167.128 69.232.42.17|[b]NOTE:[/b] This patch is old already. Scroll down further. The current version of this patch is 1.17.3.<br />[hr]<br />This is a patch to upgrade RiveScript 1.17 to 1.17.1 (1.18 alpha).<br /><br />It adds &quot;topic inheritence&quot;. See post http://www.rivescript.com/yabb2/YaBB.pl?num=1221621108<br /><br />The patch file is attached. To patch RiveScript.pm on a Unix-like system, copy the patch file into the same directory as RiveScript.pm (version 1.17) and run the command:<br /><br />[code]patch &lt; RiveScript-1.17.1.patch[/code]<br /><br />Here is some example RS code that demonstrates the topic inheritence capability:<br /><br />[code]+ test game<br />- &#123;topic=room1&#125;You're now in the game. &#123;@look&#125;<br /><br />&gt; topic global<br />  + &#123;weight=100&#125;help<br />  - Game help (todo)<br /><br />  + &#123;weight=100&#125;inventory<br />  - You have no items in your inventory.<br /><br />  + &#123;weight=5&#125;(north&#124;south&#124;east&#124;west)<br />  - You can't go in that direction.<br /><br />  + _ *<br />  - You don't need to use the word &quot;&lt;star1&gt;&quot; in this game.<br /><br />  + *<br />  - I don't understand what you're trying to do.<br />&lt; topic<br /><br />&gt; topic earth inherits global<br />  + put on astronaut suit<br />  - You don't need to put on the astronaut suit on planet Earth.<br />&lt; topic<br /><br />&gt; topic room1 inherits earth<br />  + look<br />  - You're in a room with a big number 1 on the floor. &#123;@exits&#125;<br /><br />  + exits<br />  - You can exit via the north and west doors.<br /><br />  + &#123;weight=10&#125;north<br />  - &#123;topic=room2&#125;&#123;@look&#125;<br /><br />  + &#123;weight=10&#125;west<br />  - &#123;topic=room3&#125;&#123;@look&#125;<br />&lt; topic<br /><br />&gt; topic room2 inherits earth<br />  + look<br />  - This room has a big number 2 on the floor. &#123;@exits&#125;<br /><br />  + exits<br />  - The only exit is to the south.<br /><br />  + &#123;weight=10&#125;south<br />  - &#123;topic=room1&#125;&#123;@look&#125;<br />&lt; topic<br /><br />&gt; topic room3 inherits earth<br />  + look<br />  - This room has a big number 3 on the floor. &#123;@exits&#125;<br /><br />  + exits<br />  - The only exit is to the east.<br /><br />  + &#123;weight=10&#125;east<br />  - &#123;topic=room1&#125;&#123;@look&#125;<br />&lt; topic[/code]<br /><br />This code will provoke &quot;deep recursion&quot; prevention code:<br /><br />[code]&gt; topic recurse1 inherits recurse2<br />  + test<br />  - Tested.<br />&lt; topic<br />&gt; topic recurse2 inherits recurse1<br />  + test2<br />  - Tested2.<br />&lt; topic[/code]<br /><br />Demonstration from rsdemo:<br /><br />[code][kirsle@epsilon RiveScript-1.17]$ ./bin/rsdemo ./lib/RiveScript/demo<br />Welcome to the Perl RiveScript Interpreter. This script is a demonstration<br />of RiveScript. The bot's replies are taken from the files in the<br />'RiveScript/demo' directory, which by default are based on some of Eliza's<br />triggers and responses. To load a different set of replies, provide<br />a path to a directory on the command line, e.g. rsdemo /opt/rs/brain<br /><br />Loading RiveScript brain from directory:<br />./lib/RiveScript/demo<br /><br />RiveScript::Warning: Deep recursion while scanning topic inheritance (topic recurse1 was involved)<br />RiveScript::Warning: Deep recursion while scanning topic inheritance (topic recurse2 was involved)<br />You're now chatting with the RiveScript bot. Why not say hello? When<br />you get tired of this, type &quot;quit&quot; to exit this demonstration.<br /><br />You&gt; test game<br />Bot&gt; You're now in the game. You're in a room with a big number 1 on the floor. You can exit via the north and west doors.<br />You&gt; help<br />Bot&gt; Game help (todo)<br />You&gt; inventory<br />Bot&gt; You have no items in your inventory.<br />You&gt; south<br />Bot&gt; You can't go in that direction.<br />You&gt; north<br />Bot&gt; This room has a big number 2 on the floor. The only exit is to the south.<br />You&gt; north<br />Bot&gt; You can't go in that direction.<br />You&gt; south<br />Bot&gt; You're in a room with a big number 1 on the floor. You can exit via the north and west doors.[/code]||1224219978|Kirsle|RiveScript-1_17_1.patch
Re: Patch: RS 1.17.1 - Topic Inheritence|Kirsle|casey@cuvou.net|1222039077|Kirsle|xx|0|69.227.167.128|Here's another patch. Patch this against an original copy of RiveScript 1.17 (i.e. not one that you patched using the last patch).<br /><br />This one allows one topic to inherit triggers from multiple topics.<br /><br />Example:<br />[code]&gt; topic global<br /> &nbsp; + &#123;weight=100&#125;help<br /> &nbsp; - Game help (todo)<br /><br /> &nbsp; + &#123;weight=100&#125;inventory<br /> &nbsp; - You have no items in your inventory.<br /><br /> &nbsp; + &#123;weight=5&#125;(north&#124;south&#124;east&#124;west)<br /> &nbsp; - You can't go in that direction.<br /><br /> &nbsp; + _ *<br /> &nbsp; - You don't need to use the word &quot;&lt;star1&gt;&quot; in this game.<br /><br /> &nbsp; + *<br /> &nbsp; - I don't understand what you're trying to do.<br />&lt; topic<br /><br />// A topic for easter eggs or something.<br />&gt; topic easter<br /> &nbsp; + &#123;weight=100&#125;(@fbomb) you<br /> &nbsp; - &lt;sentence&gt; you, too.<br />&lt; topic<br /><br />&gt; topic earth inherits global easter<br /> &nbsp; + put on astronaut suit<br /> &nbsp; - You don't need to put on the astronaut suit on planet Earth.<br />&lt; topic[/code]<br /><br />To inherit from multiple topics, separate the topic names by spaces (to be consistent with RiveScript arrays and &#123;random&#125; tag, but since topic names aren't allowed to have spaces, there is no &#124;pipe&#124; equivalent needed).||||RiveScript-1_17_2.patch
Re: Patch: RS 1.17.1 - Topic Inheritence|a2b|roy@wasystems.net|1222039609|a2b|xx|0|76.102.148.130|You are killin it! Fantastic job. &nbsp;I don't know if I will be able to try this patch today but I will try later tonight. ||||
Re: Patch: RS 1.17.1 - Topic Inheritence|a2b|roy@wasystems.net|1223705423|a2b|xx|0|76.102.148.130|Inherited topics are not honoring previous statement (%) checks.||||
Re: Patch: RS 1.17.1 - Topic Inheritence|Kirsle|casey@cuvou.net|1224215358|Kirsle|xx|0|69.232.42.17|Here's patch 1.17.3 which should fix the %previous issue (it was relatively simple, just had to add a method to return a list of topics that inherit eachother and then check each of those topics for %previous's, whereas before it only checked for them under the current topic).<br /><br />Here's my example code:<br />[code]&gt; topic global<br /> &nbsp; &nbsp; &nbsp;+ test global one<br /> &nbsp; &nbsp; &nbsp;- Testing global one...<br /><br /> &nbsp; &nbsp; &nbsp;+ test global two<br /> &nbsp; &nbsp; &nbsp;% testing global one<br /> &nbsp; &nbsp; &nbsp;- This %previous has worked.<br /><br /> &nbsp; &nbsp; &nbsp;+ test global two<br /> &nbsp; &nbsp; &nbsp;- This is the regular &quot;global two&quot;<br />&lt; topic<br /><br />&gt; topic test1 inherits global<br /> &nbsp; &nbsp; &nbsp;+ *<br /> &nbsp; &nbsp; &nbsp;% this is a test2 question<br /> &nbsp; &nbsp; &nbsp;- The question from test2 linked to a %previous from test1.<br /><br /> &nbsp; &nbsp; &nbsp;+ test test1<br /> &nbsp; &nbsp; &nbsp;- This is a regular trigger in test1.<br />&lt; topic<br /><br />&gt; topic test2 inherits test1 global<br /> &nbsp; &nbsp; &nbsp;+ test test2<br /> &nbsp; &nbsp; &nbsp;- This is a test2 question<br /><br /> &nbsp; &nbsp; &nbsp;+ quit<br /> &nbsp; &nbsp; &nbsp;- &#123;topic=random&#125;Left.<br /><br /> &nbsp; &nbsp; &nbsp;+ *<br /> &nbsp; &nbsp; &nbsp;- [you're in test2; &quot;quit&quot; to quit]<br />&lt; topic<br /><br />+ test inheritence<br />- &#123;topic=test2&#125;You're now in topic test2.[/code]<br /><br />And the output<br /><br />[code]You&gt; test inheritence<br />Bot&gt; You're now in topic test2.<br />You&gt; test global two<br />Bot&gt; This is the regular &quot;global two&quot;<br />You&gt; test global one<br />Bot&gt; Testing global one...<br />You&gt; test global two<br />Bot&gt; This %previous has worked.<br />You&gt; test test1<br />Bot&gt; This is a regular trigger in test1.<br />You&gt; test test2<br />Bot&gt; This is a test2 question<br />You&gt; okay<br />Bot&gt; The question from test2 linked to a %previous from test1.<br />You&gt; okay<br />Bot&gt; [you're in test2; &quot;quit&quot; to quit][/code]<br /><br />Again, patch this against a clean version of RiveScript 1.17. If ya can't find any more ways to break this, I'll release what I have now as RiveScript 1.18 to CPAN. :)||||RiveScript-1_17_3.patch
