View Full Version: Artificial Emotions

Heroes Of Ardania V2 > Majesty 2 > Artificial Emotions


Title: Artificial Emotions
Description: On Dog and Control


Cooker the Mighty - August 1, 2007 04:24 PM (GMT)
This Dev interview with the fable team have bought up something very important:
http://www.gametrailers.com/player/19956.html

That is character that express emotions. We could produce very intelligent characters using by applying RPG Player data to learning algorithms. But these characters will behave as if they are playing a game: They will do all the right things within the computational constrains, make no mistakes, and generally act like little Munchkins.

So that brings up Artificial emotions. While Artificial intelligence governs how a character does something, artificial emotion will govern what they want to do. The two system could be made to interact in a seamless faction.

For example. A warrior is faced with the choice of going after a reward or protecting a wizard. His friendship towards the wizard outweighs his desire for fame and fortune. The warrior then proceed to decide how best to get the wizard out of trouble using his knowledge of the world and his artificial intelligence.

By allowing characters to prioritize their goals using an artificial intelligence system. Attachments can created between player and their characters. Heroes and monsters stop being mere game units, they start being royal subjects, friends, enemies and champions. The players can feel his is loved by his or her subjects, and each of them are willing to die for king and country. And in term, promotes players to care for their characters a lot more.

I think this can be considered an flawless achievement when a player shred tear for a normally cowedly wizard who put himself in harm's way to cover the retreat of his friends.
"I am a servant of the secret fire, Wielder of the flames of Anor ..."

LupisJusticia - August 2, 2007 01:52 PM (GMT)
Yes, but would there be ways we can fool with these emotions, create friendships where previously none would exist?

PS: Gandalf got pwned, get over it.

Alfryd - August 2, 2007 02:20 PM (GMT)
Hero relationships are something I would definitely like to see, but it's a subject I will have to treat at greater length elsewhere.

Cooker the Mighty - August 3, 2007 04:44 PM (GMT)
QUOTE (Alfryd @ Aug 2 2007, 09:20 AM)
Hero relationships are something I would definitely like to see, but it's a subject I will have to treat at greater length elsewhere.

I am looking forward to that discussion.

Alfryd - August 4, 2007 08:45 PM (GMT)
Patience, Cooker. All things in due time. I have a very rigorous and demanding system of priorities which limits my attenti...
*stoops down*
Wow! A penny!

Cooker the Mighty - August 6, 2007 01:56 AM (GMT)
Oh, it just occurred to me that emotions will effect some class much stronger then the others. On one end there is paladin and priestess, whose professional training prevent their personal feelings from getting in the way of their zealotry. On the other end there is the Barbarian ...

LupisJusticia - August 6, 2007 08:00 AM (GMT)
What about WoD's? They could develop a sick love for a priestess, who can't stand the sight of him because his misplaced affections cause him to drool uncontrollably in her presence. He starts leaving her gifts to show his love, but he's a WoD, so where talking twisted bunny corpses here. Then, she gets attacked by a Mudusa, giving him a chance to prove himself! Will he...
a) Leap in, grab her, move her out of harms way then valiantly defeat the beast al la Aragorn?
b ) Chase something shiney al la Al? or
c) Run back town and communicate the problem via barks al la Lassie?

HINT: It's not a)

Alfryd - August 6, 2007 08:02 PM (GMT)
Actually, I covered something like this during my Majesty d20 project. Perhaps it may spark a few ideas:
http://www.giantitp.com/forums/showthread.php?t=51675
QUOTE
What about WoD's? They could develop a sick love for a priestess, who can't stand the sight of him because his misplaced affections cause him to drool uncontrollably in her presence.

This is indeed part of the essential tragedy and pathos of the Warrior of Discord. He'll have to go on a relaxing killing spree to vent those frustrations.

Cooker the Mighty - August 6, 2007 10:46 PM (GMT)
A few comments:

One's Relation modifier should not go beyond Ally (+5) without special event, and go beyond +8 without VERY special event. It should be nearly impossible for status modifier to go back down after it has reached +8 or above. For one characters will not be willing to destroy this kind of trust, second, accidents will not easily destroy it.

