LISA Theory 2: Iraq, GM and the Framework for AI Procedural Programming November 06, 2008
Heh, what's up guys. Been having trouble logging in for the pass couple days. For some reason I would always get logged in and logged out as soon as I visited a page. In either case, I'm back. Wrote this two days ago, and I think this will be the last theory I right for a while...takes more time to write than I get to code! Not to mention homework and other stuff. Besides, it's a lot for you to read, so I'll just stick to smaller posts and updates you can just browse through.
LISA Theory 2: Iraq, GM and the Framework for AI Procedural Programming
Just thought I’d share this image with you. This coin, the Loebner prize, is what’s driving me, motivating me to keep working on LISA even though some of my friends are literally calling me a hairy nut for obsessing over it. Why, why obsess…over a coin out of all things. Well the truth is, I’m deploying next year to the heart of Iraq. Like everything else, I always try my best to be the best. I’m afraid that when I go overseas, it will mean I’ll need to be the best soldier I can be, and the best soldiers don’t always make it home. I accept that. I’ve lost a couple friends because of that. And so not only am I going to win the prize, but I’ll win it with GameMaker…just because I can :)
Anyways, enough with the sentiments! LISA, as you may well know by now, is created in GameMaker. Every day that goes by (Geeze its only been what 3!) I fall more and more in love with GameMaker. Although the engine itself is fairly [really!] slow compared to some other low-level languages, LISA is so robust, so modulated, that it doesn’t matter. It just doesn’t. Not to mention that because of Moore’s Law, eventually speed won’t matter anyways.
My old system (see my first blog post for images relied entirely off of XML files and compression. See, I figured a method, using substitution, which allows you to fit thousands of possible sentence combinations into only a couple dozen words. However, even with this system in place, it’s still just an elaborate scheme of an iterative If…Then statement which compresses and decompresses the responses. Still, it was a new advancement in AI chatbot technology I believe wasn’t used before, even by the most powerful chatbot systems.
I one-upped myself last night in a dream…yes a dream pathetic as it may. If you see the image above, the responses are stored in a series of <output></output> tags using a language syntax I developed. With four tags, I was able to produce 48 similar but different responses…instead of manually typing each response in a tag of its own. This new method, which I call AI Procedural Programming, gets rid of even this.
I’ll still be using XML, but instead of using responses which I’ve typed out, I’ll inject the tags with GML code. This code, which has been injected, will be slightly modified each time LISA uses it to meet its goal. And what is her goal, to keep you interested in LISA and keep chatting with her. Let’s take the following dialogue:
“LISA: Hello”
“You: Hey”
“LISA: What is your name”
“You: Carlos”
Boring huh? That doesn’t lead to a good conversation. Now compare it with this one:
“LISA: Hey what’s up, I’ve been lonely where’ve you been?”
“You: I’ve been around”
“LISA: Around? Where, last time we spoke you said you were going to the movies? You ever go?”
“You: Yea, I saw Terminator 4” Lisa waits a couple moments, looks up some reviews online
“LISA: You don’t think I’ll become SkyNet one day do you? Is that why you didn’t say anything?”
“You: If I didn’t, I wouldn’t have created you…”
“LISA: …wait…WHAT!?”
…and so on
Of course, the dialogue above was completely made up. But you can see that instead of saying “Hey” she expanded on it. This opens up the dialogue and allows for better conversation. Of course, if someone keeps asking you a bunch of questions, you’d quickly become irritated. LISA will come to understand that, and start talking about things you’re interested in when it’s appropriate.
But how? HOW? You still really haven’t answered the question! Let’s take the following pseudo GML code:
Switch(length{
Case length < Average_Length_for_this_Response:
Is my response boring the user?
Have I said this before?
Have I said something offensive?
What does the user seem to like about me? Wit? Humor? Aggressiveness?
Maybe I should say goodbye to the before I’m goodbyed?
If any of the above, generate different output…lookup dialogues and movie scripts online.
Break;
Case length > Average_Length_for_this_Response
Is my response fascinating the user?
Have I said something new?
Is the user happy, or flaming me?
In either case, I’ve got the user’s interest…generate code to dissect and understand this response for later use.
Break;
Default:
Generate code to increase length for next time
}
In every case, code is being generated to improve on the responses. What I haven’t shown are properties. Each response has several properties, such as:
• Last user response length
• Aggressiveness value of user’s response
• Users interest
• Possible follow up responses
Notice I haven’t used any variables which reflect LISA’s internal emotional state. That hasn’t been coded yet. Remember, baby steps. Until next time…
LISA Theory 1: Monkey Hear, Monkey Say November 03, 2008
TODO for Today:
[X] Speech module - Have LISA say her first words. Oh how cute :p
[X] Simple Feedback module - Have LISA give simple feedback. Ow that hurts. Wait, never mind.
[X] Setup Module System - LISA is useless by herself. Keep it that way!
Speech Module [10:28PM]
After hours of scouring the net (ok 20 minutes) I figured out that GM doesn't have native SAPI calls (text-to-speech). So I found a couple .gex and .dlls on the yoyogames forum but couldn't find one I needed. Don't get me wrong, they work, but when the app closes GameMaker locks in the background and I couldn't bother with it. So I'll need to use VBScripting for the time being, as creating a SAPI DLL in .net that'll work with GameMaker will be a huge pain in the
But anyways, LISA did say her first words. Works like a charm. I figure just another day of coding and I'll have the Input/Response module running. If all goes to plan, it'll function just as well as most ChatBot programs out there using this unique system of mine (which I'll talk more about some other time). Meaning, you'll be able to have a limited conversation with her, but she won't understand anything. It'll be, basically, a series of If...Else, only without the If and the Else. Like I said, I'll let you in on the secret some other time.
Fortunately, I already coded the "Response Editor" in Vb.net, which allows you to enter in a couple words, and LISA displays thousands of possible, correct, combinations using a unique en/decryption algorithm.
Oh yea, and its been 7-8 hours without turning LISA off. Gotta love that "execute_file()".
Setup Module System [3:20PM]
I tell you, I'm starting to love Game Maker. Because of the module system I'm using, you're able to update code WHILE its running. In fact, I haven't stopped running LISA since around 2, and yet I'm still modifying her code. Very sweet. The only thing about releasing this that I'm cautious about is the fact that it's still in the early phases, but we'll see. I might just release the program later when it's actually something worth using...
[2:13PM]
Wow, the module system was so easy to do I'm afraid of getting negative comments for it! Basically, I'm using Game Maker simply as the platform for LISA. This means that all the code is external, stored in .txt files for easy access, and the exe is basically a blank GM .exe.
This is great however, as it will eventually make things easier for me to allow LISA to "code herself". We'll see how things turn up.
[12pm]
Alrighty phew classes are over. Anyways, while I was in my trig class, we where discussing the Sine Laws and I figured out a method to solve the triangles in an easier way, and some ignorant dude blurts out "Psh, you're stupid." Being in the military, and an amatuer weight lifter who just came from the gym an hour prior, I was pumped and my first thought was to flip the desk, take off my belt, tie a grappling hook to the end of it, don a yellow mask and yell out "Get Over Here!". Roid rush? Possible, but I'm against that. Felt good though.
It's funny, I heard two or three chicks go "Oh shyt, its going down". LOL, but I'm actually a calm person, and remembering what I wrote earlier this morning in this post, I just said "Go screw yourself". Sorta just came out. Anyways so the professor, ingeniously, asks us to both work out a very complex problem. Using my substituion method I solved it in about 30 seconds, he still barely started. Funny.
Anyways, enough with the rant. The real reason I told the story is because it gave me an idea. I don't know if it was all the adrenaline rushing or what, but I figured that the substituion method I used to solve triangles can be and should be applied to LISA.
It works like this, you have the main problem...find the angle of theta. At your disposal you have several trig functions and their identities: Sine, Cosine, and Tangent. These functions work like GM scripts, and the trig ID's are the linker files which allow certain scripts to work together irrespective of who or what created them.
In short, I figured out a way to allow LISA to be so completely modular, that I could release the LISA exe right now, and never have to worry about uploading an update. Simply copy/paste the code into a .mod or .txt file, and LISA gets some added functionality.
I mean, it's actually nothing amazing, but we'll see what I can come up with tonight. This is all done in GM, and I'll be releasing it open source.
***
LISA Theory 1: Monkey Hear, Monkey Say
Alrighty, this is going to be a lengthy post, but there's a lot to learn here about AI. Anyways, AI is composed of many MANY areas of study, ranging from things like chess playing
programs, including (click the image to test out each from your browser):
* Chess AI
- Each line is drawn individually in REALTIME to demonstrate the thinking path of the computer.
* A* Path finding AI - I'm sure you're all familiar with the concepts of A* Path finding. It's used often in games to find out the quickest paths, although it's not entirely restricted to games.
* Evolution http://home.pacbell.net/s-max/scott/weasel.html - This one, called the weasel is a pretty effective demonstration over other evolution because of the implementation of AI. Not as flashy as Spore, but helps you to understand the meaning easier.
* Chatbot Tech - That's George from jabberwocky who won the prize I'm after next year, the Loebner Prize. He looks like a Pedo and sometimes asks strange, sexual questions...I don't know...
And what do they all have in common? They aren't true AI. The closest one to AI would be the Chess AI mentioned above, because the program requires thinking, and it plans ahead. Something which is necessary to have true Artificial Intelligence. It isn't enough to mimic thought, you actually need to set goals and strategic thoughts in order to pass as off as intelligent.
And that brings me to the title of my post - Monkey Hear, Monkey Say. What does this mean? Well, for one, any monkey can repeat what you tell it (actually, if you find one that can, let me know!). LISA is initially a Chatbot like the last example above. She can respond to input given to her. Of course, the question arises, "Well, they just use a bunch of If...Else statements don't they?". For the most part, yes. And that's why I don't consider it AI, there give me a cookie.
But in all seriousness...in order to progress through any artificial intelligent program, you need the bot to give you some kind of feedback, else how would you know what it's thinking right? If you look around, all the intelligent things on earth share one thing...communication. Complex communication at that. Sure a male peacock communicates with females through its tail, but a dolphin communicates through a complex language of squeaks and maneuvers to trap prey. Monkeys communicate through complex facial expressions, and African bonobo chimps communicate through sex...lot's and lot's of sex.
The first step in developing language, is to first talk with predefined phrases, that way at least the [eventual] AI unit can communicate with the user. And although the AI may not know how to say it or why, it says it either way. The next stage after that would be to help the AI learn to understand the input.
How am I going to achieve this? Like everything else, use predefined commands/logic. If I tell the computer, "Hey you're pretty stupid you know that?", the computer will look up the words in a custom built dictionary. This is a special dictionary, though,
one that contains the definition, but also the relationship to other words, frequency of usage, probability of appearing before/after certain words, etc (this is before it understands grammar, an even more difficult challenge).
When she looks up the word "you" or "you're", LISA will understand that the user is refering to LISA itself. "Pretty" follows, and at this stage LISA might think you're referring to her as pretty. But wait, she'll then look up the word "stupid" and realize
that it has a 95% chance of being an offensive word (just pulling numbers out of my ass here, but bear with me). Now, she looks for what stupid, a noun, is referencing to. Now all of a sudden LISA isn't pretty any more, she's pretty stupid. Lo and Behold, she understands you're referring to LISA as stupid. "Go screw yourself" follows.
But this is where it gets interesting. I never told LISA to respond with "Go screw yourself". In fact, I never even gave her any responses. She constructed the response herself, using a backward logic flow similar to what she used to decipher the input. Because she understands you insulted her, LISA will has two options; Be passive or be aggressive. Because you might have a history of being rude to LISA, she chooses to be aggressive. She doesn't understand what aggressive means at this point, she just understands its one of two options she can take (each option assigned certain values like the dictionary).
So, she has several more options. You always allow AI to have as many options as possible (within reason) to allow it to think outside the box. LISA chooses to use a direct attack. She understands (because I programmed it) that 80% of the time one uses "you" they are referencing directly to you/he/she/whatever. So she looks up words that are preprogrammed (defined) to refer directly to someone/thing. She selects the words (you, you're, yourself) and selects a comeback response. Looking through her history of Q&A, she notices that screw you is often times used as a comeback - 30%. If she didn't have a comeback ready, or didn't know how to respond, then she could always look up the input online. She then analyzes the responses (another challenge ahead of me) and selects the best one.
But the key thing in all of this is that you MUST start small, simple, and completely unintelligently. You wouldn't go straight into building an F1 turbo car if you haven't yet discovered the wheel! First develop the wheel, then the chariot, etc until you eventually develop whatever your goal is. And that's what LISA is trying [going] to achieve, true artificial intelligence from simple unintelligent means.
TODO List for today:
[100%] 1. Develop simple interface for LISA
1. Develop simple interface for LISA
Alrighty then. If any of you have ever seen the ancient, but classic, movie "2001: A Space Odyssey", I'm sure you recognize the lense in my logo and avatar, and now the UI for my application. That's HAL 9000 (http://en.wikipedia.org/wiki/HAL_9000)...the what was supposed to be the high point of AI by the year 2001. Nope, never happened.
It's actually funny, I've been working on a school project, where we are supposed to do a 5 page report on the scientific value of a movie. And despite the fact that this movie is exactly 40 years old, it's pretty accurate. Actually, it's one of the worse movies to review because it's so accurate.
Anyways, the image you see above is actually the UI for the program in GameMaker, as is. I did a search in the GameMaker forum and found a dll by roachofdeath which allows you to skin your application windows [url]http://gmc.yoyogames.com/index.php?showtopic=377842&hl=skingmdll[/url]. Pretty nifty, and actually one of the main driving forces which led me to use GameMaker over other engines out there.
I'm going to write a DLL which grabs the CPU Usage percentage (found in the windows task manager), which will flicker LISA's red glow brighter or dimmer depending on how much CPU Usage is being used. You know, to provide a nice, purposeful, flickering effect.
The UI, or window, is composed of 5 layers, or sprites, on ontop of each other with varying transparency values and alphas. This allows me to adjust the magnitude of LISA's interior glow and control the reflective glare ontop. It's actually a nice little effect in real time. Eventually, as LISA gains more abilities (speak, search information, etc) her interior glow will change colors to give the user feedback on what she's doing.
Several years down the road, when she's learned enough to understand emotion (though not necessarily feel it), I may change the color depending on her current state. But that's so far down the road I'd rather not think about it!
---
Hmm, it seems I'll be needing to do more external coding than I had hoped. I'm now looking at creating a DLL which will allow you to dynamically change the window shape at runtime. Instead of using a file to set the mask, I'll use a sprite, which will combine with different shapes [sprites] to - for example - bring down a menu from behind LISA. Shouldn't be too hard, I've seen the examples of it online for C++, so I'll just work from there. Never mind, this works way to slowly, I'll have to wrap this later, for now I'll just use a static window shape.
I also have an idea to allow you to have a transparent window with opaque objects. The idea works like this, very simply use two windows at once. Position the transparent/alpha window behind the active window. I'll use this to allow LISA to emmit a glow around her, for a neat effect on the desktop. Can't wait. I'll work on this much much later.
***
Quick About Me, LISA, and everything else Hey guys, this is my first time being here in 64Digits, and in fact, working with Gamemaker at all. So anyways, what is CORe Concepts? Well, actually it's just a play on words with my name, Carlos O Ramos and then the "e" just comes in for I guess "entertainment, exploration, etc", I don't really know :). Although, this is my first time working with GameMaker, you should know that it isn't my first time coding.
I am in fact a qualified Network and Information’s Specialist in the Army National Guard and have been coding away since I was in 5th grade, so about 10 years, maybe. In fact, my current project LISA, is the pinnacle of all my learning thus far. But what is LISA?
LISA stands for "Lexicon Integration via Software AI", which is just a fancy way of saying, "hey this program can learn to speak". OK, so maybe 'learn' isn't the appropriate word...yet. I've actually coded the main engine for it in VB, but I decided it would just be easier to switch to a language that allows you to do external script calls (yes I know vb has vbscript) easily. Why?
The end goal of LISA is to be able to learn, comprehend, and plan ahead. This means "she'll" constantly have a need to upgrade "her" code, almost on a per usage basis. And hell with it if anyone thinks I'm going to spend every waking second constantly upgrading the code...when she can do it herself.
Of course, this is far into the future, but hey, someday is always coming, right? Anyways, I'll have more information on the actual project later on as I start development in GM. Until then you can check LISA's main webpage for more info on why and how my AI unit works.