How To Create A Mind File in Billy 4.1

Greg Leedberg, 8-22-2003

  1. Introduction
    1. Important Notes For Those Familair With Billy 3.x Mind Files
  2. Creating A Mind File - An Overview
  3. Global Variables
  4. Memory Banks You Can Create On Your Own
    1. BOTINFO.BFB
    2. IDQ.BFB
    3. PROFILES.BFB
    4. NOUNS.BFB
    5. NAMES.BFB
    6. STUFFING.BFB
    7. EMOTICON.BFB
    8. BAD.BFB
    9. CONTEXT.BFB & CONTEXT2.BFB
  5. How To Create The Rest
      GROUPS.BFB, TEMPS.BFB, & SR.BFB
    1. HAWKING.BFB
    2. VERSION.BFB
  6. Quick Recap: The Files You Need To Create

1. Introduction

Billy's "mind" is used to store many types of information that Billy has learned. Different types of information are stored in different "memory banks", which as a whole make up Billy's mind. Some of these memory banks are defined completely by the construct developer, and some are just given a start by you and are added to later by Billy as he learns. You should be aware as you are creating a mind what banks are of what type. All memory bank names end with ".BFB" because at run time, the .MND file is nothing more than an archive of files, which are de-archived when a file is loaded, and then re-archived when the file is closed. Each of these files are the individual memory banks, and each one ends with the ".BFB" extension (which is a tribute to the Billy program's name back in version 1.0 - Best Friend Billy). Some memory banks are more complex than others to design, but each is described in as much detail is needed below. Despite the fact that this document seems to reveal all of the "secrets" of Billy, there is still much, much more to him as far as the processing that occurs inside him and how he chooses how he should best respond to an input. Even if you have created a mind and completely understand all that is in this manual, predicting what Billy will say should still prove to be tough (if not impossible) under some coniditions.

Important Notes For Those Familair With Billy 3.x Mind Files

If you created mind files for Billy 3, you should be especially aware of the differences between those mind files and the ones created for Billy 4. The changes are listed here:

2. Creating A Mind File - An Overview

Creating a mind file can be either really easy, or really... not easy. If you're reading this document, then you're probably already bored with "easy". When you click on File | New Mind, you are given to modes to choose from, Simple and Advanced. Simple Mode is described in the main manual, and this one describes just "Advanced" mode.

Advanced mode revolves around the idea of you creating the individual memory banks on your own. Sections 4 & 5 describe the format and language of each memory bank in detail, so you should read them fully before you start making your mind file. Through the editing of memory banks, you have virtually complete control over the personality of the mind file. When you create the memory banks, they must all have the correct file name as indicated in this manual, and they must all reside in the same folder on your hard drive. That folder should contain ONLY the files needed for this mind file.

After you select "Advanced" mode, you will be prompted for the folder which contains all of the relevant files. After you select it and click "OK", the mind file will be created in that folder with the name "new.mnd".

3. Global Variables

Rather than continually listing these, I'll just list here what the global variables are. These are variables that can be used in many instances in Billy's mind to plug in certain values that may change. If you can use these in a specific memory bank, that should be noted in the section dealing specifically with that bank. The global variables are:

The "&" and "@" refer to two different types of global variables, but you need not worry about the difference at this point.

4. Memory Banks You Can Create On Your Own

Each of these memory banks should exist as a file (with the correct name and extension) the folder in which you are creating your mind file.

4.1. BOTINFO.BFB

This file contains the attributes for the mind file you can edit by going to Customize | This Mind. The format of this file is:

[Bot Name]
[Relationship type]
[Relationship name]
[Gender]
[Age]
[Location]

without the brackets. So, an example BOTINFO.BFB file might be (as it is for the default mind):

Billy
Daisy
girlfriend
male
21
New Hampshire

4.2. IDQ.BFB

Billy 4 tries to positively identify each it talks to be querying them certain questions. It stores the answers to these questions, and uses an alogrithm to figure out what the best question to ask is in order to figure out who it is talking to. The extra questions are because Billy could, potentially, talk to two people with the same name. This file contains the questions themselves, as well as some text into which the answers can be inserted when Billy is echoing back answers as known facts about the person it is talking to. The format of this file is:

Q0=[Question #0]
Q1=[Question #1]
Q2=[Question #2]
Q3=[Question #3]
Q4=[Question #4]
CONFIRM=[Confirmation question]
LASTTIME=["Last time" text]
FACT1=[Fact text for question #1]
FACT2=[Fact text for question #2]
FACT3=[Fact text for question #3]
FACT4=[Fact text for question #4]

Now, some of these require explanation.

First, note that question numberings start with zero. It's easier to implement (for me, at least) that way. Question #0 is always the question asked first (after that, the order of questions is based on which question would narrow the field of people down the best). Question #0 should almost always be "What is your name?" or something along those lines.

The confirmation question is what is asked when Billy has narrowed the field of people down to one, and wants to make sure that this is not someone new. Usually this question should be "Have I talked to you beofre?" -- the key is that if the user answers "yes", then the user is ID'ed as that one person the field had been narrowed down to. If the answer is "no", then this is considered a new person.

The "Fact text" lines for each question is the text that would precede an answer if that answer was to be echoed back by Billy as a fact (he will do this occassionally). For instance, if question #2 was "Where are you from?", then the fact text for question 2 should be something like "You are from".

The reason there is no fact text for question 0 is that, usually, that question is "What is your name?" and it would sound silly to say "Your name is Greg." So, instead, Billy is also able to say when the last time was that he talked to the current person, and the text that would precede that is the "Last time" text. This text should be something like "I last talked to you".

These lines can be in any order that you want. The order here just made the most sense to me. But the reason that every line is structured like a variable assignment is so that you can order them to your liking.

An example of this file:

Q0=what is your name?
Q1=where do you live?
Q2=what's your favorite sport?
Q3=what's your favorite book?
Q4=what's your favorite movie?
CONFIRM=have i talked to you before?
LASTTIME=i last talked to you
FACT1=you live in
FACT2=your favorite sport is
FACT3=your favorite book is
FACT4=your favorite movie is

4.3. PROFILES.BFB

This file is associated with IDQ.BFB. As Billy learns about people, he will store that information in here. It should start with knowledge about no one, but you still need to create it. The first line in this file is the number of profiles it has learned. So, you should make this file look like this:

0

4.4. NOUNS.BFB

This file is merely a list of nouns that Billy knows. The format is simply:

[Noun 1]
[Noun 2]
[Noun 3]

And so on and so on. Really, just a list of any number of nouns, one on each line. This file will be added to as Billy learns new nouns from talked to people. Billy's default mind comes with a list of 471 nouns, so I won't list them all here, but a smaller example is just:

HOUSE
CAT
DOG
TREE
BOX

4.5. NAMES.BFB

Like the nouns memory bank, this one is a list of names Billy knows. Same format:

[Name 1]
[Name 2]
[Name 3]

Any number of names, one name per line. This file will be added to as Billy learns new names. Once again, Billy's default mind comes with knowledge of 276 names, so I won't list them all, but an example:

HOMER
BART
LISA
MARGE
MAGGIE

4.6. STUFFING.BFB

This file is just like the nouns and names, except it is a list of "stuffing". Stuffing is just words that come between a "noun marker" (such as "a" and "the") and the actual noun. For the most part, this is adjectives. Why I don't just call it the "adjectives file", who knows. Format is familiar:

[Stuffing word 1]
[Stuffing word 2]
[Stuffing word 3]

One stuffing word per line, any number of lines. This file will be added to as Billy learns new stuffing words in conversation. Billy's default mind comes with a list of 272 stuffing words, but a shorter example:

BLUE
RED
BIG
NICE

4.7. EMOTICON.BFB

Billy occassionally will add an emoticon ("smiley") to the end of his sentences. This file contains the emoticons he has available to him, in this format:

[Rate]
[Emoticon]
[Emoticon]
[Emoticon]

There can be any number of emoticons, but only one per line. The "rate" is an integer which represents the rate at which the emoticons will show up. A rate of 20 would mean that they would show up, on average, once every 20 sentences. An example of this file (taken from Billy's default mind):

20
:)
:)
:)
:(
;)
;)
:O
^_^
:^o
{:'O

4.8. BAD.BFB

This memory bank contains a list of sentences which Billy should try to not say. Normally, this file is filled in by Billy when you say "Don't say that" to him, but you might want to enter some sentences in here if you find that your mind file has a tendency to say some silly things. The format:

[Bad sentence]
[Bad sentence]
[Bad sentence]

This can contain any number of bad sentences, or none at all. The file must exist, however, even if it is an empty file. In fact, the default Billy BAD.BFB is an empty file -- and your probably should be, too. An example of a non-empty file would be:

How is you doing?
My phone have is a to are market with two blue.
This this is is a a sentence sentence that that doesn't doesn't make make sense sense.

4.9. CONTEXT.BFB & CONTEXT2.BFB

These two memory banks are certainly the most complex. They also help to define a particular mind's "personality" more than any other bank. These are the files that contain all the sequences of words that Billy should look for, and how he should respond to those sequences (indivdual sequences of words are called CONTEXTS in the world of Billy). Let's start simple. CONTEXT.BFB and CONTEXT2.BFB use the same "language" to control the context/response search. The difference between the two files is that CONTEXT.BFB handles STATEMENTS, while CONTEXT2.BFB handles QUESTIONS. Questions are identified by Billy (predictably) by whether or not the sentence ends with a question mark ("?"). Everything else is a STATEMENT. The reason the two types of sentences get their own banks is that quite often, the same sequence of words can have two very different responses depending on whether it is a question or a statement.

Each of these banks contains many, many, context/response sequences, so first I will explain how to build just one. Predicatably, a single sequence is divided into two sections, the CONTEXT section, and the RESPONSE section. These begin with the control statements "###CONTEXT###" and "###RESPONSE###", both of which get their own line, and must be uppercase. So, a simplified sequence would look like this:

###CONTEXT###
[the context to look for]
###RESPONSE###
[how to respond to it]

I will first explain the CONTEXT section. You have to understand how Billy looks for these contexts. He loops through the sentence, taking each word at a time and looking at each of these contexts relative to the "current" word in the loop. The current word is numbered word 0. Each word in a sentence will eventually be word 0, but only after each word before it has been. The word immediately following word 0 is word 1, the next one is word 2. You must use these numbers to have Billy look for contexts. Within the CONTEXT section, you must have, on a line by itself, a word to look for (in uppercase), and on the next line, the "number" of that word in the context. Almost all of the time, the first word of the context will be 0. Remember, this does not mean it is the first word of the sentence, just the current word that Billy is on in the loop. Also keep in mind that punctuation will have been stripped, and contractions will have been expanded. So, to look for the context "How tall are you?", the context section would look like:

###CONTEXT###
HOW
0
TALL
1
ARE
2
YOU
3

The use of the numbers makes it so that you can look for more than just uniterrupted sequences of words. As a technical note, you CAN use negative numbers to access words that came before the "0" word, just type "-1" in the file.

The next feature which makes this more complex is the use of variables in the context section. Rather than specific words, there are some "global variables" within Billy that you can use in the context section. Refer to section 3 for a list of the global variables. When you use global variables, Billy "plugs in" whatever the acutal value of the variable is, and looks for that in the sentence.

In addition to these variables, you can look for TYPES of words. When Billy analyzes a sentence, he puts an ID on each word that he can indentify. To look at these IDs in the context, use the following list:

Now, on to the response section. The response section tells Billy how to respond to the associated context, and can contain ANY number of possible responses -- Billy will randomly pick one. Each response gets its own line. There are two possible types of responses, FREE FORM and TEMPLATE, and each will be described.

Billy has a built-in ability to create his own sentences using knowledge stored in his language memory banks. This is the basis of FREE FORM responses. Rather than telling Billy exactly how to respond to the context, free form responses allow you to give Billy a few "keywords" that should be included in the final response, and he will generate the most intelligent sentence he can using those words. A free form response takes up one line, and is just a sequence of keywords, all in uppercase. So, to tell Billy to respond with a free form response using the keywords "I" and "tall", the response section would look like this:

###RESPONSE###
I TALL

A word of caution is that if you tell Billy to make a response with a keyword that does not exist in his language memory banks, then you may very well create an infinite loop when he goes to do what you've told him to do. As such, every time you specify a free form response, you should enter at least one sentence in his language memory that uses these keywords. Refer to this section for information on how to do that. But for instance, if you give the keywords "I TALL", you should be sure there is a sentence such as "I am tall" present in his language memory banks. This way, right from the start "I am very tall." will be a possible response to the context. Over time, Billy will learn more about the words "I" and "TALL", and will create his own responses.

It is with free form responses that the different types of global variables come into play. If you noticed, some global variables have a "&" as their first character, while some have a "@". The ones with an "&" can be used in free form responses -- those variables are recorded in the language bank as variables. The others are not stored as variables in the language bank (otherwise, for example, anytime the user used the number that just happens to be Billy's age in a sentence, it be recorded as the "age" variable, even if that was not the right context) and cannot be used in free form responses.

The other type of response is called a "template" response, and was created to enable you to include variables in a response which may not exist in Billy's language bank. Template responses are merely template sentences where certain variables are "plugged in", they are not intelligently generated by Billy. As such, you should only use them when you want to use variables.

Template sentences are identified by the first word being "@@T". After this is a space, and the template sentence. The primary variables you will probably be using in template responses are "context variables" -- these let you plug in words from the context, and they all being with "@". To plug in the "0" word, you would use "@0". To plug in the fourth word, you would use "@4", and so on.

There are some special flags you can use with context variables. The "P" flag switches some pronouns, which you may want to switch when echoed back by Billy. It switches "HE" to "HIM", and "SHE" to "HER". The way you specify this flag is "@Px", with x being the word number. The other flag is "R", which reverses some possessive pronouns you may want reversed. It switches "MY" to "YOUR" and "YOUR" to "MY". The way you specify this is "@Rx", with x being the word number. If you use any of these flags and the word that gets plugged in ends up not being applicable to the flag (like, if the word "cinnamon" is the word in that context position), the word remains unchanged. So, you should use these whenever someone might use one of the applicable words and that word would sound wrong in the response.

Additionally, you can use any global variables you wish in a template response, and it is only in template repsonses that you can use the "@" globals. So, a template response that should say "I am [age] years old and quite tall, [user name]!" would look like:

###RESPONSE###
@@T I am @age years old and quite tall, &username!

This complete context/response sequence would be coded as follows, then:

###CONTEXT###
HOW
0
TALL
1
ARE
2
YOU
3
###RESPONSE###
I TALL
@@T I am @age years old and quite tall, &username!

One additional point to be made is this: Multiple possible responses is the norm, but there may be cases where you want multiple contexts to result in the same group of possible responses. For example, in the example above, in addition to a sentence such as "How tall are you?", you may want to look for "How short are you?" (I know, it's awkward :) ). This is achieved with just an extra ###CONTEXT### section. So, the example now looks like this:

###CONTEXT###
HOW
0
TALL
1
ARE
2
YOU
3
###CONTEXT###
HOW
0
SHORT
1
ARE
2
YOU
3
###RESPONSE###
I TALL
@@T I am @age years old and quite tall, &username!

Either way, you get a random response picked from the same group.

As I said, a context file can (and should) contain many context/response sections. If an input sentence matches multiple context sections, preference will be given to ones which appear earlier in the context file. So, you should give some thought to the order of these files, as some very general contexts could possibly "hide" contexts that come below them.

Either of these files may, if you wish, be an empty file. If this is the situation, then Billy will handle ALL input as he would if the input did not meet any of the contexts in these files. In this case, he uses the algorithm from DAISY to extract keywords directly from the input and build a response on these. This is fun as a computer science experiment to see how intelligent a computer really can be, with no human guidance, but it tends to sound much less intelligent.

For a real-life example of this, look at the file CONTEXT.X, located in the folder you installed Billy into. Do not edit this file, however. It is used by Billy when initializing mind files or creating new ones in Simple Mode.

5. How To Create The Rest

The following files are part of the mind file, but you do not directly create them yourself. Read these sections for info on how you do make them.

5.1. GROUPS.BFB, TEMPS.BFB, & SR.BFB

These files contain all of Billy's knowledge about language, including grammar and vocabulary. Billy's algorithms for learning and generating language are very complex, however, and the storage of this data is equally complex. Therefore, it would be virtually impossible for you (or even me) to create these files manually.

The way that these files will be generated is that you will create a file, named INPUT_L.TXT (input language). This file will contain every sentence you want Billy to be able to say, each on a line of its own. These sentences will be fed into Billy atuomatically when the mind file is created, and the neccessary memory banks will then be created.

It is very important to note that when sentences are fed in through INPUT_L.TXT, contractions (such as "don't") are NOT automatically expanded, therefore, you must manually expand any contractions in this file.

It is in INPUT_L.TXT that you must enter all of the sentences that correspond to context/response keywords in CONTEXT.BFB and CONTEXT2.BFB. So, in the example given in that section, you would make sure that one line in this file was:

I am tall.

I'll repeat: Make sure that whenever you use keywords in a response, there is a sentence in INPUT_L.TXT that contains those keywords!.

5.2. HAWKING.BFB

Billy has a subsystem which learns knowedge, and then is able to answer questions about that knowledge. This file is where all of that data is stored. You will likely want to start your mind file out with some facts that it can answer questions about.

Much like with the language files, this file is too complex to be hand-edited. So, you should create a file named INPUT_K.TXT (input knowledge), which contains all of the facts you want your mind file to know. Each fact should be on a line of its own. For instance, if you want the mind file to know that the capital of Alaska is Juneau, you would have one line in INPUT_K.TXT that reads:

the capital of alaska is juneau

And then when the mind file is created, all of these lines will be fed one at a time into the knowledge web subsystem, and a resulting HAWKING.BFB will be produced. Then, you could ask Billy, "What is the capital of Alaska?", and he would answer it correctly.

5.3. VERSION.BFB

This memory bank serves only to identify the "version" of mind file that you are creating. There have been several versions in the past, and will likely be many more in the future. This file allows the Billy program to determine if it can safely open a given mind file or not.

This memory bank is generated for you by the Billy program when the mind file is created.

6. Quick Recap: The Files You Need To Create

Now that you know how to create all of the memory banks, make sure that you have all of the following files in a folder, with no other files: