AI Zone Admin Forum Add your forum

NEWS: survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Pandorabots - test to check if one value higher than another

Would there be a way using aiml to determine whether one predicate storing a numerical value is more or less than another predicate storing a numerical value?  Thanks.


  [ # 1 ]

Not without coding it yourself. Is there a range to these numbers or could they conceivably store any value?


  [ # 2 ]

Hi Steve - unfortunately the range could be extrewmely large otherwise I could do a long list of conditions and jumping out when it matched - had hoped there might have been a crafty trick smile


  [ # 3 ]

Hi Steve

I have found a way without any coding or javascript and only using aiml tags available in aiml v1 on the free Pandorabots server to compare two numbers and determine if one is higher, lower or equal to the other and the difference between them and to use the result in further calculations.

I haven’t used long lines of condition statements and this will work on any whole numbers as large as you like but it doesn’t work on decimals since aiml strips out the decimal points and replaces with a space.

I needed to solve this issue for my roulette game to work.

You can see this in action at  Say ‘play roulette’ to start the game.

See if you can figure out how I did it?  smile


  [ # 4 ]

The solution was based on a trick and an understanding of advanced maths.  The trick was to <sraix> the maths but the problem to be solved was that the answer back was unsigned, i.e. you couldn’t tell if the answer was positive or negative because Pandorabots loses the - minus sign.

The solution to this was to do the maths a second time but to ask for the square root.  If the original maths produced a positive result then the answer back was a positive number but if it was negative then the square root of a negative number cannot be calculated unless you use imaginary numbers which is beyond the ability of <sraix> and you get one of a number of text messages back. 

This way you can determine if the answer was positive or negative and handle it appropriately. In my roulette game this translates as to whether the player won or lost on a bet.


  [ # 5 ]

Interesting solution to a difficult problem. smile Only zero (0) would be a “problem” (being the equivalent of “equal to”), but you can test for that with AIML. Well done. cheese


  login or register to react