MOB Combat AI
Goto page Previous  1, 2
 
Post new topic   Reply to topic    mudlab.org Forum Index -> Design
View previous topic :: View next topic  
Author Message
BobTHJ



Joined: 19 Nov 2005
Posts: 31

PostPosted: Tue Nov 29, 2005 8:12 pm    Post subject: Reply with quote

I don't think there is a way to avoid hard coding the goal-steps. However, there is a high degree of reusability because you are breaking down the main goals into bite-size goal-steps. Goal steps can be assembled in different orders with a different set of parameters and accomplish an entirely different goal. Therefore this solves the problem I posed in the topic-starting post of coding a different AI for each mob. Instead, I only need to code a set of goal-steps, and then assign a goal to each mob. The mob will then use those goal-steps to complete it's goal. As time progressives you can add increasingly advanced behavior to all mobs by simply adding more goal-steps.

Also note that the majority of the low level goal-steps will be skills, spells, and items which are already coded. It's simply a matter of what goals those skills/spells/items can complete. For example, a Teleport spell completes the goal of "Move to room X". A healing potion completes the goal of "Increase my health".
Back to top
View user's profile Send private message Send e-mail
Author Message
Kelson



Joined: 18 May 2005
Posts: 71
Location: SC

PostPosted: Wed Nov 30, 2005 12:01 am    Post subject: Reply with quote

BobTHJ wrote:
I don't think there is a way to avoid hard coding the goal-steps.


I don't know if that is quite accurate. I haven't worked on my game for a bit now since I've been working on AI in another game (TASpring). One of the cool parts of a fellow AI-developer's work is that he doesn't hard-code responses. When the AI begins it develops its own database of options and evaluations for those options based on known characteristics (in TA, these options might be which unit to build, in which case the characteristics are things like cost, damage, armor, speed, range, etc) and evaluated characteristics (such as effectiveness vs unit X, efficiency, etc). In a mud, this would be possible by categorizing commands that deal with emotes, that deal with combat, that occur only during combat, that deal damage, that help defend the mod, etc. Just something to think over...

Perhaps the OrcMageAI could, over time, tell that the flame spell normally does 95-115 dmg to units, but against players it tends to do only 15-30 dmg (because they use fire-resistance) and begin using the 50 dmg poison spell (normally 10 seconds of 5 dmg/s to units) which tends to do 100 dmg to players (10 seconds of 10 dmg/s). Or it could figure out that players tend to do ~500 dmg / fight of fire damage and only ~100 dmg / fight of melee damage, so it'll toss up that fire resistance more often.

- Kelson
Back to top
View user's profile Send private message Send e-mail AIM Address
Author Message
BobTHJ



Joined: 19 Nov 2005
Posts: 31

PostPosted: Wed Nov 30, 2005 12:28 am    Post subject: Reply with quote

Sorry, I misunderstood your previous post. Yes, in that sense, I don't want the goal-steps "hard coded". As I described above, mobs would have a limited memory that would allow them to track bits of information like "How effective are my fire spells against X?". Then, as the effectiveness of it's fire spells decreased, so would the weighted value of using those spells, causing the mob to use fire spells less frequently.

I think the planning engine "goal-step" system will work well with this type of adaptive thinking, because it requires each goal-step to return a value of how effective that action will be toward completing the goal. This way, you only have to adjust an item's effectivness number based on input the mob receives. However, how to actually effectivly structure the code is something I'm still working on. I spent about 6 hours on it to day and only laid the groundwork for the goal-step system.
Back to top
View user's profile Send private message Send e-mail
Author Message
Big J Money



Joined: 30 Nov 2005
Posts: 2
Location: North Carolina

PostPosted: Wed Nov 30, 2005 9:00 pm    Post subject: What perfect timing Reply with quote

I've been working on a design for a very complex MUD (custom base) for years now, because I'm still novice at coding, and I have to have every little piece of my complex system broken down into simple parts before any of my coding will bear lasting fruit. Recently, I've taken on the task of brain-storming AI. My first approach was to handle all Mob AI together in one system, including combat. Even though the information posted here does not contain combat references, you can assume this system would be used for combat AI as well. I am posting my blog here. Please offer any comments; particularly those of you who are programmers and can forsee any CPU complications. My largest threat in designing this game is going to be efficient use of CPU resources.
--------------
I do not have time to read articles, books, or even a long-winded Wikipedia entry on Artificial Intelligence. What little I know about it is that true AI does not exist in computer games; it doesn't even exist in chess engines, yet. However, AI is the term I am comfy using, because I'm not part of the inner circle of game design. Let it suffice that I placed the term in quotes to prove I don't expect to discuss true Artificial Intelligence here in my little bl*g. From here on out, I will call it AI simply because I don't know what else to call it. Probably some kind of algorithm. You can correct me later.

