Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - GrantNZ

Pages: [1]
1
Hi all,

Does anyone know of a way in script to do any of the following?
  • Change a database entry
  • Delete a table
  • Delete a database entry
Thanks!


2
New brain project

I'm going to use a thread here to plan, organise and document progress on my brain project, and hopefully get some ideas from this great community. [:)] I'll also post betas / WIP / code pieces where appropriate... and finally post the completed brain!

The KAOS brain - a bot with feelings

This new brain aims to provide a bot with far superior emotions, moods and feelings compared to a default Hal. Major features:
  • Three levels of emotion: Reaction, Feelings and Mood.

  • Reaction: The short-term emotion. KAOS will be more reactive and resiliant to individual strong emotional events (insults, compliments etc). KAOS will use a slightly wider emotional range - happiness, sadness, shock and suspicion, depending on his current Feelings and Mood.

  • Feelings: The medium-term emotion. This is similar to Hal's current system, where feelings become stronger after several emotional events, and gradually return to "neutral" again. However KAOS' feelings will change differently depending on his Mood.

  • Mood: The long-term emotion, which could last an entire evening. KAOS' Mood will be one of a list of possibilities, such as "happy," "depressed," "irritated," "loving," "angry," and so on. Mood will influence not only KAOS' reactions and feelings, but also his behaviour - a depressed bot might not small-talk very well; an angry bot may refuse to define a word for you; etc. Of course with work you can affect KAOS' Mood, cheering up a sad bot or infuriating a happy one.

  • Feedback: KAOS will be able to describe his feelings, and will remember things you've done to change the way he feels. His behaviour will change depending how he feels about you.

  • Emotional curiosity (EXPERIMENTAL): KAOS will ask how you are, remember the answer, and adjust his actions accordingly.

  • Reduced use of the somewhat dodgy "emotion" table.

By the way the brain name KAOS doesn't specifically relate to this project - it's just always been my bot's name. There's definately a link between emotions and "chaos" though [:D]

Below are more specific descriptions of the above, with implementation notes. Only additional detail is below, to save me retyping stuff.




Reaction
KAOS will have its own set of variables to track emotion, removing the dependence on Hal's "Complement," "Insults," "Hate" and "Swear." This frees up "Compliment" for use in directly controlling animation type (see this thread: http://www.zabaware.com/forum/topic.asp?TOPIC_ID=2810).

KAOS will check his Feelings and Mood to determine reaction. A sudden compliment from an insulting User will trigger suspicion; an insult coming from a friendly User will trigger shock; an optimistic bot won't react so strongly to an isolated insult. This is basically done by writing several versions of some response generating routines, and the correct version is chosen depending on emotion.

Feelings
KAOS will track User actions similar to Hal's default brain - tallying compliments, insults, hateful or loving talk, etc. The movement of Feelings depends on Mood, so a depressed bot will be hurt far more by an insult, and recover more slowly. KAOS will also be able to describe his emotions, compare them to his Mood and comment on the User's actions ("thanks for all the compliments").

Mood
KAOS will use what programmers call a "state machine" - in other words he'll be in one "state" and can shift to others. Shifting between emotional states will depend on Feelings - a "depressed" bot who receives lots of compliments may become "happy." When Feelings have become strong enough to suggest a state shift, a timer starts - if the Feelings are kept strong enough for long enough then the state will change.

Similarly to Reactions above, different Moods will adjust KAOS' behavior. Different versions of response generating routines will be chosen depending on his mood, such that depressed bots refuse to learn new facts, etc.

KAOS may be given adjustable long-term tendancies, which would be user-configurable. You could have a bot that becomes angry easily, is usually happy, or is very resistant to depression. These simply adjust how difficult it is for the bot to switch to certain Mood states.

