RiveScript Math Expressions|Casey|casey@cuvou.net|1216234967|Kirsle|xx|0|72.37.252.50|I'm currently working on programming a RiveScript bot to help iron out the rough edges of the Perl RiveScript module. So far I've fixed a couple of bugs in the module itself (some of them bigger than others).<br /><br />The bugs in version 1.15 that are going to be fixed in version 1.16:<br /><br />[code] 1.16 xxx<br /> - New options to the constructor: 'verbose' and 'debugfile'. See the new()<br />  constructor for details.<br /> - Bugfix: when there were multiple +trigger's that had a common %previous,<br />  there was no internal sort buffer for those +trigger's. As a result, matching<br />  wasn't very efficient. Added the method sortThatTriggers() to fix this.<br /> - Bugfix: tags weren't being processed in @Redirects when they really<br />  should've!<br /> - Bugfix: The ^Continue lookahead code wouldn't work if the next line began<br />  with a tab. Fixed![/code]<br /><br />Now, here's a new idea for a new RiveScript tag: math expressions. Here's an example case:<br /><br />[code]+ i am * years old<br />* &lt;get age&gt; != undefined =&gt; &#123;@int new age *&#125;<br />- &lt;set age=&lt;star&gt;&gt;I will remember that you are &lt;get age&gt; years old.<br /><br />+ int new age *<br />* &lt;star&gt; == &lt;get age&gt;      =&gt; I already know you are &lt;get age&gt; years old.<br />* &lt;star&gt; == &lt;expr &lt;get age&gt; + 1&gt; =&gt; Oh, you had a birthday!&lt;add age=1&gt;<br />* &lt;star&gt; &gt; &lt;get age&gt;      =&gt; You're more than a year older now?&lt;set age=&lt;star&gt;&gt;<br />* &lt;star&gt; &lt; &lt;get age&gt;      =&gt; You're younger now? o.O&lt;set age=&lt;star&gt;&gt;[/code]<br /><br />[code]User&gt; I am 20 years old.<br />Bot&gt; I will remember that you are 20 years old.<br /><br />User&gt; I am 20 years old.<br />Bot&gt; I already know you are 20 years old.<br /><br />User&gt; I am 21 years old.<br />Bot&gt; Oh, you had a birthday![/code]<br /><br />So basically, &lt;expr $math&gt; would (safely) evaluate the mathematical operators within and then return the result. This would complement the currently existing &lt;add&gt;, &lt;sub&gt;, &lt;mult&gt;, &lt;div&gt; tags, which currently only work on modifying user variables.<br /><br />&lt;age=&lt;expr &lt;get age + 1&gt;&gt;&gt; would be equiv to &lt;add age=1&gt;.<br /><br />The syntax might be &lt;expr&gt;$math&lt;/expr&gt; instead... I'll have to decide on that later.<br /><br />If anyone has any suggestions on this, reply here before I get around to implementing it. Otherwise I'll dictate a solution and you'll all be stuck with it. :P||||
Re: RiveScript Math Expressions|sevenzenith1|sevenzenith@gmail.com|1336480449|sevenzenith|xx|0|1.20.0.142|umm that great||||
