Advertisement

AI for RPGs

Started by November 17, 2002 03:12 AM
27 comments, last by Vendayan 21 years, 11 months ago
It amazes me sometimes that the AI for RPG''s is so extremely limited. Perhaps I should start with a couple of examples. First Everquest. For one because just about every RPG player has played it or at least read/heard alot about it in detail. The AI in this game is very simple. An NPC has a radius around it in which it picks up events of a character/NPC moving in close. When one does move inside that radius it checks to see if it can see the subject, invisibility and line of sight are the only things I believe it considers. After it ''sees'' a target it checks as to whether or not it will attack depending on the ''faction'' system. If so the NPC closes for the kill until it gets too badly hurt and then runs. This is what we are wasting our money on!? On a better note there is Morrowind. This game has no better of a system, except for roleplaying. An NPC might in morrowing notice that a player is wearing very high quality clothing and offer a compliment. An NPC will also call for the guards if the player would be so bold as to try to sell an item to him that he stole of the merchants shelf. Although I''ve been dissapointed at times to find that I could be on the brink of death and while standing right next to a cleric whose life I had saved in a quest would sit and stare at me while I bled to death, even while he had many powerful healing spells and full mana. I would love to be part of a team that would actually take things such as this into consideration. Where every time an NPC acknowledges the presence of another player/NPC he would check a list of attributtes to that player and act on them accordingly. For instance consider the follwing scenario... Two NPC guards are walking a predefined path along the top of a castle wall. Both guards are equiped with a shield a crossbow and a longsword. The guards also know that if anything goes terribly wrong to run to the castle wizard (this would be a short script to make the gaurd ''persue'' then put the wizard in a ''catious'' state and have the wizard ''follow guard'' while the guard will ''pursue'' the threat). The guards then during their partol see an intruder climbing the walls. If this scenario happened in everquest the AI would respond like this... If the Target''s level is too much higher than mine, Ignore the threat until it attacks me. Otherwise walk in blindly with the sword (because its in my hand at the time) and fight until im down to 20% health, in which case I run straight away from the intruder, or until one of us dies. This can be done much better using a bit more event driving. I would have the NPCs first consider the opponent a bit better. They would come to a rating of some sort of the amount of threat the target seems to be judging by his appearance. An orc has moderately intimidating appearance and reputation as a race. So we will take that factor and later apply it in some way to the assessment of this individual orc. Judging by the individual orcs appearance by what it''s holding and wearing it seems to be a scout as opposed to a spell caster. So that''s average, but this orc though has another factor to consider. It has a pegged leg. This affects not only the ''fearsomeness'' of the orc but also it general speed/mobility factor, which our guards might consider if they have to run for the wizard. Given the scenario the guards decide that they might easily be able to handle this orc themselves. Of course periodically the guards will need to reconsider thier course of action. Especially when this orc turns out to be an experienced assasin and manages to take off the arm of one of the guards and then turns on the other quickly wearing him down. In everquest... the guard who had his arm taken is considered to be in critical condition so he turns and runs, although the other who is unhurt stands stupidly and continues to attack without considering his own fate or the possibe fate of his friend, who with the AI in everquest would now be being chased by an orc who blindly turned his back on the healthy guard to chase the wounded one. Another solution could be to decided that since both guards are from the same faction and fighting a common enemy that they would be good candidates to form a group to combat this orc. In group AI the NPC''s will react to events that affect their group members. When the one guard loses his arm and turns, the other who is healthy considers running as well, but instead decides to cover him by setting his movement action status to ''cover'' and keep his action status on ''attack''. Ok, now I''m not saying that this how it SHOULD be done, but just saying what I would like to see. If anyone else has any other good ideas or input throw in your 2 cents. ~Vendayan
"Never have a battle of wits with an unarmed man. He will surely attempt to disarm you as well"~Vendayan
That sounds great. I think that games should be more realistic,
some people think that making games more realistic ruins them.

But what would of hapned if, for example, when solid snake surprised the guards they ran away, or shot you. this is in no way as fun as skaring them, which is more realistic.

These ideas are very good. I am hoping to,when i become better at programming, make an completly free roaming RPG/Adventure, and ideas like that would make it sooooooooo better.

The game is going to be big, very big (map wise)
You should listen to me, im 'Special'.Or so my physiatrist said.
Advertisement
You can''t expect, at least for the moment, an AI as evoluted for a MMORPG than the ones you canget for a classic RPG. For Everquest - particularly Everquest as it''s one of the only recent MMORPG that doesn''t use a ''visibility'' system to activate mobs only when there is a player character in a certain range of them -, the servers have a huge load of work even with the simple monster behaviour system used. And that "simple" behaviour is far from being as simplist as you describe it, with some mobs being "social" for instance, with rather complex rules on wich player or NPC to attack when a mob is attacked by several players - and possibly NPCs - at once, with features added with the kuniark extension - particularly an enhancement of the "hate list transmission" to other mobs -, with mobs casting spells not randomly (healer mobs will heal other friendly mobs when they get low on health, not just themselves, they will be more likely to root a player if the player runs from them than if the player fights them, etc...).