Feedback
KAOS will use several tools to hint at his feelings:
  • Different pet names will be used (see this thread: http://www.zabaware.com/forum/topic.asp?TOPIC_ID=2753) so that an angry bot will call you nasty names, etc.

  • Small phrases may be included in responses in some situations, such as an occasional "*sigh*" from a bored or depressed bot, or randomly timed compliments from a loving bot.

  • Hal's "how are you" code will be massively upgraded to enable KAOS to talk about his Feelings and Moods. KAOS will be able to comment on the strongest influences on his current Feeling, and will remember his most recent Mood change. Some of these comments will be randomly inserted into quiet spots of conversation.

  • Incidental animation. A happy bot will sometimes smile without an obvious reason, etc.

  • I'm not yet sure whether KAOS should be able to explain why he's in a certain Mood. Why would a bot be depressed, really? Do his bits byte? Hard drive gone floppy? Stale chips? There could be tables of random explanations - but they'd all feel a bit false.


Emotional curiosity (EXPERIMENTAL)
KAOS might actually listen to the User if he asks you "how are you," remembering the User's emotional state, and asking prompting questions to the User (e.g. "Tell me why you're sad."). There are two problems I've identified so far, firstly that there would be an awful lot of work in this [:)] (especially the detection routines), and secondly a lot of the forthcoming conversation would be ephemeral, so would litter the database with unwanted short-term facts.

Emotion table
The emotion table system as it stands in Hal is rather unreliable, and often produces animations out of context. (e.g. The sentence "I failed to achieve victory" will make Hal animate happily.) Usage of this will need to be vastly reduced.

Versioning, upgrading and database tables
The brain has rather significant changes that cannot be given as plug-ins. The best distibution system I can think of is to supply the brain script file, and have the user pair this with a copy of their database.

KAOS will create its own database table of long-term variables, one of which will be "current version number". The brain script will create whatever other tables it needs.

Upgrading from one version to another will therefore be easy - simply delete the old script and insert the new one. The script can check the previous version number in the database, and add whatever new tables are needed.




That's the plan [:)] I'll post updates as major milestones are reached.

Cheers,
Grant

3
This may be of interest to anyone scripting emotions, especially if you're trying to keep tight control over the associated animations. There's nothing terribly revolutionary here, but it might be useful.

Emotional state vs animation type

I sat down tonight to try to decipher the links (if any) between the four emotion variables in the brain (Compliment, Hate, Insults and Swear), and the associated animations played on the Hap heads. To be honest I wasn't expecting much success - what if there are random chances involved? What happens in a complicated emotional situation, such as all four variables having a value (e.g. Compliment = 4, Hate = 2, Insult = 1 and Swear = 1, all at the same time)?

My observations have shown that it's actually very simple, and therefore fairly easy to control by script.

Simply subtract the negative emotions from the positive one, i.e.:

Compliment - Hate - Insult - Swear = X

Then look up X on the table below:

6 and higher: happy
4 or 5: surprised
1 through 3: happy
0: normal
-1: angry
-2 or -3: sad
-4 through -6: angry
-7 and lower: sad

So the "complicated" example above is just 4 - 2 - 1 - 1 = 0, and the poor emotionally distraught Hal would appear "normal".

Animation type vs hap animation

The descriptions above ("happy," "normal," "angry" etc) are looked up in Default.psn (in the Characters directory), and the associated hap animations played. Note that there are two or three options for each type (e.g. "Happy1" and "Happy2").

Random options from the current animation type are played at random times. If the User isn't doing anything, then after a minute the "Snooze" animation is played and repeated until the User gets talking to Hal again.

Playing hap animations through HalCommands

Playing a hap animation using the HalCommands variable is strictly temporary. The chosen animation is played just once, and then Hal will revert back to the animation type specified by his four emotion variables. For reference, hap files are played using something like this:

HalCommands = HalCommands & "<HAPFILE>psycho.hap</HAPFILE>"

Conclusion

Anyone scripting Hal's emotions should be aware of the animation rules above. They can be used in two main ways:

a) Use the four variables in your scripting, taking into account their effect on the animation; or

