Question

I am working with AIMLbot.dll in c#. I saw two functions saveToBinaryFile and loadFromBinaryFile. I think these functions are to store current contents in bot's brain to a file. But it doesn't seems to be working! Means, If I say to remember my name and save the content to GraphMaster.dat file. Next time I load the content of the same file and when I ask my name its giving the wrong answer. My class is as follows.

class AIBot
    {
        private Bot myBot;
        private User myUser;

        public AIBot()
        {
            myBot = new Bot();
            myUser = new User("UnknownUser", myBot);
        }

        public void Initialize()
        {
            myBot.loadSettings();
            myBot.isAcceptingUserInput = false;
            myBot.loadAIMLFromFiles();
            myBot.isAcceptingUserInput = true;
        }

        public void Load()
        {
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Graphmaster.dat"))
                myBot.loadFromBinaryFile(AppDomain.CurrentDomain.BaseDirectory + @"\Graphmaster.dat");
        }

        public string GetResponse(string input)
        {
            Request r = new Request(input, myUser, myBot);
            Result res = myBot.Chat(r);
            return (res.Output);
        }

        public void Save()
        {
            myBot.saveToBinaryFile(AppDomain.CurrentDomain.BaseDirectory + @"\Graphmaster.dat");
        }
    }

Can anybody help to point out the problem?

Was it helpful?

Solution

I got a solution for the problem. Hope it will help others.

  1. Save user session like

    this.myUser.Predicates.DictionaryAsXML.Save(saveFileDialogDump.FileName);
    
  2. Load the stored session next time.

    this.myUser.Predicates.loadSettings(openFileDialogDump.FileName);
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top