AI Zone Admin Forum Add your forum

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

Progressive rule output
 
 

Hi,

I want to build a rule that can get executed multiple times, has different output each time until it outputs nothing.

So basically what I want is random output without the random :D

example:

u: (test) ^keep() 
[ This should be the first ]
[This is the second output] 
[ this is the third output] 

By executing this rule the statement get of course printed in a random order.
I want to achieve them being in order without writing ugly and unclear code.

My current solution is using a trigger variable for that, but I would like to have a clearer way just like the random notation or something nearer:

if($trigger == null)
{
 This should be the first
 $trigger 
1
}
else if($trigger == 1
{
 This is the second output
 $trigger 
2
}
else if($trigger == 2
{
 this is the third output
 $trigger 
3

Apart from that is does everything I need:
- Output the three statements in order
- easily extensible (usable for n statements)
- Outputs nothing after all statements are used.

 

 
  [ # 1 ]

Couple of programatic options come to mind:

u: (test) ^keep()
$trigger += 1
^refine()
  
a: ($trigger==1)
    
This should be the first
  a
: ($trigger==2)
    
This is the second output
  a
: ($trigger==3)
    
This is the third output 

or

u: (test) ^keep()
  
$trigger += 1
  $_label 
= ^join(TRIGGER $trigger)
  ^
reuse($_label)

sTRIGGER1 (?)
  
This should be the first
s
TRIGGER2 (?)
  
This is the second output
s
TRIGGER3 (?)
  
This is the third output 

You can dress the first option up to have a final a: () rule to decide what to do when you reach the end.
Similarly on the second option you can use ^getrule() to determine if a rule with the label actually exists or not.

But you can also let Chatscript keep track of what rules it has used up. Perhaps the easiest way is to isolate the output rules (no pattern required) into their own topic without the keep or system control flag, and then from your (test) rule either ^gambit() or ^respond() the topic depending on the rule type you used. CS will output the first rule that hasn’t previously been used for this user. This makes it easy to extend and there is no counter variable to keep track of.

 

 

 
  [ # 2 ]

Hi,

There is another way to achieve what you want.
I’m sure you already finished but I wanted to share to get feedback too.

s: ( ~emothanks )
   
My pleasure
s
: ( ~emothanks )
   
You’re welcome 

Here, the first rule executes and erase. Then, the second ... And you can do it without code as long as you want.

 

 

 
  login or register to react