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..

Conditional gambits
 
 
tLIKE () if (!$like{
     Did you enjoy this movie
?
      
a: (yesSo do I $like yes 
      a
: (no)  "Why not ?" $like no 
     }
     
else { So what else would you wanna discuss about the movie

This code asks the first question but outputs no other text. When I enter yes or no, it replies with I don’t know what to say even though I thought a quibble might show up. Why does “So do i” or “why not” fail to output? And shouldnt the else part be output the second time I login?

 

 
  [ # 1 ]

Once the gambit is used the first time, it erases itself (no ^keep() ) so there is no second time.
As for syntax,  a: goes AFTER the entire rule. As you have it embedded in the { } of the if, it is merely text to display, having nothing to do with being a rejoinder.

 

 
  [ # 2 ]

Not sure I understood that bruce. Are you saying that within {} I can put no text except script commands? So the only way to display text in there would be to use e.g. a reuse command that went to a nomally failing gambit or responder? Are there any documentation files you could recommend for one hoping to learn scripting?

The docs on control scripts is only 3 pages long.

Sorry if I seem to be getting ahead of myself so quickly but I was already beyond basics in Chatscript a while back, Then, I stopped doing it for a while and got distracted by something else. I have medical problem where I lose my memory re something if I am not constantly involved in it. The main problem came when I lost all data on my pet CS project after my hard disk died on me. So I do remember most of the basics. Its the advanced I want to get into. You may remember me as a user who was asking questions about Postgres and noSql as a way to replace facts. In fact you can see my posts if you go 2-3 pages back on the forum.

I dont think any of my rules are being erased as I am using keep repeat on the topic. If I direct a reuse to a rule that has the pattern ($undef) does it check that pattern or bypass it?

 

 
  [ # 3 ]

This is a second post after modding my previous one

uCHECKLIKE ($undef) if (!$like^reuse(LIKE1}
                
else ^reuse(LIKE2}

u
LIKE1 ($undefDid you enjoy this movie?
      
a: (y)  So do 
        $like
=yes
      a
: (n)   car manufacture
         $like
=no
         
u
LIKE2 ($undefSo what do you wanna chat about

Once again interjection may be the issue as changing my pattern from yes to y works for the enjoyment check. It even goes to LIKE2 if needed. However, typing n alwys gets me the “i dont know” text.

 

 
  [ # 4 ]

Ah i just discovered n is an interjection but y isnt. I am going to disable interjections. Hope it wont cause too much trouble until I can build a macro to handle them.

 

 
  [ # 5 ]

answering various:

1. Rejoinders like a: are attached to the end of a rule and constitute a new rule. This is normal:
t: what is your sex
  a: (male) ok
  a: (female) I see.

What you wrote was stuff inside an if statement. A rule is not going to be over until the if is complete. So
t:  I like if ( $undef) { a: (male) ok a: (female) I see }
is not over until that closing }  hence the stuff inside the { } is either functions or text. In this case it is text and would get printed out.

2. keep on a topic does not impact gambits. Gambits can only be kept if you put ^keep on the gambit itself, and keeping gambits almost NEVER makes sense.

3. ^reuse bypasses the pattern check.

4.  n is NOT an interjection.  To see what happens, type:
  :prepare n
  :prepare y

and see what the system says is the result.

 

 
  [ # 6 ]

I think n is an interjection concept because prepare n give “actual used input” as ~no while prepare y gives y
However, I looked in interjections.txt and there is no <n as shown in :down ~no

Sorry I cant post the exact details but I dont know how to paste from the dos window since I cant select and Ctrl-C just aborts.

I tried pasting your code in my bot and I still get the matching brace error. Also shouldn’t it be !$undef instead of $undef since I meant an undefined variable by $undef.

 

 
  [ # 7 ]

you are correct. n is mapped to ~no by the texting file. 

I was just illustrating format of code when i used $undef, not actually making meaningful code.

 

 
  [ # 8 ]

But I still cant use that kind of code in the top file. I tried the example you showed and it always returns the “Failed to close code started with }” error. Unless you meant it as an example that didnt work in which case its just me being confused. It works if I only enter text in the braces and dont have any rejoinder rules but I am wonder of such control is possible with chatscript.

I know I can get it to work by using reuse in the brackets and sending it to normally failing rules and I suppose thats a workable option since you would only need a seperate reuse for each block of if braces.

Another issue is passing control to my top file. Currently the control script starts in ~intorductions and I can get to my ~gladiator file by way of reuse or using a topic keyword. Is there any other way to start in ~gladiator once I’m done with intros?

 

 
  [ # 9 ]

On the other hand, I would myself use ~no and ~yes in the rejoinders instead of n and y.

 

 
  [ # 10 ]

If you do :prepare or :trace, the output goes into the users log file, and you can cut and paste from that, or email it to me.

 

 
  [ # 11 ]

by the way in your earlier post:

$like=yes

is incorrect and should be $like = yes

the conflated form is used in pattern as a test.  Here you are doing an assignment.

 

 
  login or register to react