I originally intended to reply to the other AI thread, but somewhere along the line, I got distracted and forgotten about it. This is going to be a fairly long post, so bare with it....
I've work on 3 scheduling applications involving constraint programming, and I can tell you this, scripting AI sucks. Why? It is firstly hard to code, harder to debug and more often then not, the code is not portable.
AI at the simplest level means that based on a given input, do something with the input and produce an output.
This is practically what every electronic application does, just the scope in which we are talking about.
Most modern programming languages are not meant to deal with complicated logic sequences and for a good reason, because computers natively only understand two states, aka. your 0 and 1.
For most applications, that is more then sufficient, but when we want to model human logic, it is not.
A good example is this: Say you want to make a simple application to post a message on this board. We want it to make a post every Sunday.
The pseudo code will probably end up something like this:
if(DAY== Sunday)
{
MakePost();
}
Now, we want to make the program more intelligent. If it is Sunday, the program will make a post about sports if the program is started before noon, else it will make a post about a movie.
if(DAY==Sunday && TIME > NOON)
{
MakePost(Sports);
}
else if (DAY==Sunday && Time <= NOON)
{
MakePost(Movie);
}
Now, we want to extend it even further, it will make a reply, instead of making a new post if an existing post about the topic is available.
if(DAY==Sunday && TIME > NOON)
{
if (post(Sports).exist())
{
MakeReply(Sports);
}
else
{
MakePost(Sports);
}
}
else if (DAY==Sunday && Time <= NOON)
{
if (post(Movie).exist())
{
MakeReply(Movie);
}
else
{
MakePost(Movie);
}
}
At this point of time, look at how ugly and bloated the code is. We are only dealing with 3 choices, check if the day is Sunday, then if the time is before or afternoon and lastly, if a post exist or not.
This mess of code is practically unique to this example, you can’t really rewrite it into a class or function and reapply it to another program. As stated earlier, a computer at its base compares only 2 states, on or off. With so many if-else/switch case/whatever needed to perform the scripted logic, a lot of time is spend by the computer just in navigating down to the proper route to execute.
This is a big reason why MMORPGs and such have little to no intelligence for their mobs. Behavior differences between a level 1 and an uber mob are usually very little. If it take an extra 0.01 sec for a mob to navigate down to the proper action, on a server with 1000 people will mean an extra 10 sec of computing time is ate up. A switch/case base on total hate is much easier to implement, and less taxing on the computation requirements.
Most commercially available optimized AI engines cost so much due to amount of development effort needed to produce it, and using those engines for games are not really economically viable and even then, they are slow compare to the other processes going on in a game.
I’ve use ILOG Solver before for one of the applications, and it took the engine a good 50mins to work out a schedule involving just 20 people, with difference constraints. Eg. Person A cannot work on Monday, B can only work from 9am to 10am etc…….
Next, there’s a fine line between Artificial Intelligence and what I call Cheating Intelligence.
Decision made by a computer comes from certain inputs, but how and what are these inputs?
Basing on the previous thread, where Don talk about the cleric killing script:
1. Determine every person who can heal.
2. Sort heal effectiveness in descending order (guy who can heal the most at top) by class (i.e. all clerics are considered the same).
3. Kill a random person with highest healing effectiveness. (this is assumed to always be possible. If not the boss is not capable of winning against the players to begin with, and any AI is futile).
4. Repeat until no more peole can heal, then add all the people who can resurrect (in case some people can resurrect but cannot heal) and repeat 1-3. After that the AI is free to do whatever it wants.
How is the mob going to determine who can heal? By “observing” the player or simply calling the function look_up_player_class()?
If the mob is going to “observe” the player, how is the mob going about to “observe” the player?
Remember, a computer is a non-living thing, it will and would also do the same thing, given that conditions are the same. If you spoon feed it data, it will always use that data and do the same predicted output. If you implement a sequence for “observing”, it will always execute it in that particular order. Not to mention, doing either of these once again eats up computation time.
Computers are not meant to be “random”. Most random function involves getting the .0001 sec of the computer’s time or use a seeding table to achieve random numbers.
I learn this the hard way in one of the applications I write that schedule production timing.
No matter what quantity of steel needs to be produce, steel will always be scheduled to be produce in night, because steel production has the lowest priority. Even if there is nothing being produce in the afternoon, steel will still take the night slots.
In order to make computer “random” they have to learn.
Most of you should know about Neural Networks or pseudo learning such as Fuzzy Logic.
Fuzzy logic is basically asking a bunch of “ifs” and from there, conclude a result and stick with it.
Neural Networks are basically a bunch of artificial neurons link together. Each artificial neuron takes in one or more input and produce out exactly 1 output. They are then link together and over time, some neurons will “die” off, some get replace, etc.
Using Don’s example again, we can break it down to find class, sort heal efficiency, kill.
Layout will probably be something like this.
Player info - Find class – Sort class – Sort heal efficiency – Kill
Say there are only 3 players, Alice (cleric), Bob (warrior) and Charlie (paladin).
The possible routes identify by the computer might be:
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Alice)
The computer first try to kill Alice, but Charlie manage to keep her alive. At next AI refreshment, computer reanalyze situation.
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Alice)
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Charlie)
Computer takes route 2, and attacks Charlie.
Computer fails again, next AI refreshment:
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Alice)
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Charlie)
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Bob)
Computer takes route 3, attacks Bob
Computer fails, next AI refreshment:
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Alice)
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Charlie)
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Bob)
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Alice then Charlie)
In this example here, Kill Alice then Charlie means the computer attacks Alice for a bit, then attacks Charlie
Computer takes route 4, moderate success, next AI refreshment
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Alice)
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Charlie)
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Bob)
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Alice then Charlie)
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Alice 10% then Charlie 90%)
Computer takes route 5, some success, next AI refreshment
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Alice then Charlie)
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Alice 10% then Charlie 90%)
Player info(Alice, Bob, Charlie) - Find class (Cleric, Warrior, Paladin) - Sort heal efficiency – (Cleric, Paladin, Warrior) – Kill (Alice 20% then Charlie 80%)
Computer discard route 1 to 3 because of no apparent success. Tries etc…..
Note, this is a VERY simplistic look at neural networks. In reality, it is much more complicated especially the decay and reinforcement of routes.
Now that I cover most of what AI is, I have to say that what Lucas is looking at is not really on AI Behavior, but more on event scripting. I.E the ability for a game to response to on going events. You guys on the other hand are looking at AI Behavior…..