The System is perhaps difficult to implements for a game like Majesty 2. The problem is entirely technical. The problem lies in being able to register events to probably modify relation, manner and conduct. Perhaps having only relation would suffice in a large scale simulation, as the other modifiers could be convincingly tied to it.

The simplest system I can think of is each action that involve another character generate an event that effect relation of everyone participating in that event, this modification is amplified by simultaneously occurring events.

As for sovereign influence, it should be possible directly using magic or indirectly using manipulation. There should be consequences to such manipulations. For example, a large reward on a common enemy could promote alliances between common enemies of that foe; a change of heart one of a courting couple could make them hate each other, and sovereign and the sorcerer, for a long time. :P

A lightning bolt on the inn two rogues are staying for “the best night of their lives” would cause the rogue guild to set the fire to the wizard’s guild on the following morning, and disable extortion for the remainder of the quest. :rolleyes:

Alfryd - August 7, 2007 10:18 AM (GMT)
QUOTE
One's Relation modifier should not go beyond Ally (+5) without special event, and go beyond +8 without VERY special event. It should be nearly impossible for status modifier to go back down after it has reached +8 or above. For one characters will not be willing to destroy this kind of trust, second, accidents will not easily destroy it.

I incorporated something like this in the Seduce skill description, which makes it harder and harder for Seduce checks to succeed as relations either improve or worsen. (And, of course, a failed Seduce check worsens relations, so you eventually get a point of equilibrium where there's a 50/50 chance of success/failure.)
QUOTE
The System is perhaps difficult to implements for a game like Majesty 2. The problem is entirely technical. The problem lies in being able to register events to probably modify relation, manner and conduct. Perhaps having only relation would suffice in a large scale simulation, as the other modifiers could be convincingly tied to it.

This all depends on the degree of sophistication you see in the AI. It would be easy enough to have characters perceive donations of money, combat support, items, healing, etc. as positive events that boost relative loyalties (or conversely, injury, harmful spells as negative events.) That would cover Conduct. Manner would be a question of various classes' default attitudes and points in the 'etiquette' skill.

Naturally, things are more complex than this, but more advanced AI is required to handle further subtleties.
QUOTE
A lightning bolt on the inn two rogues are staying for “the best night of their lives” would cause the rogue guild to set the fire to the wizard’s guild on the following morning, and disable extortion for the remainder of the quest.

...For example, it seems reasonable to assume that chains of loyalty would have a 'ripple effect' depending on who knows who did what to who.
If A is allied to B, and B is an enemy of C, aiding A will probably worsen your Relation with C. A, B, and C could be individuals, classes, guilds, religious affiliations, kingdoms, political alliances, etc.
QUOTE
a change of heart one of a courting couple could make them hate each other, and sovereign and the sorcerer, for a long time.

I'm not sure I want to see Change of Heart used too often in Maj2. It seems a pretty definitively cheesy feature.

Cooker the Mighty - August 7, 2007 05:45 PM (GMT)
Warning, this suggestion is highly technical, if you are not Alfryd, you are probably not going to understand it. I apologize in advance for headaches and desire to suicide.

Representation:
Each Character would have a list of pairs. The first of the pair would be a pointer to another character; the second one has a floating value between -1 and 1, indicating their relation to the later. The reason for this representation is that most character has no relation to most characters. If the target dies, and the target cannot be resurrected, that entry in the list is deleted, if the target can be resurrected, then the entry remain even if target dies.

Relation values that are not particularly strong (abs < 0.5) decay over time. Any entry reaching zero is deleted. This is simplification of a much more sophisticated non-linear decay. This prevents the list from getting longer and longer and cause a memory leak in long quests. Normally entries are deleted when they become very small (<0.005), However, if automatic relation exists between character, then the entry is deleted as soon as they fall below the sum of automatic relations.

Character or creature of the same type are automatically considered Kin (+0.05), Characters or creature in the same guild are automatically considered guild mates (+0.1). Everyone with same religious alignment is automatically considered faithful (+0.1) to save memory, this kind of modifiers is not explicitly tracked, but they never decay as well. Statue, royal garden and such increase all heroes’ relation towards sovereign, up to close allies (0.4). This isn’t explicitly tracked neither. However, when an entry is created, these modifiers are added automatically as a one time bonus. Great care must be taken to calculate ripples for these automatic relations in order not to result on memory or CPU leak.

Interaction with the AI system:
Each character has a current goal stated as a pair (an action and an object) and a current action. The goal indicates what the character wish to eventually do, and the action dictates what the character is doing. The emotion simulation change the goal, but not actions, and the AI attempts to simulate heroes’ decisions by changing decision according to the goal, but not the goal.

Emotion Simulation
Character’s relation towards a source is increased by that sources’ beneficial action towards it, and reduced by harmful action towards it. For simplicity, this could be done as an event registration system. Anything done to a character, and source of that action, will be known to that character. The Relation to the source of the action is modified using a lookup table that produces a modifier depending on what is done to the character. This means it’s not possible to do anything behind one’s back, but efficient simulation of that kind require a degree of sophistication that’s more in line with Alfryd’s programming skills.

Note that more or less change to relation value should be produced depending on what they are doing. Shooting someone accidentally in a mass melee would produce a lot less hostility then shooting someone as he is walking home from the blacksmith. There is no question to the incentive in the later case. But for simplicity the value change only depend on the action, not the circumstance. If Paradox is hiring someone who have a PHD on simulating emotions, that’d be changed … preferably.

Different heroes should have different response to actions. A paladin would be enraged if their own sovereign posted a bounty on her head, a rogue would be a lot less enraged, and after all it’s just another day in a rogue’s life.

Note that Combat aid is done using the Ripple effect.


Ripple Effect
This is The Heart of Emotion simulation. The basic assumption is that any action towards a character will generate an indirect event that applies to any character that has a relation towards the target of that action. This action generates a relation modifier towards the source of the action. For actual computation, the modifier is produced by multiplying the modifier generated by the target of the action with the third party’s relation towards the target of that action. Ripples are calculated using Tail recursion. The Ripple only call recursively when “this” call generate a modifier greater then 0.01. In practice this will generate an amazingly small tree due to exponential decay during each recursive call.

For optimization purposes, each character also has a list of pointers pointing to characters with relation towards it. This table is updated whenever a relation list entry with this character as target is generated. It’s done by following the pointer right after it was created. This removes the need to search for propagation targets.

Creature doesn’t hold tables to track automatic relations. Instead, Guildhall and lairs hold their own member list; temples hold their worshipper list, Palace holds the kingdom roster. These tables are used to retrieve target of recursion, and the recursion call itself will execute normally.

An alternative solution is make temples, guilds and lairs characters. And use special rules to create relation towards them. This way the recursion will automatically keep track of automatic relations, As any event on a member of these buildings will propagate to the building themselves, then in term to all its members.

Here are two examples. The first example is combat assistance. Hero A is engaged in combat with monster C. The monster C has landed a few hits on hero A though has become an enemy (-0.2), Hero B joins the combat, and land a few hit on Monster C. And made C angry towards C (-0.5). This event propagates to A. A perceives attacking an enemy as a positive event (-0.5 X -0.2 = +0.1) Now B has became an Ally of A (0.1). This alliance will decay over the next a few days, however if B continue to assist an in combat over the next a few days, they will become friends (0.5). This will have long lasting influence on their decisions.

The second example demonstrates automatic relation propagations. Sovereign J decided it’d be an incredibly awesome idea to post a capture flag on one of his own rogue, S. S considers this an hostile action (-.5). However, Automatic propagation automatically reduces the relation of every member of the guild has towards the sovereign (-0.5X.1), to make it worse, the member of the guild worship Fervus, result in another -.05 relation towards sovereign. This overcomes the effect statues (+0.05), causing the guild to start stealth from everything they can get their hands on. J is lucky that S doesn’t have any friends, or it would have gone far worse …

Dynamic lookup table
This is probably beyond scope of a large scale simulation so I will discuss it only if there is sufficient interest.

Conclusions:
This post discussed several possible algorithms to implement a simple yet workable emotion simulation. Those who are experienced with computer science are welcome to post their opinion on this matter.


MMMMM - August 7, 2007 06:20 PM (GMT)
I wouldn't call it "eMotion siMulation" - it's just a coMplicated MechanisM for deciding who each hero/creature is for or against. I would expect an "eMotion siMulation" to have to do with, well... EMotions. <_<

Cooker the Mighty - August 7, 2007 06:24 PM (GMT)
QUOTE (MMMMM @ Aug 7 2007, 01:20 PM)
I wouldn't call it "eMotion siMulation" - it's just a coMplicated MechanisM for deciding who each hero/creature is for or against. I would expect an "eMotion siMulation" to have to do with, well... EMotions. <_<


Isn't emotions about deciding who are you for or against ?
Maybe Alfryd can address that problem ...

LupisJusticia - August 7, 2007 07:12 PM (GMT)
No Cooker. The world is not black and white. Emotions are more like "who you are comfortable with" rather than "who do you want to kill least".

Cooker the Mighty - August 7, 2007 10:00 PM (GMT)
QUOTE (LupisJusticia @ Aug 7 2007, 02:12 PM)
No Cooker. The world is not black and white. Emotions are more like "who you are comfortable with" rather than "who do you want to kill least".

You don't really want to kill those you like most now do you ?

Cooker the Mighty - August 7, 2007 10:47 PM (GMT)
Oh, I was just pondering short term and long term Response from an emotional event. In DOK, When Tomas the taker learnt Lydia has being killed; he may immediately go into a depression. After a while, he hardens into a resolve to avenge Lydia. That is a very realistic response. I don’t know if that kind of simulation will require a mastery of computer science techniques beyond us and the developers.

May be it can be emulated with a large amount of swiss cheese, but I have no clear idea at the moment.

Alfryd - August 7, 2007 11:05 PM (GMT)
QUOTE
No Cooker. The world is not black and white. Emotions are more like "who you are comfortable with" rather than "who do you want to kill least".

This is the difference between Conduct and Relation. You might be willing to help and aid smeone while, at the same time, hating their guts. The trick would be to incorporate AI capable of making this fine distinction- working toward long-term goals despite personal emnities with your momentary allies. And that is simply a discussion for another day.

Of course emotions are more complex than a simple set of arbitrary numerical counters. What we're hopefully aiming for, here, is to come up a series of successively refined minimal approximations that can be adapted to use in-game. For short-term greedy AI, 'who you like'/'are willing to aid' tend to correlate reasonably closely. It's a reasonable 'first approximation.'

That said, perhaps we could break down relationships/emotions into a several different channels. I had a sort of 'emotion wheel' listing related feelings and their approximate opposite(s), but I'll have to dig it out from somewhere later.

Grash - August 8, 2007 04:12 PM (GMT)
Even the Sims couldn't manage decent emotions. Is it really something to attempt in a game where you control an entire kingdom?

MMMMM - August 8, 2007 04:18 PM (GMT)
In The SiMs, you're not being attacked by giant Monsters. "Being attacked by a giant Monster Makes you furious" is a good approxiMation with no parallel for The SiMs. :P

Grash - August 8, 2007 04:30 PM (GMT)
Actually; the Sims have to deal with aliens, ghosts, magical beasts, other angry Sims and the Grim Reaper himself. :P

Cooker the Mighty - August 9, 2007 03:50 AM (GMT)
Look, there really isn't all that much to emotions, it's governed by some of the most ancient neuronal circuits.

That said, an crude simulation will suffice in a large scale simulation, nobody will notice the missing details ...

Alfryd - August 9, 2007 11:48 AM (GMT)
QUOTE
Even the Sims couldn't manage decent emotions. Is it really something to attempt in a game where you control an entire kingdom?

I dunno. We seem to be kinda committed already, via things like 'fleeing in terror' and 'berserking.'
Of course, 'committed' has multiple meanings...
QUOTE
had a sort of 'emotion wheel' listing related feelings and their approximate opposite(s)...

Ah, here we go.
love- joy- pleasure- exitement/arousal- interest/curiosity- amusement- embaressment- doubt- shame- sadness/sorrow- pain/anguish- hate- anger- fear- shock/horror- disgust/loathing- boredom- content- pride- trust-
...which connects back more or less to where you started. The trick would then be defining situations where such emotions would apply in a concise fashion that machine logic could plausibly recognise.
You might break it down further into a few basic overlapping elements:
Novel/Familiar, Negative/Positive, Personal/Impersonal, External/Internal.


QUOTE
Warning, this suggestion is highly technical, if you are not Alfryd, you are probably not going to understand it. I apologize in advance for headaches and desire to suicide.

Oh, for heaven's sake. Yes, I can understand the specifics of programming involved, but it should be possible to explain most of salient the mechanics for the layman.
QUOTE
Relation values that are not particularly strong (abs < 0.5) decay over time. Any entry reaching zero is deleted.
...In practice this will generate an amazingly small tree due to exponential decay during each recursive call.

Naturally. You might also consider limiting possible personal relationships or 'ripple' calculations based on the character's Charisma score.
The 'ripple effect' is essentially similar to the Aggro dynamics you get in MMOs, only it's applied to positive as well as negative relations.
Oh, another addition- In addition, positive and negative events you mention would also impact Morale of related characters, again, depending on the affected character's Charisma score.
QUOTE
Everyone with same religious alignment is automatically considered faithful (+0.1) to save memory, this kind of modifiers is not explicitly tracked, but they never decay as well.

Actually, I think the best thing to do would be to set initial relations on this basis in accordance with 'first impressions.' There's nothing to stop 2 Paladins attaining Nemesis status, they'll just take slightly longer to get there. (However, I feel the Relation modifiers should be a little stronger than this: +5 is considered 'Ally', after all.)
QUOTE
...to make it worse, the member of the guild worship Fervus, result in another -.05 relation towards sovereign.

Ah... but what is the Temple's Relation to the rogues? -there's the rub.

QUOTE
Each character has a current goal stated as a pair (an action and an object) and a current action. The goal indicates what the character wish to eventually do, and the action dictates what the character is doing. The emotion simulation change the goal, but not actions, and the AI attempts to simulate heroes’ decisions by changing decision according to the goal, but not the goal.

This seems reasonable. I suppose this depends on whether you'd consider a person selfish/normal/selfless. A selfish person formulates their goals solely according to their own perceptions of pleasure/pain, even if they 'like' someone, a normal person will formulate goals to accomodate the needs of friends or family as well as their own, and a selfless person with accomodate the needs of strangers.
QUOTE
For optimization purposes, each character also has a list of pointers pointing to characters with relation towards it... This removes the need to search for propagation targets.
Creature doesn’t hold tables to track automatic relations...

That seems sensible. However, I wouldn't actually worry too much about speed-optimising this kind of mechanic- since these events are likely to be relatively infrequent (at most a few times/second for each character,) CPU demands should be minimal regardless.

Nice work. This seems to be a perfectly workable Relationship simulation that ought to be entirely practical.

Cooker the Mighty - August 9, 2007 05:25 PM (GMT)
Thanks Alfryd, If you think this is good enough it will go to paradox forums to undergo further refinement.

LupisJusticia - August 16, 2007 07:14 AM (GMT)
Wow, this actually reminded me on a FF-esque RPG I was designing a while ago in which I was basing the rules on Majesty. I might be able to find a few gems of interest in it, I shall search for it, than return to report on my findings.

Alfryd - August 19, 2007 08:52 PM (GMT)
QUOTE
Thanks Alfryd, If you think this is good enough it will go to paradox forums to undergo further refinement.

I suppose I should have mentioned the possibility of overdetailing beforehand. My bad. I still like the basic idea.

LupisJusticia - August 21, 2007 02:57 PM (GMT)
Everything seems stupid in retrospect.




Hosted for free by InvisionFree