So I am still plugging away at MUD design, all by my lonesome self, and I've decided to hop a few pages in the design document to AI. So far, my hypothetical model features these four elements of /mob AI:

Desire
Perception
Deduction
Behavior

That's almost even a logical sequence, but not quite. Desire is plugged in by the creator. A /mob might have Peaceful Coexistence and Wealth with high values in both. Or, a /mob might not even have Peace as a desire (or Self-Preservation) but have Sport. That would -- surprise! -- probably be an orc. Sport without Peaceful Coexsistence and low Self-Preservation means the orc's desire for competition drives all the way into the realm of bloodlust. I'll have to make sure there is a small amount of Companionship desire in there somewhere, so the orcs don't kill each other too much. If we wanted orc rapists for whatever reason I guess they might also get a Sex desire. I think my games will do fine without the gratuitous sex violence, though.

Perception is based on "Awareness Flags" (AFs) which turn on and off depending on the /mob's knowledge of itself and its environment. Basic AFs would include things like Health, Inventory, Location, Local Obj. Some of these may actually cause behavior in the /mob immediately, but most of them will lead to processes called...

Deductions. This is where the /mob must further investigate what he is aware of. If another, unrecognized /mob walks into the room, the decuction will be to figure out all the characteristics of that /mob that are important. All of these characteristics are advanced AFs themselves. Does the orc spy a deer? Since a deer is an archetypal /mob, no deduction is necessary, and the orc's AI will immediately activate a flag that says "weak opponent" and "not orc". "not orc" would bring about the deduction "poor companion".

So, the orc would begin to engage some kind of behavior, according to its desires. I wonder what that would be in this case. So far, the idea is that every time a flag changes, that /mob's Desires and AFs are compared on some chart that links certain combinations with behavior. Whenever a behavior is found, it happens. Well, it's not quite that simple. There will have to be a logical ordering of behaviors. It wouldn't be good for a goblin to enter a room with both a chest of gold and a helpless merchant and attempt to both open the chest and attack the merchant at the same instant. That would be rather clumsy. Well, not on the goblin's part; he's quite the multi-tasker. [Edit: This is a good place to use your concept of 'acting on the highest priority per tick']

Anyone have any ideas or comments? The things I'm struggling to figure out are: how to handle the fact that each instance of a /mob has separate "knowledge", and what to do with a /mob's flags when the zone that /mob belongs to is unloaded. Obviously a game using this system would have to feature some kind of loading and unloading of /mobs or else things would become over-loaded very fast with all this flag checking and deducing going on.
-----------------
Of course nobody responded to this blog entry. It was way too detailed.

=$= Big J Money =$=

[Edited to reflect more specific thought]


Last edited by Big J Money on Wed Nov 30, 2005 9:53 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Author Message
BobTHJ



Joined: 19 Nov 2005
Posts: 31

PostPosted: Wed Nov 30, 2005 9:36 pm    Post subject: Reply with quote

I've been continuing to flesh out the goal-oriented AI system, and I'm making good progress. I like your concept of Behavior = Deduction(Desire + Preception). I think I am modeling all of these concepts in my goal-step system:

Each goal has a priority which equates to the mob's Desire to complete the task

Each goal can be affected by outside stimuli (Perception)

The mob weights out the difficulty of each goal step with the difficulty being adjusted by the mob's Perception (above) and the mob's memory and selects the least difficult option (Deduction)

The mob acts on it's selcted goal-step by sending commands to the parser (Behavior)

I think this system could model the behavior you desire. The goal steps will range in complexity from simpe "Move to room X" to highly complex "Find Love", "Find Entertainment".

To provide some variety between mobs (so every mob doesn't always select the same goal-step) I'm adding two other factors: personality and memory.

Each mob will have a personality based on one or more the four basic personality types (using the axis of Introvert/Extrovert and Dominant/Recessive). Each personality type will have different "traits" associated with it. Traits might be "Bossy", "Social Anxiety", "Abstract Thinking", etc. Mobs would be assigned a random sampling of traits based on their personality type. These traits would modify the difficulty score of a goal-step to make it more (or less) likely to be selected. For example, if a "Bossy" mob needed something in another room, it would be more likely to tell someone else to go get it for them that it would to go get the item itself. On the other hand, a mob with "Social Anxiety" would be more likely to retreive the item itself, possibly even taking a route that would allow it to avoid other people. These traits act as "filters" that every potential goal-step is run through to modify it's return score.

Also, each mob has a memory. The mob's memory will also adjust the difficulty return scores of the individual goal steps to increase the likelyhood of the mob choosing an action that will be effective. The example that we've already used several times in this thread the mob switching from Fire spells to Frost spells based on it's memory of the opponent resisting it's previous Fire spells. Another example of memory is a mob that offers to sell you an ancient artifact from place X because it has heard you talk about place X several times.
Back to top
View user's profile Send private message Send e-mail
Author Message
Big J Money



Joined: 30 Nov 2005
Posts: 2
Location: North Carolina

PostPosted: Wed Nov 30, 2005 10:20 pm    Post subject: Reply with quote

I didn't want my post to become too long with the blog entry, so I will add updated concepts here by editing this reply.

Allow me to clarify deductions for the moment, because they don't fit so easily into the equation. It's more like: Perception New = Deduction(Perception OldA + Perception OldB)

Eventually, however, you get to a Perception that sparks this equation: Behavior = (Desires + Final Perception)

This is still pretty sloppy, and I'll be back to update it later

---------------------
[Edit: I knew I'd be back in here, soon... 11/30 6:00 PM New text in Color]

Another thing we should probably add to the equation are Relations. You have already mentioned them; how a Mob might act differently based on faction relations, alingment, species, etc.

You might have Behavior = ((Desires + Relations) + Perceptions) OR Behavior = (Desires + Perceptions) + Relations, depending on how you choose to do it. The second equation seems more logical, but from a programming standpoint, I think the first equation might actually be more versatile; the key being that you can choose which desires invoke the relations modifier.

Peaceful Coexistence would be an example... A famous warrior might possess a high level of it toward a civilian, but his desire for peace with an orc could be nil... Companionship would be another... an orc might desire not to kill other orcs at first, because of the need to exist in a group, but that same desire would not factor concerning humans.

So, when Wealth is a factor in the behavior equation, you might have:

Behavior versus A = (Wealth Desire + Perception of A)

...but for Companionship it would be:

Behavior versus A = ((Companionship Desire + Relations to target) + Perception of A)

Truly, there should be two Relations modifiers: Macro and Micro. Macro would be things like factions, and Micro would be regarding specific NPCs and players. What I've listed above would be an example of Macro. However, you might want a player to be able to get on the "good side" or "bad side" of certain Mob groups or NPCs. If you're really snazzy, you might even want NPCs the ability to do the same thing, but that's another discussion. Anyway, the Micro Relations Modifier would somehow manage to find its way into all dealings. If a player managed to get on the good side of some orcs, they wouldn't want to kill him. They might even try and join him. How exactly you work the equation depends on your algorithm, of course. I think I might simply have it act as a modifier to 'Peaceful Coexistence' or 'Companionship', depending on the /mob. Maybe an orc would be a useful asset to a player, but a troll is a loner, and would simply leave the evil player in peace. The two bonuses might even stack: a neutral player might just be able to keep the orcs off his back by pleasing them, but an evil player would enjoy both a macro AND micro bonus after pleasing them; enough to get the orc to join him as a hench-man.

=$=
Back to top
View user's profile Send private message Send e-mail
Author Message
BobTHJ



Joined: 19 Nov 2005
Posts: 31

PostPosted: Thu Dec 01, 2005 6:37 pm    Post subject: Reply with quote

I've somewhat adapted the "Micro" relationship issue you discuss above into the mob memory system. When a mob encounters a PC (or another mob for that matter) they will take into account both the overall faction score of that character, and the overall "feeling" they have toward that character based on their memory (ie prior actions that the character has taken that the mob observed).

I also want to work out a system for close mob relationship ties. For example, if your character slays the mob Daddy Smith, the mobs Mommy Smith and Baby Smith will have a very strong hate toward your character. I'm not quite sure how to handle this as it doesn't fit well into the Faction system (I don't want to have a Smith Family faction for the 3 Smith mobs) or the Memory system (Mommy & Baby may not have been around to observe you slaying Daddy, so they wouldn't have a memory of it).
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    mudlab.org Forum Index -> Design All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2002 phpBB Group
BBTech Template by © 2003-04 MDesign