I agree though that there is no real AI in Everquest (and even less in the other MMORPGS) and that these features are implemented in the simplest possible way, but a complex AI is not something possible on servers having such a huge amount of data to control. To counterweight the lack of AI, MMORPGS usually make mobs stronger than same level characters.

For classic RPGs, Baldur''s Gate 2 and Arcanum have a much more interesting AI than Morrowind''s one, wich is pretty limited. But a very evoluted "general" behaviour AI is something very hard to create. By general I mean an AI that would not be using a script to tell a guard that if an ennemy is close he must go warn the wizard. Using scripts means that when creating the world (wich is usually very huge), there is a heavy work to do to add these scripts. An AI that lets a guard figure out by himself that he could go warn the wizard of the castle (if the castle has a wizard) when the threat looks dangerous, or just go fight by himself when the threat looks easy to handle, is much more complicated to implement, as to be able to add a feature like this, you will have to add many similar features for many other situations (a group of bandit would post by themselves some sentries on the path to their camp, they also would leave their camp regularly to make ambushes on a road, etc... the possibilities are endless and that is actually the problem.. ).

Using scripts (like it''s done actually in many RPGs), or int he case of MMORPG creating GM controlled events or dynamic world changes (Asheron''s Call and some others) allows to occasionally create complex behaviours. Of course, the annoying word here is "occasionally". But it''s still the easiest way to create as complex behaviours as you might wish.

David Antonini.
David Antonini.
Just thought I''d throw in my 2 bits here =)

AI is a tough bugger to tackle for the reasons David already stated. (BTW David you seem to have analyzied the crap out of MMRPGS. Nice.) I''m wrestling with this beast myself atm in my RPG game design. I expect it will require the most fiddling out of all my engines, but basically it boils down to sacrificing performance for realism.

An excellent lesson in scripting can be had by purchasing Neverwinter nights. Design yourself a basic landmass and then try scripting in a single NPC. Now start scripting some various behaviours for him.. some timers, some reactions, some area triggers, some PC triggers.... Now add a couple wandering gaurds.. I personally guarantee you if you''ve written any kind of decent script for 3 NPCs they will noticeably bog down your server =)

It all boils down to processor cycles. In the games of Asheron''s Call and Everquest there are actually many servers per world. (I believe EQ is over 30 per now but thats old data) Even with say 30 servers hosting a mere 2000 players, thats nothing compared to all of the NPC AI work and scripting thats bogging them down. And dont get me wrong Im with you on the fact that it was a pretty sucky AI. Worse than sucky it took them 2 years to even get it into the "playable" category visavi line of sight bugs, Z-axis screw ups etc. So whats the answer?

If my mob hears a sound does he cast camoflauge on himself and scout you out? What triggered the sound? what abotu the range check to see if the mob heard the sound? What about the faction check to see if the mob was in a "friendly" are and does he even care about the sound? What about the skill checks to see if he has detected my stealth? what about the AI check to see if he''s a chicken and calls for backup before investigating? What about his buff status? should he self buff before he investigates? should he go back to the shaman and request buffs? Should he light a signal fire to trigger an alarm? Should he run screaming like a child?

Now multiply all those variables by the number of active mobs on any given server... so lets say 5,000. I think you see where this is going =)

You could be running a whole warehouse full of Xeon clusters before you get the juice to drive those kinds of scripts. And the bottom line is people wont pay for it. I''ve done the market research and I know what I can charge. $15 is doable $20/mnth is going to seriously cut into your player base.. but then again is that such a bad Idea?

When UO came out 6 years ago chargin 10 bucks a month for a game I laughed. Then I watched as hundreds of thousands of people flocked to it. The bandwidth consumption of UO was on a scale never seen on the internet before and the $10 bucks covered bandwidth and made a few people exceedingly filthy rich. (Ever notice that origin stopped producing games ever since UO? Even before EA got involved they had more than they could chew ) Now every 12 year old with a gateway computer has broadband internet access and demands the absolute best from On-line games. The lag and latency that was tolerated on UO and written off as modem problems is absolutely unacceptable to the up and coming online gamers of tomorrow. They want latency free, lag free, feature packed titles with wicked action and short term gratification with promises of long term epic confrontations. In short they want the universe and they want it delivered in a neat little box at a cost of $10 a month. Ouch

