rich kopelow
V.I.P
Posts: 47
Joined: Thu Aug 25, 2016 7:45 am

User Settings vs. Variables

Fri Aug 26, 2016 10:30 am

I appear to be missing the difference in meaning/usage between user settings and variables. Can someone please explain this or point me at the document hat explains it?

Thanks,
Rich.

User avatar
Fantom
Help & Support
Posts: 304
Joined: Fri Oct 25, 2013 9:20 pm

Re: User Settings vs. Variables

Fri Aug 26, 2016 5:53 pm

Every user created retrieves its initial settings from the UserSettings like the default name to be assumed for all users or their age, gender and so on.

SIML UserSettings

rich kopelow
V.I.P
Posts: 47
Joined: Thu Aug 25, 2016 7:45 am

Re: User Settings vs. Variables

Sat Aug 27, 2016 7:17 am

Thanks for the reply, but I'm still confused. I'm writing a game program and knew that I needed to store state, so after each call to chat I copy out the settings and save them. The next time I interact with that user I load the settings back before the next chat call.

If I use the following sample code:

Code: Select all

    <Model>
        <Pattern>I'm male</Pattern>
        <Response>
                <Think><User Set="gender">Male</User></Think>ok
        </Response>
    </Model>
    <Model>
        <Pattern>I'm female</Pattern>
        <Response>
                <Think><User Set="gender">Female</User></Think>ok
        </Response>
    </Model>
    <Model>
        <Pattern>What's my gender</Pattern>
        <Response>
        	You are <User Get="gender" />
        </Response>
    </Model>
It works as expected, meaning that I can set the User setting "gender" and the modified version is returned as expected. I have an initial user setting of Unknown. So it appears that my settings change and don't simply return the initial value.

When debugging I noticed that in addition to the "settings" property, BotUser also has a "vars" property. I'm trying to understand the difference between these and how the vars are used.

Thanks,
Rich.

User avatar
Leslie
Lead Software Architect
Posts: 353
Joined: Fri Sep 14, 2012 12:20 pm
Contact: Website

Re: User Settings vs. Variables

Sat Aug 27, 2016 5:32 pm

To save user settings I believe you are using the GetDocument() method present in the UserSettings class. If not, I will encourage you to follow this procedure as it is fast and takes care of Volatile variables (the values of which are not supposed to be serialized).

Vars is just another Settings instance, the value of which gets reset after every chat result is generated. I personally use Vars from my application side to set temporary variables before making a chat request.

In the code below What is my gender gives You are

SIML Code

<Model>
  <Pattern>I AM MALE</Pattern>
  <Response>
	<Var Think:Set="gender">Male</Var>ok
  </Response>
</Model>

<Model>
  <Pattern>WHAT IS MY GENDER</Pattern>
  <Response>You are <Var Get="gender" /></Response>
</Model>
Moreover, I believe the code above can be made less verbose by using the Think namespace. Also I recommend filtering out I'm to I AM and What's to What is

SIML Code

<Siml xmlns:Think="http://syn.co.in/2014/siml#think">
  <Concept Name="Concept-Name">
    <Model>
      <Pattern>I AM MALE</Pattern>
      <Response>
        <User Think:Set="gender">Male</User>ok
      </Response>
    </Model>
    
    <Model>
      <Pattern>I AM FEMALE</Pattern>
      <Response>
        <User Think:Set="gender">Female</User>ok
      </Response>
    </Model>
    
    <Model>
      <Pattern>WHAT IS MY GENDER</Pattern>
      <Response>You are <User Get="gender" /></Response>
    </Model>
  </Concept>
</Siml>

rich kopelow
V.I.P
Posts: 47
Joined: Thu Aug 25, 2016 7:45 am

Re: User Settings vs. Variables

Sat Aug 27, 2016 9:21 pm

So Settings are meant for persistent data and Vars are meant for scratch pad settings and don't persist on their own. I am using GetDocument() to persist the Settings.

I'm in the process of writing a game in which the interactions are via text messages and are intended to often be far apart in time. Since I am using a single SimlBot to host a single game that may be talking with many unrelated players, I am "manually" persisting and restoring the User Settings each interaction. I didn't know if I should also be persisting the Vars collection, but it appears that in my case (manual persistence) there is no real difference, so I can write my siml using primarily Settings, but I might use Vars to indicate real world state (i.e. it's currently night) that would vary independently from the conversation.

I was unaware about using
. Thanks, but where should I be reading about things like that? Or where did I miss it?

Thanks for your filter suggestions as well. This was just to demo illustrating that settings returned current values instead of "initial" values and not a real part of my project. But points taken.

User avatar
Fantom
Help & Support
Posts: 304
Joined: Fri Oct 25, 2013 9:20 pm

Re: User Settings vs. Variables

Sat Aug 27, 2016 10:52 pm

The Think namespace is part of the SIML Specification. You can find all tutorials on Syn.Bot and the SIML Specification here.

rich kopelow
V.I.P
Posts: 47
Joined: Thu Aug 25, 2016 7:45 am

Re: User Settings vs. Variables

Sun Aug 28, 2016 12:03 am

noob failure. Thanks.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest