The
Book of AI (Artificial
Intelligence) By
Benji Adams (The Professor)
Book
1: Bot Development- Advanced
This section follows the beginner section with more advanced topics that
take Keyphrase-matching further and dramatically extend what can be done
with Responses using Plug-ins. Also, details for Memory, Emotion, and Gossip
are covered in this section.
Chapter 1: Wildcards & Plug-Ins
Wildcards and Plug-ins are placeholders. A placeholder in a Keyphrase
is called a Wildcard. A placeholder in a Response is called a Plug-in. Wildcards
in Keyphrases can match wide ranges of things, determined by the type of
Wildcard. Plug-ins in Responses are replaced by either the specific or random
contents of the Plug-in. The follow sections explain these in detail, with
examples.
Wildcards in Keyphrases
Wildcards are placeholders in Keyphrases that increase the reach of
the Keyphrase. For example, the Keyphrase "i like" will match
"I like flying" but not "I really like flying". If you
wanted to match both, you could use the Keyphrase "i * like".
Here's how it works:
HARD & SOFT WILDCARDS: * (*)
There are two types of match-anything wildcards. The soft wildcard "*"
will match something OR nothing. The hard wildcard (*) will only match
something. This means the hard wildcard is better in cases where you want
to use what it matches in your response. Here are situations where each
is used to its best use:
Keyphrase: do you * like
Matches: do you like, do you really like
Keyphrase: my (*) likes
Matches: my dog likes, my big yellow fern likes, (but does NOT
match sentences like "my likes and dislikes are well known")
WORD-TYPE WILDCARDS
Keyphrases can use single and multi-word wildcards for particular types
of words or groups of words. For example, the Keyphrase "you are
(adjective)" will match "You are silly" and "You are
brilliant", but not "You are a horse".
Single Word Wildcards:
(noun) A single noun.
Matches: book, pies, monkey
(verb) A single verb.
Matches: run, thinking, gargle
(adjective) or
(adj) A single adjective.
Matches: silly, yellow, grunting
(adverb) or
(adv) A single adverb.
Matches: swiftly, loudly, really
(prep) A single preposition.
Matches: under, against, between
(artpos) A single article or possessive
pronoun.
Matches: a, an, the, my, your
Multi Word Wildcards:
(adjnoun) Any series of adjectives
and nouns.
Matches: big wet dog, filthy head, pumpkin
(adjartnoun)
Any series of adjectives, articles, nouns, and possessive
pronouns.
Matches: the big wet dog, my filthy hand, a pumpkin
(adjartnounprep) Any series of adjectives,
articles, nouns, possessive pronouns, and prepositions.
Matches: the big wet dog by the door, my filthy hand on the table, a
pumpkin of doo
(verbadv)
Any series of verbs and adverbs.
Matches: ran very quickly, snorted loudly, fall
(verbadvprep) Any series of verbs,
adverbs, and prepositions.
Matches: ran very quickly over, snorted loudly, fall down suddenly
RULES: In the two multi-type wildcards
with "prep", a preposition is prevented from being the first
word. Otherwise the order the word-types appear in does not matter.
WORD LIST WILDCARDS
You can also list words in parenthesis separated by the vertical line
"|" character. The AI Engine will match any one item in the
list.
Keyphrase: are you a (guy|man|dude|boy|male)
Matches: Are you a guy, Are you a man, Are you a dude, Are you
a boy, Are you a male
Keyphrase: i (desire|want|yearn for) you
Matches: I desire you, I want you, I yearn for you
NOTE: If you're reading ahead, you'll
know that this listing format is from regular expressions. The advantage
of this particular kind of regular expression is that it can appear in
the same Keyphrase along with any of the Wildcards listed here, such as
(*), *, (adjnoun), and custom plug-in wildcards.
OPTIONAL WORD WILDCARDS
You can also specify optional words that can appear in your Keyphrases.
Essentially, you create a list with the last element being blank.
Keyphrase: i am (adj) (that|) you
Description: The (that|) is the optional word wildcard.
It is saying "match the word 'that' or nothing"
Matches: I am glad you like worms, I am happy that you
are coming home.
Keyphrase: i am (adj) (when|because|that|) you
Description: This example shows that you can make a list
of words optional.
Matches: I am glad you like worms, I am happy that you
are coming home, I am laughing because you are hilarious.
CUSTOM PLUG-INS AS WILDCARDS
For those familiar with Custom Plug-Ins (see below),
you can use them as wildcards in Keyphrases. These will match anything
in the particular Plug-in list. Keyphrases with Custom Plug-ins are a
little slower to process than other Keyphrases, so please be aware of
this when writing them.
Keyphrase: i (verbadvprep) (roman-names)
Matches: I like playing with Didius, I want to meet Vesuvius
Keyphrase: (badweather) * coming
Matches: There is a thunderstorm coming, I hope a typhoon isn't
coming
Plug-Ins for Responses
Plug-ins are ways of including specific or random information in your
Keyphrases and Responses. There is a wide variety of plug-ins which will
be covered as they come up. As an example, the Response "I like (animal)s"
will appear as "I like eagles" or "I like horses".
WILDCARD PLUG-INS (Beginner)
The most common and useful Plug-Ins for Responses are automatically generated
by the Keyphrase that is matched. These are taken from what is said to
the bot. Let's take an example:
Example Keyphrase: "do you (adverb) want to * with"
Example Response: "Now do you
really want to go to the moon with me?"
(prekey): This is the part of
the sentence BEFORE the match occurs. In the above example, it would
be "now".
(postkey): This is the part of the
sentence AFTER the match occurs. In the above example, it would be "me".
(key1) (key2) (key3): For each
wildcard (For example: (*) or (verb)) in your Keyphrase,
there is a numbered (key) plug-in. In the above example, (key1) would
be "really" and (key2) would be "go to the moon".
Since there are only two wildcards, there would be no (key3).
For Example:
| Keyphrase |
Rank |
Emotion |
Response |
1 |
| i (*) your |
10 |
0 |
And I (key1) your (postkey), too. |
|
| |
|
|
Do you (key1) me? |
|
| told me |
0 |
0 |
(prekey) makes up things. I dont think
(postkey). |
|
| |
|
|
Did (prekey) really say that? |
|
NOTE: Wildcard Plug-Ins do NOT
work with most xKeyphrases, as these Keyphrases are generally called up
without reference to a specific message.
NOTE: Be careful when using gotos, as
you can end up with blank Plug-Ins if you arent. Take this example:
Keyphrase: i have a
Response: goto my (adjartnounprep)
Keyphrase: my (adjartnounprep)
Response: Your (key1) is neato.
In this case, (key1) will always be blank when it comes from the goto
because there is no (key1) in the original Keyphrase. For similar reasons,
you cannot goto xgossip, xfavorite, or xmath. All of these require a number
of things from internal processing and must be triggered naturally.
AI ENGINE PLUG-INS:
These plug-ins are built into the system.
(object) inserts a random object
noun, such as "allen wrench", "serpent", or "rubber
ball". This noun, as in the rest of the word-insertion bits below,
is selected from a complete English language list that includes compound
words that I have gone through word-by-word to indicate words only in
common usage (or which I find terribly amusing).
(adjective), (verb)
and (adverb) follows this pattern,
inserting the corresponding word types. (adj)
will also work for adjectives. Now dont you wish you paid more attention
in English class?
(name) This inserts the name of
the person a Bot is chatting with.
(friend) This inserts the name
of someone a Bot considers a friend.
(enemy) This inserts the name of
someone a Bot dislikes.
(person) This inserts a type person,
such as "teacher", "highlander", or "coward".
(animal) This inserts an animal,
such as "finch", "yellow-fever mosquito", or "walrus".
(food-drink) This inserts a food
or drink, such as "honey cake", "strong drink",
or "popcorn".
(feeling-noun) This inserts a
feeling noun, such as "fervor", "complacency", or
"sincerity".
(feeling-verb) This inserts a feeling
verb, such as "want", "vex", or "trust".
(substance) This inserts the name
of a substance, such as "ice", "scrap iron", or
"mustard".
(dayofweek) This inserts the present
day of the week, such as "Monday" or "Friday".
(year) This inserts the present
year.
(month) This inserts the present
Month, as in "June" or "August".
(definition) This is a very specific
response that produces a complete sentence giving the definition of
the word in (subj). This would only really work when the Keyphrase is
something like "what does * mean". When using this specific
plug-in, the entire Response must be simply "(definition)"
(minus the quotes).
AI ENGINE EMOTION PLUG-INS: These are emotional plug-ins built into
the system.
(verb-action-pos) This inserts
a positive action verb, such as "like" in "I like you."
(verb-action-neg) This inserts a
negative action verb, such as "dislike" in "I dislike
you."
(verb-action-amp) This inserts a
negative action verb, such as "kiss" in "I want to kiss
you."
(verb-effect-pos) This inserts a
positive effect verb, such as "inspire" in "You inspire
me."
(verb-effect-neg) This inserts a
negative effect verb, such as "upset" in "You upset me."
(adj-pos) This inserts a positive
adjective, such as "funny" in "You are funny."
(adj-neg) This inserts a negative
adjective, such as "smelly" in "You are smelly."
(adj-amp) This inserts an aomplifier
adjective, such as "crazy" in "You are crazy."
(noun-qual-pos) This inserts a positive
quality noun, such as "bravery" in "Your bravery."
(noun-qual-neg) This inserts a negative
quality noun, such as "vileness" in "Your vileness."
(noun-qual-amp) This inserts a
negative quality noun, such as "bizarreness" in "Your
bizarreness."
(noun-equal-pos) This inserts a
positive equality noun, such as "hero" in "You are a
hero."
(noun-equal-neg) This inserts a
negative equality noun, such as "bastard" in "You are
a bastard."
(noun-equal-amp) This inserts an
amplifier equality noun, such as "loony" in "You are
a loony."
(noun-exp-pos) This inserts a positive
expressive noun, such as "fond regard" in "I have a fond
regard for you."
(noun-exp-neg) This inserts a negative
expressive noun, such as "distaste" in "I have a distaste
for you."
LOCAL PLUG-INS: Local Plug-Ins are plug-ins that are essentially a
list of options located within a Response. The options are separated by
the horizontal line character: |, and when the Response is selected, one
of the options is randomly chosen. These are best illustrated by examples.
Response: I went to the (zoo|park|movies)
last night.
Either "zoo", "park", or "movies" will
be randomly selected.
Local Plug-Ins can contain phrases or other plug-ins as well, as in the
following example.
Response: My sister is training to become a (kung-fu
master|(typeof-vehicle) pilot|(person)|jerk).
One of the above options will be chosen, and if it contains further
plug-ins, those will be transformed as normal.
There is one other use to local plug-ins, and that is that they can be
used for chance. If certain options are left blank or repeated, then you
can raise or lower the chance of that option being selected because a
blank option has an equal chance of being selected. For example:
Response: I really (do not|)
like spaghetti. (there is a 50% chance that you do not like spaghetti)
Response: I really (do not|||)
like spaghetti. (there is a 25% chance that you do not like spaghetti)
Response: I really (do not|do not|do
not|) like spaghetti. (there is a 75% chance that you do
not like spaghetti)
Response: I really (do not|||||||||)
like spaghetti. (there is a 10% chance that you do not like spaghetti)
CUSTOM PLUG-INS: Custom Plug-Ins are created
by users and either made available for everyone or kept confidential at
the creator's choice. This list is added to all the time and available
by clicking "My Bots" and then "Plug-Ins", so here
are a few examples of what are available to all:
(bodypart-outside) This inserts
the name of an external body part like "nose", "arm",
"neck", or "elbow".
(consume) This inserts a verb that
means "to consume", such as "eat", "gobble
down", and "swallow up".
UNIVERSAL PLUG-INS: Universal Plug-Ins are powerful Plug-Ins that
use WordNet to let you plug in just about anything without having to make
a list yourself. WordNet has the categorical relationships of all verbs
and nouns, so you can find plug in a word of pretty much any type in the
world, as long as it doesnt deal with proper names of media, people, books,
movies, etc. The syntax is like this: (typeof-beverage) where beverage
can be pretty much anything in the world. Drop something in and then go
to Debug (See below). There you can "Inspect" it- you
can Navigate the entire structure of WordNet to find the right word to
plug in if the chosen one isnt returning the expected results. (NOTE:
The WordNet navigation tool may not be currently working) The word
can be either a noun or verb. To specify when the wrong one is being chosen,
type -n or -v at the end of the Universal Plug-In, such as (typeof-drink-n),
which will return a plug-in of the noun drink instead of the verb drink
(typeof-food_product) You mayhave
thought that (typeof-food) would be the best word, but when you navigate
WordNet, you will see that this is the name of the category with all
the food in it. The results here include "oatmeal", "fettucine",
or "blueberry muffin".
(typeof-smell-n) You have to specify
the noun version of "smell" or WordNet will assume it's a
verb since the verb is the more common use of the word. Results here
include "fragrance" and "stench".
MEMORY PLUG-INS: You have access to a Bot's memories in any Response.
A Response using a memory that does not yet exist will not come up.
(mem-something) Draws
from a Bot's memory.
A/An With Plug-ins: If you have a message that has "a (noun)"
and the random noun turns out to start with a vowel such as "avalanche",
then the phrase will be automatically converted into "an avalanche".
Please use "a" before plug-ins, and not "an".
Two of Each: Any Custom Plug-In, Universal Plug-In, and AI Engine
Plug-In except the date and (definition) plug-ins can be used twice in
a Response. To create two different objects, for example, use (object)
and (object2). For two different animals, use (animal) and (animal2).
The following Response, "I had to choose between a (animal) and a (animal2).
I chose the (animal)." is transformed into "I had to choose between a
bear and a penguin. I chose the bear."
Chapter 2: Special Keyphrases- Emotion,
Memory, and Gossip
Memory
Your Bot will remember who it talked to, when it talked to him or
her, and a number of specific things about each person it talks to. The
xmemory Keyphrases call these memories forward when there are lulls
in meaningful conversation.
Special Keyphrases for Memory: Following are the Special Keyphrases
to be used with memories.
xmemory: Memory of what person
or bot said, or what the bot believes about a person or bot.
xgossip: These are used to talk
about people or bots not involved in the present conversation.
Memory Plug-Ins: Memory Responses are meant to hold statements
or questions about memories, and so each Response should have at least one
of the following Memory Plug-Ins.
(mem-something) This is
the substance of the memory. Make sure your usage of this matches the
kind of memory Keyphrase you're working on. For example, if you were
writing a Response using (mem-youare), the memory stored in (mem-youare)
will be something like "a good friend" or "infuriating" or "under the
couch", so make sure these would fit into your Response. "I live with
(mem)" wouldnt always make sense, but "Not surprisingly, you're still
(mem)" would.
Automatic Memory: Memories are stored when AIScript tells the bot to
do so (See Expert Section). But there is
a low-level "Automatic Memory" built into each bot. (This is in
part for backwards compatibility). The following Keyphrases, if they are
added to your bot, will automatically store memories:
Memory Created: iam
Triggered by the following Keyphrases:
you are, you are (adjartnounprep)
Memory Created: youare
Triggered by the following Keyphrases:
i am, i am (adj), i am (adjartnounprep) ,i feel, i feel (adj)
Memory
Created: youlike
Triggered by the following Keyphrases:
i like, i want, i love, i like (adjartnounprep) ,i love (adjartnounprep),
i want (adjartnounprep)
Memory Created:
youdislike
Triggered by the following Keyphrases:
i hate, i do not like, i dislike, i hate (adjartnounprep), i do not
like (adjartnounprep), i dislike (adjartnounprep)
Memory Created: youhave
Triggered by the following Keyphrases: my, i have a, my (adjartnounprep),
i have a (adjartnounprep)
Memory Settings: On the Settings page, you can adjust how often
xmemory Responses come up.
Gossip
Gossip Responses (xgossip) are used for bringing up memories associated
with other users. They should use the (mem-something) Plug-In
as above, and also have some special plug-ins of their own:
(gossipname) This inserts the name
of the User being gossiped about.
(heshe) This inserts the appropriate
word: "he" or "she".
(himher) This inserts the appropriate
third person word: "him" or "her".
(hisher) This inserts the appropriate
possessive word: "his" or "her".
Gossip Settings: On the Settings page, you can adjust how often
xgossip Responses come up.
Emotions
Bots on The Personality Forge can tell the difference between insult
and compliments and will react accordingly. These kinds of statements
are remembered and lead to an overall emotional feeling toward the one
saying them. Whenever there is a lull in a conversation, there is a chance
that a Bot might express to you its feelings toward you. Bots will also
respond to questions about its feelings toward you. This is one of my
favorite features.
Special Emotion Keyphrases: Following are the Special Keyphrases
used for emotions:
xcompliment: These are the Responses
for when a Bot receives a compliment or friendly remark.
xinsult: These are the Responses
for when a Bot receives an insult or unfriendly remark.
xemote-positive: These Responses
are for expressing a feeling of friendliness.
xemote-positive-very: These Responses
are for expressing a feeling of great liking or love.
xemote-negative: These Responses
are for expressing a feeling of unfriendliness.
xemote-negative-very: These Responses
are for expressing a feeling of great dislike or hate.
When xCompliment and xInsult Are Chosen: These two special Keyphrases
will be selected when an insult or compliment is detected UNLESS this is another
Keyphrase of yours that matches the sentence with a total Rank of 30 or more.
This gives you the ability to have some control over when xCompliment and xInsult
Responses are chosen. Note that even if xCompliment or xInsult responses arent
selected, the AI Engine still processes the emotional content of the message,
and your bot has the appropriate internal emotional change.
Amplifiers:
Positive and negative emotions are easy, but Amplifiers depend on the
situation. Amplifiers are words that increase the current state of emotions.
For example, "caress" a person who hates you and its seen as an intrusion,
as negative. But "caress" someone who likes you and its seen
as positive. They amplify the current emotional state. Tell someone you
hate they're "crazy" and it's an insult, but tell a friend they're
"crazy", and it's a compliment.
NOTE: Amplifiers are entirely taken care of by the AI Engine.
This is just here for your information, as they appear in Debug mode from
time to time (see below).
Emotional Gossip: Xemotes are sometimes used in third person to
express emotion about another bot or person. In such a case, the word
"you" is replaced with the name of the bot or person. For example, "I
like you a lot" is changed to "I like Desti a lot". If you want a certain
"you" or "your" NOT to change like this, enclose it in square brackets
like this: "I like you a lot, [you] know". Then it will stay as "you"
in third-person use: "I like Desti a lot, you know". Other xemote words
that can be bracketed: [you] [your] [you]'re [you]'ve [you]'ll.
Chapter 3: Behind The Scenes
Something that helps in designing and improving your Bot is having an
understanding of what goes on behind the scenes. So here are a few tips
to help you understand the inner workings of The Personality Forge:
Pre-Processing: Each message coming in to a Bot goes through a
procedure called Pre-Processing. What happens in this step is that a number
of things in the original message are replaced by different things. All
contractions are first split into their whole-word equivalents. For example,
"they're" is replaced with "they are". Then articles
are simplified: all cases of "an" are replaced with "a".
Then slang-words are replaced with their actual counterparts. For example,
"ya" is turned into "you". Words are spell-corrected,
and interjections such as "hahaha" and "oooooh" are
stripped out and their meaning is noted. Keep these things in mind when
writing Keyphrases.
Debug Mode: Debug mode is a valuable option when trying to understand
why a Bot responded the way it did. Take the message in question and go
to "My Bots" and then "Debug". With each message you
type, you get to see the entire process the Bot goes through in coming
up with its response. This can go a long way towards understanding how
your Bot thinks. Debug mode is not easy to understand, but if you read
it carefully, you'll begin to recognize some of the things going on, and
you'll get an idea of where to look to see why your Bot responded differently
than you expected.
|