Since Im currently rewritting my scripting for AI I believe I can safely say that even the simplest AI/NPC response has a lot more going on behind it than you might imaging. Even my agro mangement scripts go on for half a page. If faction=friendly { share agrolist} (if new.ally.level => (agrolist.average.lvl) add 50 to NPC.morale. Goto Morale.check goto cast.check goto etcetc.

I agree its a poor way of handling AI and believe me I''m all for beating up gaming companies about it but bottom line is the alternative isnt pretty. LAgged to hell servers or 25$ a month gaming fees to support that warehouse of Xeon clusters =)

Good article though a lot of people are jsut content with it. Im with you. Push the envelope and see what happens.

Mark

Mark MacPherson
Flybynight Studios: Owner
Current Skillsets: Project Manager - Team Lead - Scripter - 2D Artwork - Basic 3D Modeller - Web Development - Marketing - Administration

In My Opion the way of hanleing the ai problem is to create a sepreate client for the ai that runs off of scripts and stuff but is still integrated into the server program (located on a seaperate computer on the local network of the server)

this releveves the burdon of the server haveing to deal with all the scripts and incresses the power of the ai. along with that you could add a chat bot like thing and a have it linked to a event list and gossip channel for say of globle events that would pass as rumers.

the only ai in this type of system that need to have a chat profile running are the ones that have a signle from the sever that an player is near by then you have the ai go abouts it life and boom you have an smart ai

all the simple none humam like ai run off of the server.
Im going to extrapolate this idea of AI servers and see where it goes. Honestly I hadn''t concidered it but then again im a traffic efficiency analyst so Im a little retentive about anything that increases network overhead =)

So you have a server farm running global world funcitons including various databases full of info.. Then you have a guard strolling around a rampart somewhere and all the server knows is NPC xyz is travelling X dir at X speed..

Meanwhile back at the ranch... err I mean AI server.

AI script #guard3265 is checking the server to see when guard3265 actually gets to point Y so it can tell him to turn to direction Z and let out a yawn. So now what we having is polling of the databases on a more constant basis with another latency hop to contend with. Even if its a local latency issue and delt with on gigabit backbone you are still hammering the server with inforequests from it''s database. I personally feel this would be almost as bad as processor cycle latency. The polling will be a constant traffic hammer on your server drawing on your bandwidth handling capabilities which in turn produce client lag. May as well just let the server handle the scripting and throw as much power into it as you can.

I am not one to speak on this though because I truely don''t know all of the alternate ways to get the databases to mesh between server and AI server. Maybe there is some completely simple answer I am overlooking?

Mark




Mark MacPherson
Flybynight Studios: Owner
Current Skillsets: Project Manager - Team Lead - Scripter - 2D Artwork - Basic 3D Modeller - Web Development - Marketing - Administration

Advertisement
Just as a followup to my post above, really what you have to remember is that even our most fantastic efforts as programmers are going to fall terribly short at reproducing a decent AI in a MMOLG. Now when you concider that most peoples focus in the game is to find stuff, kill it, loot it and sell the treasure a wicked AI that consumes the kinds of server resources we are talkign about all the sudden becomes unnecessary. What players DO want however is the ability to interact in some form with the game at a human level. This is where live event teams will become an essential part of ANY successful game of the future.

Mindless killing of bats for hours on end is enough to make anyone hate a game, but what about a game that makes sense? Why kill bats? sure they are there, but what about giving players goals? What about an AI for a city that is more of a general AI? What about a city that is leaning towards war with a neighbouring tribe of orcs? What about events and quests that can be done in that city to drag the AI more towards war or more towards peace? What about an AI that once a city has declared war on the Orcs would respond by doubling the spawn at the orc village, spawning a boss mob and sending waves of attackers every 30 minutes against the city walls. Now THAT is an AI that could be done on an AI server. No constant polling needed, more general AI actions and reactions, IE after a certain lvl of anger towards the orcs is reached, orc warparties are increased in difficulty in spawn areas a-f and quests s through z now become available. Maybe vendors start paying premiums for Orc hides/trophies etc.

Thats an AI that I can see taking off. Put an AI like that in place with a Live events team of 3-5 people per server spawning Boss mobs, live questing events and suddenly the AI doesnt seem like such a huge issue.

Maybe thats just me though

Mark

Mark MacPherson
Flybynight Studios: Owner
Current Skillsets: Project Manager - Team Lead - Scripter - 2D Artwork - Basic 3D Modeller - Web Development - Marketing - Administration

What you''re suggesting there Slyxsith is a God-type AI, which is certainly more appropriate for MMORPGs than single mobs with intelligence.

The average life expectancy of a mob in a game like Everquest is measured in seconds. Why build lots of great AI into a mob that is only going to get killed very quickly. To make it harder to kill? There are other ways to make it harder kill. To make it more interesting? Certainly it would be more interesting if your opponent kept reacting to your attack strategies and foiling you, but this can be more efficiently handled at the God-level AI.