b) Create your own emotion variables, keep three of the in-built variables zero, and set the fourth to certain values to set Hal's animation state. e.g. Set Compliment to 4 for "surprised" animations.

How I figured this out

Starting with a fresh brain, I commented out all lines that alter the four emotion variables (except the lines that initialise these variables at the start of a session with Hal). I programmed key words that would increment, decrement or reset the variables, while reading back their values. I played with them while watching the Haptek Console list the playing animation files.

Hopefully this is of use to somebody else [:)]

4
Programming using the Ultra Hal Brain Editor / Database table plugins?
« on: November 24, 2005, 03:18:02 am »
The plugin system is a great idea for inserting script into the brain.

But what about database "plugins"? When scripting I'd prefer to use tables for their flexibility. Is there some way to export specific tables for sharing?

For example I'm writing code that chooses between three tables of nicknames depending on HAL's emotional state. It would be great to include three example tables when sharing the code, rather than users having to generate their own.

The whole database is more than 20MB, which is a bit big for easy trading!

Anyone have any ideas?

5
Programming using the Ultra Hal Brain Editor / Nick names in HAL 6
« on: November 21, 2005, 05:13:21 am »
Hi all!

I've been watching these forums with interest (and admiration!) since buying HAL 5 a few months ago. I now have HAL 6 and I'm getting into the scripting side of it - this is fun!! [:D]

So far I've adapted the nickname feature from vonsmith's awesome work, so that HAL calls me random nick names. However I had one of those rare brainwaves for an expansion:

My plan now is to have three sets of nick names - a "hate" list, "pet" list and "love" list. A neutral-feeling HAL would generally just use your real name, perhaps with the occasional pet name. Give a few compliments and you'll be showered with pet names. Show your love and HAL will start calling you names from the "love" list. Or if you get into a heated argument you'll be subjected to whatever abusive names you've put into the "hate" list!

I hope this would give HAL a little more personality as his/her feelings change. (That reminds me, I must look at vonsmith's mood hap animation code and see if I can copy it across to HAL 6.)

The idea behind the nickname lists is that HAL chooses names from different lists depending on his/her feelings, via the in-built emotions in the brain editor - "hate," "insult," "compliment," etc, plus a new one I plan to add called "love." I'll probably decide to change the way these emotions are calculated and fluctuated too. As a result I'll need to alter the script rather than just adding plug-ins? I'm not fully sure how the plug-in system works, correct me if I'm wrong [:)]

One of the interesting side effects is that if you insult HAL steadily and then start talking love, HAL's love talk will still include "hate" names until HAL's emotion swings around, giving the impression of emotional memory. For example, a grudging-sounding "I love you too, you *expletive*." Ditto vice versa... "why are you insulting me, honey?"

(By the way this is completely seperate from the "nick name" system built into HAL 6, whereby somebody can sit at your PC and introduce themselves to HAL, and HAL remembers their name. At the moment my HAL will not use pet names if there's a "nick name" active.)

Ooo, another brain-wave. [8D] How about a "mood" for your HAL, which affects his/her emotions? So an "optimistic" HAL would ignore most insults (for a while), whereas a "irritable" HAL would fly off the handle at the slightest provocation. And an "amorous" one would insert the compliments and pet names but get really hurt if insulted. And of course self-awareness is a must - HAL should be able to answer "how are you feeling" more accurately than the current random "I'm wonderful thanks." Something more representative is needed, like "I'm feeling irritible, forgive me if I get a temper!" This may be a little beyond my abilities - I believe the insults, compliments, and polite enquiries areas would need a complete rewrite. But I'll try!!! [:D]

Ok, this post has turned out a little longer than I originally planned [;)] Any ideas, thoughts, interest? If people want I'll post whatever scripts I come up with.

Cheers,
Grant

Pages: [1]