One of my biggest peeves on any game is bad monster/NPC ai. I hate being able to go into a room on most muds, kill a guard, and have four other guards stand around and look at me, saying \'hi\' and silly things like that.
So, in this thread, I\'ll discuss pros/cons/caveats of npc AI, potential methods for achieving a decent level of intelligence within the system, and means for achieving the goal.
While more or less a novice programmer (programming in LPC for a mudlib I wrote) I have studied extensively on various AI methods, from genetic programming to neural networks. In addition, I have a fairly decent background in psychological phenomena, (emergent phenomena versus inherent) and motivation/thought processes.
I tried this post once before, so I\'m trying again. Here are the things that I feel are vital for a good A.I. These will be broken down in either subsequent postings, or this posting itself, and potentially I will offer some observations/ideas for creating the systems themselves, should anyone be interested, though I\'d prefer to do that via private message.
1: Responsiveness.
2: Planning
3: Motivation
4: Pathfinding
5: Entropy
The first point was raised in the introduction to this paragraph. Nonresponsive NPCs, that don\'t respond to outside events. The simplest of the responsive NPCs I\'ve programmed rely on catching events in the surroundings, and simple pattern matching (via regexp or sscanf) similar to how I imagine the query functions for Planeshift NPCs work. This is ok to a point, but usually there is little that actually can be programmed this way, and it can only respond to things within the devisor\'s programming.
2: Planning.
A sticking point for 99% of AI everywhere I\'ve seen. Rather than sending in an overwhelming mob, most AI allows defeat in detail, due to poor planning/terrain control/pathfinding. Planning is one of the most complex systems within A.I, as it has to determine the current \'state\' of the system, then interpolate how to get from point A to point B. This is one of the things that I have been working hardest on in my own work. It comes down to a problem of both semantics and conceptualization. Often things that can be conceptualized cannot be brought into words, and vs/vs. Semantics often don\'t translate into concepts via noise in the communication, as well. In addition, our current understanding of though processes themselves is lacking. This can actually be either moved to its own forum, or perhaps worked through in private message, as it\'s a fascinating field for me. More or less, to sum this up, it\'s not a problem of getting from point A to point B, it\'s a problem of the sequence of steps from point B to backwards chain to point A. Probably most of this could be accomplished by creating binary trees for object locations, and treating objects as attachments to nodal points on the trees using a weighted djikstra algorithm to allow for planning for the best means of getting there.
3: Motivation
The motivation of the A.I. can\'t be understated either. The simplest motivation system is a simple bit, that says \'this monster is aggressive\' or turned off, not so. A more complex version might say that \'this monster is aggressive to \'. A far more complex version might be \'this monster is aggressive to unless is present, and when the time is .\" the one I\'m after, and have been working on, actually allows the creature itself to learn, to some extent. This would be an excellent place to attempt to test the conceptualization and attempt implementation, really, of the idea.
I.e. Monster behaves in way towards when the emotion flags read with a 45% entropic modification, because he is insane. However, with approach is done, modifies its behavior.
Motivation is complex, and can be accomplished several different ways. In \'the sims\', not to bring up a relatively pointless product, but to illustrate a point, they have happiness/sadness/etc indicators, which help determine the personality. Using these as a seed for the algorithm, as nearly as I can tell it can modify the values directly. To speed this problem up, binary trees could definitely be used, or perhaps hashes. really hard to tell what would be most efficient in this instance. (I know the simple multiple array one of my friends was using is very inefficient for it, especially in an interpreted (bytecode) language).
A modification of this could actually be fear, interest, or even, should you go so far, desire, jealously, and lust.
4: pathfinding.
Extremely annoying is the fact that monsters aren\'t bright enough to *not* walk off cliffs/platforms, and then disappear off the map. *chuckles* Simplest way to do this, is to create a set of nodes throughout yklaum, in the main pathway areas, and safe traversal areas. This could be done in the database, likely with xy coordinates, and a node connected by a pathway at each point. This pathway could be modified in a number of ways for the conditions, which means that it could be extremely flexible. Using djikstra, you can calculate any given path, and get the set of all paths between all points (a lengthy calculation given the potential number of nodes, just in the city) But the best part of this is, you can cache the results, use the nodal set as a container class, then move objects between nodal areas, or even between active nodes. The paths could be complicated greatly by simply setting up a certain amount of randomness in the paths of the nodes, and a certain amount of deviation from the node path, itself. (i.e. an algorithm designed to allow the NPC to \'wander\' between certain guidelines)
5:entropy
Discussed in several of these points, the inherent randomness of the system. It allows NPCs to do more realistic behaviours by not following rigidly set paths. And allowing them to make \'bad\' decisions.
6: cooperation
This one is a fun one... you see a single gobble out in the middle of the sewers.. then all the sudden you\'re ambushed by them all. Or you kill someone in city limits, and the guards seal the exits, and start a search through the city, only allowing others to escape.. but perhaps there\'s a secret exit in one of the labyrinth paths....
Many ways to set up cooperation, the simplest is with just messaging between NPC objects, with a \'master\' object coordinating it. I.e. the \'leader\'. Recognize and kill the leader, and they become a rabble, and much easier to eliminate.
However, sometimes the leader isn\'t what they seem...
Any and all points in this can be discussed at length. And examples given of potential code to accomplish some of it. A lot of what I\'m thinking of may involve caching results from background computations, and recombining it with others, creating a viable path, which will accellerate things substantially. (cached data being far faster than recalculating the dataset). At that point, it mostly involves adding nodal points into the mapping. The biggest caveat of this system is simply that it grows very complex, and the complexity grows exponentially, though the computation may not have to, using djikstra. Part of it involves testing with genetic algorithms, part involves caching, and part involves psychological phenomena.
Considerably more than .02 tria...
Lyistra.