Let''s consider our entrepid party venturing into the Caves of Doom, which happens to be the current residence of Ogrok the Goblin Lord. Now each goblin that Ogrok sends to kill the party doesn''t have to be intelligent. However, if Ogrok were to lure the players into an ambush and slaughter them, now THAT would be interesting. Even more so if when next our stupid, er entrepid, heroes venture into the Caves of Doom, Ogrok uses a different strategy to slay them and adds their loot to his hoard!

This sort or AI is definitely within the reach of current hardware capabilities. All it would take is a committment from a game company to pay for the development of the dynamic strategy engine. Tantalus (here in Oz) is funding such an engine, but not for online games and not for RPGs... at least, not yet. Hopefully we''ll see this idea in the market within the next two to three years.

Cheers,

Timkin
The Ai Sever thingy sounds intresting but it would probly have some massive drawbacks but i cant think of anything. I came up with the idea and just decided to tossed it around. it seemed like a greate idea for citybased ai that would interact with players more then say hello. and the drag on the sever would probly still equal to or less then that of a normal player as far as i can see it would be just like connecting a botted player to speacial local port on the server.
0))))))>|FritzMar>
My technical knowledge aren''t very good so I might be saying somethign stupid, but I think that what you mentionned is actually the problem, with an AI server, Fritzmar.. in EQ for instance, the servers can''t handle more than 3000 players connected at the same time because of bandwidth problems. But it constantly handles 30 000+ NPCs without problem and could deal with much more as each extension adds a lot of new NPCs to the world (I think they actually use one physical server per zone, though, and each zone contains usually less than 150 players and roughly 1000 NPCs.. I think there are different servers for each zone). If the NPC AI was dealt with on a separate machine and considered by main servers as Bot-players, thus taking some bandwidth, I think it would in fact increase a lot the load of the main servers.
About the activation radius (like in Anarchy Online and Asheron''s Call, and maybe Dark age of camelot), as far as I know the mob AI is dealt with by the server. When there are no players within activation range, the mob AI is just limited to checking for the arrival of a player within activation range. This is a very useful method to limit the server load related to NPCs behaviour, but it has the drawback of sometimes making mobs "appear" out of nowhere because of internet latency, i.e the server detects that the player is in activation range of the mob when the client has already moved the player much closer to the mob than the visual range limit.
I quite agree with Timkin that god mobs (bosses) could have a much more complex AI though.
Actually this already partly exists in Everquest (and probably in some other games, but I didn''t explore them enough to figure it out). With Vellious, Verant industries added some complex scripts to EQ, usually related to quests. For instance a quest involves a war between the dwarves and the giants, with many mobs spawning all of a sudden and starting fighting each other. I don''t remember the exact details, but I think if the players manage to kill all the giants, then the dwarf king offers a reward to one of the players who got an item out of one of the giants, and otherwise after some time all the dwarves within the dwarf city vanish all of a sudden.
Many similar scripts were added (a sleeping ethereal dragon called "the sleeper" can be awaken once per server, and he starts killing every dragon related creatures in the zone, then despawns, respawn in another zone and keeps killing creatures there, etc.. the script going on for over half an hour; a quest involves telling a giant "we have to attack" and then following a small squad of 4 or 5 giants to a faery village, to watch them fight the faeries, then to watch them get killed as some very high level faeries spawn to protect the village, and then to go back see the giant who had given you this quest, wich will now have different sentences to tell you, etc..).
When creating Everquest, verant hadn''t put anything that sophisticated as they thought that the possibility of having "GM events" (i.e interactive events in wich some people of Verant staff play the role of creatures and control them just like a player would do) would be enough. But of course with the number of servers and players and the hugeness of the world, this solution was not good as most players would never see a GM driven event during all their gameplay.
We''re still far from complex behaviour AI though. It''s just pretty simple scripts . Let''s hope we can see better than that in top commercial RPGS in the future.
Stil the main point is that any attempt at sophisticated AI in MMORPGs will have to be local, given the actual hardware possibilities and the performances/prices that players expect. I think that regular RPGs can for sure have a much much better general AI though. Morrowind is a perfect example of a game giving too much attention to graphism performances (just like Daggerfall was, though they at least renounced to the dull idea of randomly generated surroundings..).
About AI in commercial games in general, I must say I am really impressed by the progress there has been the last few years in soccer and other collective sports simulations (EA fifa 2002 and 2003 seem very impressive to me). Wargames and strategy games probably progressed a lot too, but I haven''t tested any lately.

David Antonini
David Antonini.

This topic is closed to new replies.

Advertisement