Giving birth to AI

Miscellaneous Forums/General Discussion/Giving birth to AI

Has anyone here ever coded a really complex AI? So complex that you can't really tell beforehand how it's gonna behave. What were your feelings when you first started it?

I have coded AI for my game for the last couple of weeks. Had to write more than 1000 lines of code before I could even test it. Last night I was finally able to run it for the first time and had strange feelings about it. Kind of like giving birth to child. Or like I'm Dr. Frankenstein and I'm jumpstarting my monster.

The AI's first steps were pitiful to look at. It was stumbling around and not doing what it was supposed to. Buggy code, bad parameters. Definitely his fathers child. :) But there was still something good there too. Few positive suprises.

The monster needs a brain surgery, but fortunately not a brain replacement. Can't wait to get to it again. Oh, why do I have to have a day job...

I must be loosing it.

My Zombie game had about 100 AI states by the time my brain started bleeding and that was pretty cool watching humans shooting zombies and having their own battles with no intervention from the player.

What was cool was when a guy with a gun got killed by a zombie and another guy took the gun from his dead hand and starting shooting the zombies with it... Nice touch I thought!

@Rob
Is there some demo of that game..I would like to see that if possible(regarding AI you mentioned)

the AI in my racer was probably only about 70 lines. I believe simple is better, and does not necesarily give simple results.

It depends on what you are doing though. IMO, fuzzy logic gives better humanised results in AI.

Not taking anything away from what you've said or done Cygnus, but race logic is generally much simpler as there aren't too many things you do, it's pretty much all go round the track as fast as possible avoiding other people. If you're too not facing the right direction the turn that way, if it's over a certain angle then hit the brakes too.. etc.

Mine had stuff like if you see a zombie and you've got a gun shoot at it until it gets too close then leg it...
If you see another human then meet up with them and clump together, especially if one of clump has a gun...
On top of that the map was completely free form and they found routes to move around it on the fly.
That said, a lot of the states were things like, "find new place to head for" which then switched straight to a "go to location"... anyway... AI is a lot of fun to program!

I find AI does better if its given rules that the player has to abide by, this makes for a more harder to beat AI :)

I always make my AI routines emulate the controller, so instead of reading from keys / mouse / controller it reads from the AI routine.

I'm reading a coding book that says to do that, not quite sure how though, would it be something like:

if players=2 then
readinput_player2()
else
readintput_AI()
endif

Yeah pretty much, basically I just have variables that handle the control so you end up with a bunch of axis' which have been set by your function.

x axis (-1 to 1) , y axis (-1 to 1)
firebutton 1, firebutton 2 etc etc

Then you just control your player or non player based on these values.


Not taking anything away from what you've said or done Cygnus, but race logic is generally much simpler as there aren't too many things you do, it's pretty much all go round the track as fast as possible avoiding other people. If you're too not facing the right direction the turn that way, if it's over a certain angle then hit the brakes too.. etc.


Oh of course, and this goes without saying really. even with player AI the hardest part should be the pathfinding though- over complex AI code introduces bugs, simple fuzy logic *can* be used to introduce variabilities that can seem like himan judgement (they are technically bugs too.)
Racing AI is a speciality of mine- FPS AI? i can do the character stuff, but i fall short at pathfinding hehe.


I find AI does better if its given rules that the player has to abide by, this makes for a more harder to beat AI :)



Thas how the racing AI worked too, 75 lines deciding where to turn, if a collision was imminent etc, and set the gas, brake pedal, steering wheel and hand break according to what was returned... the function called the same routine that the human control function called.

updatecar(Car), where car was a class that had gas,brake, handbreak, and steer members.

Simple AI logic works best for games with simple game logic (racing games, for example, where you simply follow the track).

But more often than not, you need complex AI code for a game with complex game logic. In almost any game, there's a point where you get used to the AI and know all it's moves and how it reacts, at which point playing against it isn't really that fun any more. Without some complexity in the AI's decision making process, playing against it will become boring very quickly.

Complex code certainly can introduce bugs if you're not careful, but if you're worried about bug introduced by complex code you shouldn't be making games at all :)

Then you just control your player or non player based on these values.

Definitely, your AI's should always have the same control functions as your player if possible.

I would rather ask an other question even though it is not certainly the first time that this kind of question has been arisen

Ok someone use 100 FSM in is game
Fine , but FSM'S are , up to a certain extent ,a matter of common sense
Everybody has probably used a rough FSM in his game development , maybe, without realizing it

What about sophisticated AI ?
Neural, genetic, learning..

Is complex AI of real use ?

I haven't done much AI programming yet but I'm sure it's in the future ... I would have to agree up front that if you want the behavior to look intelligent it's going to have to do more than make really obvious decisions for really obvious reasons, it's got to have an `intent` and a range of abilities or ways in which it can achieve that, rather than just one.

With the car AI- it didnt work on path (well, a path was introduced later for sanity..) The car AI was able to race competetively without nodes or knowing where it needed to go, i coded it to "see" the track edges. It would quite hapily drive around the track and obstacles using this information- the path points were used to ensure they knew they were going backwards but even that could have been avoided.

Unlike most games I never coded anything to do with pits- if a car ended up "off track" its sight code would guide it out of its situation.

I would actually code my human AI the same, No pathfinding unless really required, Sight of the level and walls, and line of target for the player. "decision making" AI is simply flags, part of a really imple FSM.

The art of AI is the art of convincing the human player that the AI is clever.

The path and method of the logic is irrelevant - the end result is the conclusion of the assumption of everything that didn't happen.

What about sophisticated AI ?
Neural, genetic, learning..
They're still Finite State Machines. They just have many, many states. A heuristic neural network is probably overkill, because it will take you ages to teach the game how to win effectively. In short they're only practical for games like Chess (or OCR and SPAM filtering).

A collection of expert systems, with each expert system handling different states in an FSM, seems to provide a pretty good balance - in situations were states are fairly abstractly defined (ie. defending, assaulting, covering fire, retreating, patrolling, etc.) and the available information (input parameters) isn't overwhelming, seems to work quite well.

Is complex AI of real use ?
Depends on what you mean by "complex". Is good AI of real use? Yes, and the simpler (that is the more data-oriented) they are, the better (which is why expert systems are a fairly good compromise). In many cases tho' a dumb AI, careful scripting and triggering is all you'll really need. Like the others have mentioned the choice of which "enemy strategy" to use also depends heavily on the type of game.

Thanks , it is also my opinion
The point is that, in my (right or wrong) opinion FSM and expert systems are a sort of coding style rather than real AI
What's the theoretical background supporting FSN and expert system ?
All of us have been using FSM and expert system in our games, may be in a rough way , without realizing it

Real AI would be called intelligence rather than artificial intelligence. ;-)

>Is complex AI of real use ?

First you need to define 'AI', then define 'Complex AI'.

AI is a wonderful subject for study and experimentation, but the computing power or concepts aren't really there yet. Just because you use an artificial neural network, it doesn't automatically make your game better. Often, an FSM is the better way to go.

>The point is that, in my (right or wrong) opinion FSM and
>expert systems are a sort of coding style rather than real
>AI

Please explain...

At it's simplest, a FSM is just a bunch of IF...Then statements. Expert systems use a lot of those statements, and can utilize an FSM to enterpret the rules derived from research, but the greater emphasis is generally on knowledge gathering(ask the experts) and representation(rules).

>What's the theoretical background supporting FSN and
>expert system ?

Google is your friend.

>All of us have been using FSM and expert system in our
>games, may be in a rough way , without realizing it

Most use FSM's, but I doubt that bedroom coders routinely use expert systems.

First you need to define 'AI',

Why should I first define AI ?
It is a well known term

then define 'Complex AI'.

Why should I waste time ?
Neurals, for example, are based on complex algo's
FSM is just a matter of common sense

Actually neural network AI is extremely simple in operation (as opposed to a large FSM, for example, which contains pages and pages of hard-coded logic).

I would define "Complex AI" in a game programming context as artificial intelligence that has enough programmed variety to surprising the player with new tactics, etc. for a considerable amount of time (at which point the user has "figured out" the AI and can predict it's actions), regardless of the implementation used (state machines, neural networks, fuzzy logic, etc.)

From a programming point of view, yes, but not for sure from a math point of view
The algo to define the weights of the a neural network is quite complex and it is far away from being intuitive
FSM on the contrary is matter of common sense

Why should I first define AI ?
It is a well known term
Yes, but it is not a well defined term. It is "a field of research concerned with the study and design of intelligent agents".

Neurals, for example, are based on complex algo's
No. Neural networks are traditionally based on complex data structures. Something like a case based reasoning system could be an example of a complex algorithm.

The algo to define the weights of the a neural network is quite complex and it is far away from being intuitive
It doesn't have to be. It depends entirely on what you need your neural network to do.

Are you sure to know what a neural network is ? :)

Yes. I've written several, for projects at University (mostly image/text recognition and autonomous robots) and privately (mostly for fun - RARS etc.).

Ok so the algo for training a neural networks is something simple for you
You must be an Einstein then :)

There is no single algorithm (or rather strategy) for training a neural network. Which strategy you use depends on lots of different factors, although mainly:

a) The types of input.
b) The amount of feedback.
c) The desired output.
d) The degree of reproducibility (how often does it "get it right").
e) The degree of predictability (how often does it come to the "expected result").

You must be an Einstein then :)
Hardly.

I beleive that you studied neural network at university but it must have been many years ago, being evident that you forgot what a neural net work ( or at least a training algo) is :)

Well you're entitled to your opinion.

FlameDuck ,come on
I dont really see why you are still arguing about an evident issue
Everybody knows that implementing an FSM is much easier than a neural network
My question was simple and clear
Does it worthwhile using neural network ?

Everybody knows that implementing an FSM is much easier than a neural network
Well "everyone" who knows that is wrong. I would argue that for any FSM that has "n" number of states and an NN with "n" nodes, there is a (surprisingly small, certainly smaller than the average Chess NN) number "n" for which the FSM becomes an order of magnitude more complex (in terms of writing the damned thing) than the NN.

My question was simple and clear
Does it worthwhile using neural network ?
That's neither simple nor clear, as it depends on lots of different factors:
a) How much processing power are you willing to sacrifice (NN's take more)?
b) How much memory (NN's take more)?
c) Is it going to be a "hive mind" (like Chess/Stratego) or are you going to need a different NN for each "unit" (like a Flight Simulator), and is the unit going to live long enough that it can learn effectively (or have recurrent memories)?
d) Is it necessary (Chess - Yes, Pacman - Not so much).

Generally speaking, I'd say no. Unless you have a strategic element as a focus of your game, there is no reason to use a NN for AI. Unless learning to play the game better, is a feature you really want (rather than just tweak magic numbers in your FSM) to increase difficulty as you play.

>FlameDuck ,come on
>I dont really see why you are still arguing about an
>evident issue

He's not.

>Everybody knows that implementing an FSM is much easier
>than a neural network

That would depend on the complexity of the FSM.

>My question was simple and clear
>Does it worthwhile using neural network ?

Apparently you are the resident expert on ANN's and you have to ask if it is worthwhile to use them?!

Sorry but you completely miss the target

I repeat once again that I am not talking from a programming point of view
I am talking from a "conceptual" point of view ( game play)

An FSM is nothing else than a collection of IF...THAN..statement
Everybody uses FSM in game development even if someone may be not aware of
The code can get extremely complex, that's true, but conceptually it remains very simple

A neural networks is completly an other animal
First of all you need a specific background
Not only
Both FSM and neural networks are deterministic techniques but there is a huge difference
While it is easy to predict the behaviour of an FSM driven agent it can be extremly difficult to guess the reaction of a neural work driven character
This can be either positive on negative
On one hand it is the dream of all game developer to design a non easy to predict character on the other hand illogic behaviour are alwayes a disaster
In cocnlusion a neural net work implementation is much more at risk
Does it worthwhile, at least for some specific situation ?
This is the queation

P.S.

NN'S does not take more memory and more processing power the direct opposite ,it is very fast
The hard job( the training) being normaly made off line

While it is easy to predict the behaviour of an FSM driven agent
Again, that is entirely dependent on the complexity of the FSM. The ghosts in Pacman for instance use an FSM, but predicting their movement pattern isn't very easy. Now imagine an FSM with more than 7 (IIRC) states.

on the other hand illogic behaviour are alwayes a disaster
The idea that a game AI that makes a mistake, is a BAD thing is such an absurd position I don't know how to respond to that. Except perhaps "Fancy a game of Tic-Tac-Toe?".

In cocnlusion a neural net work implementation is much more at risk
Conclusion based on what?

Does it worthwhile, at least for some specific situation ?
Yes. I believe I've even already given examples where a NN would be a very good idea.

NN'S does not take more memory and more processing power the direct opposite ,it is very fast
Well you're wrong on both counts. The NN with "n" nodes, will have more states (thus requiring more memory) than an FSM with "n" states. Additionally, the worst case scenario for an FSM to make a decision would be (depending on implementation) O(log n) where as the same for the NN would be O(n).

If most of game programmers use FSM rather than neural net works, there is a reason I suppose

"The idea that a game AI that makes a mistake, is a BAD thing is such an absurd position"

It is evident that you dont get the differnce between an "hard to predict behaviour" and a "non logic behaviour"
In the former case the reaction of the character depends on many factors , each one with its own weight, but it is consistent
in the lettar case it is not even consistent
On the other hand an "easy to predict behaviour" can be very boring


Of course there are type of game which can accept even non logic behaviour but , in general, RPG.WAR GAMES, FPS it is not like that

Alberto: I'm not sure what your point is, but FlameDuck is right. Neural networks can be hard to predict, which is good. If NNs were as easy to predict as FSMs, there'd be no reason to use them.

Neural networks recognize patterns and are useful for making decisions in games. For example, you might feed the NN data like the amount of enemy forces in the area, your current health, etc. and it can make a decision whether to be aggressive/stealthy/etc. There's no "logic" involved since it's simply a "fuzzy" decision making process that can be trained to correctly respond to most situations, even if the current situation has never happened before.

If most of game programmers use FSM rather than neural net works, there is a reason I suppose

Mainly because NNs are rarely necessary.

My AI is for Asteroids/Star Control clone with a bit more realistic physics. The reason why I called it complex AI, is because it's complex to me to handle. There are hundreds of parameters/variables per AI player, so it's impossible to predict exact behavior. I think it's basically a FSM, but I don't know for sure what to call it since I had no idea on basics of AI coding when I started a few weeks ago. I don't even want any 'imported ideas'. I wan't it to look like me.

I did a lot of debugging during the weekend and managed to make the AI very good. It's still a little average on manoeuvring between the asteroids, but in most cases is capable to prevent collisions. In shooting it surpasses my skills, but that's no suprise. My purpose is to make the AI as close to unbeatable as I can and then back up a little.

My original post was mainly about the sensations you have when testing your AI. I noticed during the weekend that when the AI was unable to decide which direction to evade collision, I found myself slapping the spacebar and thinking "don't do that". I was kinda amused when I realised what I did.

The problem with game ai is learning through mistakes.

Its very rare you play a racing game and win all races first time. This is why AI often needs to cheat.

"but FlameDuck is right...Neural networks can be hard to predict, which is good. If NNs were as easy to predict as FSMs, there'd be no reason to use them."

It is exactly what I said and the direct opposite of what FlameDuck was claiming
FSM are easy to predict and consequently they can be boring
For this reason commercial games very often use FSM in combination with fuzzy logic or random numbers
Obviously a complex FSM can be harder to predict than a simple NN but you must compare apple with apple

"I'm not sure what your point is"

My point is
If NN'S or other sophististicated AI's technics are so powerful why no commercial game use them ?
It is not definitly a matter of processing power, not at least for modern hardware

For this reason commercial games very often use FSM in combination with fuzzy logic or random numbers
No (good) commercial game ever uses random numbers to dictate AI behavior.

Obviously a complex FSM can be harder to predict than a simple NN but you must compare apple with apple
A NN is a FSM - it just has exponentially more states than say an Expert System. So wee are comparing Apples to Apples.

It is not definitly a matter of processing power, not at least for modern hardware
Yes it is. Besides as John pointed out, they are rarely necessary, or even desirable.

"A NN is a FSM "

I quote from " AI techniques for game programming "
By Mat Buckland

" For a long time artificial neural networks were a complete mistery to me.
I was able to describe their architecture and mechanism but I didn't get that "Ah Ha" feeling you get when a difficult concept finally clicks in your mind."

Mat , who is supposed to be an world wide expert ,took a long time to realize that NN'S is a FSM ?

I quote from his book "Programming AI by examples"

There are a number of ways of implementing FSM.
A naive approch is to use a series of if-then statements ...

How can you seriously deny tha NN'S can be considered a sophisticated AI technique while FSM is , at basic level, simply a matter of common sense

A naive approch is to use a series of if-then statements ...

How can you seriously deny tha NN'S can be considered a sophisticated AI technique while FSM is , at basic level, simply a matter of common sense

I can make a simple NN with a series of If-Then statements. I can make a FSM with a series of If-Then statements.

At the most basic level, in other words, FSMs and NNs are both just decision making algorithms. The main difference (from the "design" perspective, as you said) is that FSMs are human-crafted, while NNs are usually best when trained. Whether one is more complex than the other is a matter of perspective.

If NN'S or other sophististicated AI's technics are so powerful why no commercial game use them ?

And you know for a fact that all commercial games don't?

"I can make a simple NN with a series of If-Then statements"

Can you make an example ?

Mat , who is supposed to be an world wide expert ,took a long time to realize that NN'S is a FSM ?
I don't know, I haven't read his book. Judging from how he seems to be confusing his terms, I don't feel inclined to either.

There are a number of ways of implementing FSM.
A naive approch is to use a series of if-then statements ...
I haven't read either of those books, and don't know which context he uses the term, but every computer program is a Finite State Machine. Computers are by definition Finite State Machines. (linky)

How can you seriously deny tha NN'S can be considered a sophisticated AI technique while FSM is , at basic level, simply a matter of common sense
Because a Finite State Machine is an abstract concept, not immediately related to AI (but rather program flow). What I think you're getting at is a so-called expert system (linky).

My point is that writing a decent AI, regardless of whether it's an expert system or a neural network, is a reasonably burdensome task. Sure a crappy expert system (like Robotron or Pacman) will perform better as an AI than a crappy neural network (which would seem to be random to the outside observer). But a good expert system is definitely not "worse" than a good neural network. If you look at some of the best RARS drivers (and I imagine it's spiritual successor TORCS) you'll find that hands down some of the best are surprisingly simple expert systems. Why? Because in reality, simplicity always wins.

The idea that a neural network has some inherent property that makes it "better", "more advanced", "more complex" or "more sophisticated" than an expert system is absurd.

I wonder wether you and john speak of NN but actually you have in mind what in AI literature is known as "Perceptrons" which is the simplest kind of neural networks
Same as in case of FSM, everybody use "perceptrons" in his games, maybe, without realizing it
However I did not claim that NN'S is better than...
I claimed that it seems to be better than...
On the other hand I wonder why very few commecial game use NN'S

Can you make an example ?

Here's an extremely simple one:
If nodeA1\input > threshold Then nodeB1\input += nodeA1\output
If nodeA2\input > threshold Then nodeB1\input += nodeA2\output: nodeB2\input += nodeA2\output
If nodeA3\input > threshold Then nodeB2\input += nodeA3\output
If nodeB1\input > threshold Then OutputA();
If nodeB2\input > threshold Then OutputB();

Of course, you'd have to be almost insane to actually implement a NN this way.

The idea that a neural network has some inherent property that makes it "better", "more advanced", "more complex" or "more sophisticated" than an expert system is absurd.

Unless you want an algorithm that can be trained to recognize situations and possibly even "improvise" in new situations.

NNs have their place, but the fact that they're not necessary for good AI in most cases means that they're rarely used.

but every computer program is a Finite State Machine. Computers are by definition Finite State Machines. (linky)

FSMs are more a programming technique for AI than anything else. It simply allows your entities to react in different "moods" or "modes", like "Attack", "Retreat", "Defend", etc.

I wouldn't say FSMs are related to expert systems, since I tend to think of an expert system as something that takes a huge database of rules and comes to a logical conclusion given a set of inputs. A FSM, on the other hand, is simply a way to give your AIs multiple behaviors that are selected based on (usually very simple) rules and calculations.

FSMs are more a programming technique for AI than anything else.
Finite State Machines are an abstract tool used to describe a process.

I tend to think of an expert system as something that takes a huge database of rules and comes to a logical conclusion given a set of inputs.
Well it doesn't necessarily have to take a huge set of rules (huge is subjective anyway, depending on the complexity of the task you're trying to solve). Robotron has one (move in the direction of the player) Pacman has 7 or 8 if memory serves. Robs Zombie game apparently has 100. My RARS driver had 12. A decent chess computer will have at least 15000. Tic-Tac-Toe needs only 3 to be unbeatable. So does a Soduku solver. The 8 queens problem needs 4.

I dont think we will be coding Skynet or SHODAN any time soon ;)

"Of course, you'd have to be almost insane to actually implement a NN this way."

It would be insane because NN's have little to do with FSM
While it is true that :

"Computers are by definition Finite State Machines"

I quote from "Game programming gems" an article by Andre La Mothe (pag 330)

"They ( NN'S ) are based on highly parallel ,didtributed, probabilistic models that not necessarly model a solution to a problem the way a computer program does "

Colin McRae Rally (I think) used NN's to teach the AI opponents to drive which were then plugged into the game afterwards.
There is some suggestion that NNs can be used with Influence Maps to make strategic decisions but I wouldn't want to try and balance the game or playtest it.
In addition, much of the 'learning' is done offline as it is difficult to get enough training cases within a game.
The downside is that once learnt offline, humans are very good at checking the pattern and adapting so it's not so good for Combat AI. In those cases the game information is used (e.g. good places for sniping, high kill areas to avoid, player 'A' has many archers so build cavalry etc).
As for any of my AIs I made a very simple FSM for a Robot maze game. You could allocate points to a few attributes (speed, accuracy, reaction etc). Once done I started to 'see/imagine/hallucinate' the robots behaving intelligently. A robot with quick reaction and speed would pop 'round a corner and spot an opponent, duck back, wait for the opponent to fire and then go after them. It seemed to be a technique I hadn't hard-corded although I be pushed to call it emergent behaviour.
I also wrote a Miner Bob FSM from 'Programming Game AI by Example' (which *is* good). Didn't take long before I had a western town with feuds and gunfights. I felt guilty the first time Elsa was worrying where Bob was. Tragically he'd been shot on his way back from the goldmine by Black Bart. Black Bart was now in the saloon getting drink on his ill-gotten profits.

P.S. @Alberto, you might want to bolster your argument with a few of your own examples rather than selective quotes from books others might not have access to.

We have been talking about the difference betwenn NN'S and FSM
FlameDuck and John claimed that they are basically the same stuff while in my opinion NN'S is ,in any case a sophisticated and complex techniques even though its benefits might be questionable while FSM is , at basic level, a matter of common sense
Of course you must compare appels to apples
A simple NN'S is equivalent to hundreds of if..than statements , thus a FSM program can turn very easly into a nightmare and consequetly it need a good programming skill
Even so, FSM remains something relativly simple to grasp and to implement, from a conceptual point of view
The direct opposite for a NN'S
If you own "Programming AI by examples" you would agree that the author spends just a few words to explain the "theory" of FSM, simply because he assumes that it is something intuitive
Mat focus on how to make your code readable and flexible
In other words it is a programming lesson rather than a AI lesson
If you own the other AI book by the same author you see that his approch for NN'S is completely different


Honestly I dont see also why I should not quote the opinions of famous experts in this field as long as they are complete and reliable
I suppose they are of more interest to other members than FlameDuck's and my opinions

Honestly I dont see also why I should not quote the opinions of famous experts in this field as long as they are complete and reliable


Notice I suggested using your own examples *in addition* to any quotes.
Personally, I believe I can write an FSM easier than an ANN. However, I have only written the one ANN taken from a book I no longer have. Out of all my AI books the game related ones gloss over ANN while the more academic ones give examples that I struggle to relate to.
Anyway, I was giving a response to
a) your query why more 'complex' AI processes such as ANNs are not used extensively
b) the original post about giving birth to AI.
I don't really give a monkey's who is right or wrong on the ANN=FSM debate

>FlameDuck and John claimed that they are basically the
>same stuff

Knowledge Based Systems, Expert Systems, ANN's and even Fuzzy systems can be implemented using IF...THEN structures, they only differ in how much code is needed and how they use data and logic.

>while in my opinion NN'S is ,in any case a sophisticated
>and complex techniques even though its benefits might be
>questionable while FSM is , at basic level, a matter of
>common sense

You are talking in the abstract, whereas others are talking about implementation.

True, when I first needed a simple pattern matching engine(back in the 80's), I developed a Finite State Machine, which seemed to be ideal due to low overhead and high performance. Doing an ANN, fuzzy logic or expert system, did not occur to me because I didn't know the theory and because I learned to think about computing in a sequential manner.

>Of course you must compare appels to apples
>A simple NN'S is equivalent to hundreds of if..than
>statements

As someone else showed above, that's not always the case. While the terms and images in ANN research and theory, there are no set rules on how to implement an ANN.

>thus a FSM program can turn very easly into a nightmare
>and consequetly it need a good programming skill

An FSM has hardcoded logic, and as every programmer should realize, hardcoded logic is not always ideal when you are solving complex problems. A better solution is to use non hardcoded logic, but then the issue becomes 'when does the FSM turn into a Knowledge Based System?'(at which point we could turn to Fuzzy Logic to answer that :) ).

>Even so, FSM remains something relativly simple to grasp
>and to implement, from a conceptual point of view
>The direct opposite for a NN'S

Yes, conceptually they seem different, but in reality they still need to be programmed in the same way(Blitz is sequential, so that would be using IF...THEN and types etc.)

>If you own "Programming AI by examples" you would agree
>that the author spends just a few words to explain
>the "theory" of FSM, simply because he assumes that it is
>something intuitive

Which is probably because he started programming in a sequential language back in the 80's...

Ok my friends you won

NN'S and FSM are the same stuff because they can both be programmed using if..than statement

Maybe you know that any program can be made with if..than statements
So Excel is the same as a NNS which is the same as Quake 4 which is the same as window Vista

Obviusly the opinion of experts count for nothing for you
Even thought I have been forbidden to quote AI book I take the liberty to quote an other expert

From " AI game development " by Alex J. Champanard
Chaper 38 FINITE STATE MACHINE

" The game AI designer who crafts beahvior manually generally creates finite state system.Because they are so intuitive and simple to implement, they are the most widely used forms of AI used in games"

as well as to re quote the opinion of an other expert about about NN'S

" For a long time artificial neural networks were a complete mistery to me.
I was able to describe their architecture and mechanism but I didn't get that "Ah Ha" feeling you get when a difficult concept finally clicks in your mind."


They are the same stuff, it is evident

For the sake of an example...

Here's an excerpt from the AI in my zombie game, as you can see a lot of the states are infact more sub-states to set up the following one..

	If n\State = "NewDying" Then
		If n\Human Then n\State = "Dying" Else n\State="DyingZombie"
		n\Dead = True
		n\Timer = SetTimer(3)
		n\Frame = 8
		n\Active = False
	EndIf
	
	If n\State = "Dying" Then
		;die animation
		MoveNPC(n)
		If OnTimer(n) Then n\State = "Dead": n\Timer=SetTimer(Rand(2,10))	
	EndIf
	
	If n\State = "Dead" Then
		If OnTimer(n) Then
			n\Lives = n\Lives - 1
			If n\Lives < 0 Then n\State = "KillNPC" Else n\State = "Resurect": n\Speed = n\Speed * .2
		EndIf
	EndIf	
	
	If n\State = "Resurect" Then
		MoveNPC(n)
		n\Human = False
		EntityColor n\Mesh,AmbRed,AmbGreen+50,AmbBlue-50
		n\Dead = True
		n\Frame = 16
		n\Timer = SetTimer(1)
		n\State="NewResurect"
		n\Health = Rand(20,50)
		n\Active = True
	EndIf
	
	If n\State = "NewResurect" Then
		AdvanceFrame(n)
		;when timer = 0 Then State = "Lost"
		If OnTimer(n) Then 
			n\Frame = 24
			n\State = "Lost"
		EndIf
	EndIf
											
	If n\State = "Hunt" Then
		TranslateEntity n\Phys,-Sin(n\Angle)*n\Speed,0,Cos(n\Angle)*n\Speed
		MoveNPC(n)
		NewTarget(n,0)
		LookAround(n)
		If Found_HMesh > 0 Then
			n\Target = Found_HMesh
		Else
			n\State = "LostHunt"
			n\Timer = SetTimer(10)
		EndIf
		
		;If they see humans Or players will move towards them
		;If they lose sight of food For more than 10 seconds them State="newlost"
	EndIf
	
	If n\State = "LostHunt" Then
		TranslateEntity n\Phys,-Sin(n\Angle)*n\Speed,0,Cos(n\Angle)*n\Speed
		MoveNPC(n)
		LookAround(n)
		If Found_HMesh > 0 Then
			n\Target = Found_HMesh 
			n\State = "Hunt"
		EndIf
		
		LookForBuilding(n)
		
		If OnTimer(n) Then n\State = "NewLost"
	EndIf
	
	If n\State = "DyingZombie" Then
		MoveNPC(n)
		If OnTimer(n) Then n\State = "DeadZombie": n\Timer=Rand(2,10)
	EndIf
	
	If n\State = "DeadZombie"
		If n\Lives > 0 Then
			n\Lives = n\Lives - 1
			n\State = "Resurect"
			n\Timer = SetTimer(3)
		Else
			n\State = "KillNPC"
			ParticleSplatNew(EntityX(n\Mesh),EntityY(n\Mesh),n\Angle)
			n\Timer = SetTimer(10)
		EndIf
	EndIf
	
	If n\State = "KillNPC"
		alpha# = Float(n\Timer-MilliSecs())/10000.0
		If alpha < 0 Then alpha = 0
		
		EntityAlpha n\Mesh,alpha
		EntityAlpha n\ShadowMesh , alpha *.2
		
		If OnTimer(n) Then 
			FreeEntity n\Mesh
			FreeEntity n\ShadowMesh
			Delete n
		EndIf
		
	EndIf


Alberto: I don't think anybody is saying NNs are equal to FSMs. That's silly. Yes, they can be implemented with If..Then statements just like anything else, but that was a side-topic that you brought up I think.

The original question was, are NNs more complex than FSMs? I'd say if you had a working framework for both NNs and FSMs, NNs would be the simplest to configure for your AI (training). Not the easiest, but the simplest in concept. FSMs on the other hand, are basically pure logic, and you need to configure then by hand every step of the way. In that respect, an FSM is the more complex of the two, but probably the easiest.

Personally, I use FSMs for AI. But I'm not ruling out NNs as a possibility to simplify my AI's decision making process.

>NN'S and FSM are the same stuff because they can both be
>programmed using if..than statement

Noone is saying that they are the same, they are simply different mechanisms for pattern matching. How they work is different, but they are still implemented using the same commands.

>So Excel is the same as a NNS which is the same as Quake 4
>which is the same as window Vista

Actually, Excell using rules and data and even having the ability to use results of calculations in other calculations, gives it character traits most commonly found in experts systems.

>Obviusly the opinion of experts count for nothing for you

EDIT: Anyone can write a book and have it published. It doesn't make you an expert, and it doesn't mean that you know what you are talking about.

That being said, I'm sure the people you quote are knowledgable, so the dismissal of your quotes doesn't refer to them at all.

Programmers are an unruly and pragmatic bunch, they are generally more interested in substance rather than in fluff. For that reason your opinion and experiences count much more than quotes from books.

>Even thought I have been forbidden to quote AI book I take
>the liberty to quote an other expert

Noone forbids you to quote. It was suggested that you back up your claims with code and experience, nothing more. Don't you have an opinion or some experience you can bring to the table?

>They are the same stuff, it is evident

Good, so you finally understand! :)

Perhaps it would be easier to discuss this subject if you could elaborate on what level you think they differ?

*Implementation?
-The actual programming logic.

*Conceptual?
-States
-nodes
-rules
-data representation

As it is, I think you are debating the concept, whereas everyone else is debating the implementation.

We have been talking about the difference betwenn NN'S and FSM
No. Talking about "the difference" between NN's and FSM's is like discussing "the difference" between a high performance engine, and a sports car. One is a subset of the other.

Maybe you know that any program can be made with if..than statements
Sure, providing you have a turing complete instruction set. That wasn't the point tho', as I'm sure you're well aware by now.

" The game AI designer who crafts beahvior manually generally creates finite state system.Because they are so intuitive and simple to implement, they are the most widely used forms of AI used in games"
Oh that's so clever! Since (access to quantum computers notwithstanding) it is impossible to not create a FSM, that's hardly surprising.

Since you're so fond of quoting other people, here's one I find useful: "Those who can, do; those who can't, teach."

They are the same stuff, it is evident
Are you intentionally just not getting it or what? Nobody said an Expert System, a Neural Network, or any other form of AI are "the same". We said they're both (when implemented using existing, as opposed to theoretical computers) FSMs.

You really are good at finding nonsensical quotes, my favorite so far is:
"They ( NN'S ) are based on highly parallel ,didtributed, probabilistic models that not necessarly model a solution to a problem the way a computer program does "
So now there are some other way of programming game AI on a computer, that isn't a computer program? Oh please, I'm dying to hear this one. And for the record, a Neural Net does not "model a solution". If anything it "models a problem". Like "How do I beat Kasparov at chess", "How do I win a global thermonuclear war" or "Which letter does this sample of digitized pixels resemble the most".

They're going to be born soon.



" I don't think anybody is saying NNs are equal to FSMs. That's silly "

Read FlameDuck's post.I agree that's silly

"The original question was, are NNs more complex than FSMs?"

Yes .This was the original question an the answer is :
yes
Please see again the opinion of two well known AI specialists

"Programmers are an unruly and pragmatic bunch, they are generally more interested in substance rather than in fluff."

Actually my question was
Does it worth while using a complex tecqnique rather than a simple one ?
In other words, I have been alwayes using FSM , same as 99 % of amateur game programmers.
Can I expect any concrete benefit switching to a more coplex tecnique in term of game play ?
A very pragmatic question as you see

"Don't you have an opinion or some experience you can bring to the table?"

I have read the books which I have mentioned but I have never put in action what I learnt ( except FSM'S)
Why should I ask these question then ?
However I have at least a good theoretical background while apparently someone else does not even know what he is talking about.


"Perhaps it would be easier to discuss this subject if you could elaborate on what level you think they differ?"

a) NN'S can deliver also analog outputs
For example I made a simple steering AI using NN'S
I had two outputs in the range of 0-100 the right and the left drag force

b) The parameters are crafted manually in FSM and automatically in NN'S , using a complex algo

c)The most important, see later

"You really are good at finding nonsensical quotes, my favorite so far is:
"They ( NN'S ) are based on highly parallel ,didtributed, probabilistic models ..."

Ok I take note tha Andre Lamothe , who is a well known expert in the field of game programming , tells nonsenses

"So now there are some other way of programming game AI on a computer, that isn't a computer program?"

c) The key difference is :

" highly parallel ,distributed models"

A digital computer is essentially a step by step machine consquently its natural math is FSM
A digital computer is not fit for parallel and distributed operations even though you can of course simulate parallelism
This is the basic difference between FSM and NN'S
It is a huge conceptual difference

Yes .This was the original question an the answer is :
yes
Please see again the opinion of two well known AI specialists

Again, I don't know what you call "complex", but NNs are simple but difficult to implement properly, while FSMs are complex but easy to implement properly.

I have read the books which I have mentioned but I have never put in action what I learnt ( except FSM'S)

However I have at least a good theoretical background while apparently someone else does not even know what he is talking about.

Telling someone who has a fair amount of experience in AI and neural nets (FlameDuck) that they don't know what they're talking about is bad enough, but the fact that you haven't even implemented a NN yourself pretty much drops your credability rating to 0 (sorry, nothing I can do about this).

BTW, none of the quotes you mentioned conflict in any way with what me or FlameDuck have been saying.

"but NNs are simple but difficult to implement properly, while FSMs are complex but easy to implement properly "

Sorry but it make no sense to me

"Telling someone who has a fair amount of experience in AI and neural nets (FlameDuck) ""

That why I said "apparemtly"
However if someone makes ironic comments about the opinions of people who are known as world wide experts in this field( Alex j. Champanard - Andrè Lamothe - Mat Buckland ) well his credibility rating to 0

I was asked an explanation about the diference between FSM and NN'S nad I provided it in my previous post

Did I tell anything wrong ?
Ask this question rather than insulting people

I wasn't trying to insult you when I said that your credability was gone, I was just warning you that there are certain things you just don't do to promote your argument, and reminding you that it might help if you stick to the topic instead of telling FlameDuck he doesn't seem to know what he's talking about.

The fact is that FlameDuck does know what he's talking about, and your comment towards FlameDuck did ruin your credibility in this thread (for the time being). I'm sorry.

"but NNs are simple but difficult to implement properly, while FSMs are complex but easy to implement properly "

Sorry but it make no sense to me

I think this has a lot to do with how you define "complex". I say FSMs are complex because in any practical AI implementation the number of states and the interactions between them are just that: complex. Yes, they're easy and intuitive, but they are still complex. Is that bad? Of course not!

NNs, on the other hand, are actually conceptually simple in practical applications. Assign a few inputs, a few outputs, setup a few neuron layers, and train it. Is that good? Sometimes.

However if someone makes ironic comments about the opinions of people who are known as world wide experts in this field

Again, all the quotes you mentioned do not conflict in any way with what I've been saying. Please feel free to prove me wrong.

A concrete example just to complete my point of view

you have 3 analog inputs:

- number_of _enemies
- number_of_friends
- health

and 2 finite state

- attack
- escape

using FSM you must write a sequence of if..than statement
If your are not happy of the beahviour of your bot you can simply edit some parameters and \ or change your code

For example you can increase or decrease the threshold of the number_of_enemies to make your bot more or less aggressive

This is a very intuitive and simple approch since the influence of every parameter and every statement on the final result is immediate and easy to predict

FSM is an easly editable technique

Suppose you use a NN

You have

3 analog input node
2 middle layer node
1 binary output node

you must set the weights of the net, in total you have

3*2 + 2*1 = 8 weights

Each weight has an influence on the output but , this is the key point
such inflluence, as LaMothe said is :

Parallel and distributed

Despite the FlameDucks's ironic comment, this is the most accurate definition of a NN's explaining the huge difference vs FSM

You can not edit the weights manually, one by one, as well as edit the NN''s layout being impossible to predict the results of your changes

As an immediate consequence the " play and watch" tuning method becomes critical and you need to use sophisticated algo's for training the net

The development time grows exponentially and the risk of some un wanted behavior is quite high

NN's is not an easly editable technique

On the other hand , in theory, you should able to achieve a more realistic AI

The behaviour of your bot should be harder to predict but still consistent , du to the fact that a simple NN's is actually equivalent to hundreds if..than statements
Not to mention that you could use an analog out put rather than a binary one
Cosequently you can add , for free, additional intermediate states between Attack and escape .

Cosidering pro and con's

The obvious question is

Does it worth while using NN's?
Can you really achieve much better results ?
If so, for what applications ?

Does it worth while using NN's? Can you really achieve much better results ?
If so, for what applications ?



The only ANN game topic I ever thought might be worth trying is 'Strategic Decision-Making with NN and Influence Maps' by Penny Sweetser in AI Game programming Wisdom 2.
If professional game companies only use ANN in niche areas I very much doubt I'd need them for anything I write.
Its possible I'd look at Pattern Recognition at some point but I doubt it.

However I have at least a good theoretical background while apparently someone else does not even know what he is talking about.
That would be the one who knows what an FSM is (clue: not you).

a) NN'S can deliver also analog outputs
So can expert systems.

b) The parameters are crafted manually in FSM and automatically in NN'S , using a complex algo
Not necessarily. An Expert System operates on data. It can be either hardcoded or represented in a data structure, and that data can be changed based on feedback.

Ok I take note tha Andre Lamothe , who is a well known expert in the field of game programming
Is he? He doesn't have a profile on mobygames, he doesn't seem to have developed a game since he started XGames in 1994, and certainly hasn't developed any games you might have heard of. Like I said: Those who can, do - those who can't, teach.

A digital computer is essentially a step by step machine consquently its natural math is FSM
A digital computer is essentially a universal turing machine. Thus it's only form of math (by which I assume you mean method of execution) is an FSM. That you're unable to distinguish between a 7 state machine and a 7000 state machine, does not mean the later isn't still an FSM.

A digital computer is not fit for parallel and distributed operations even though you can of course simulate parallelism
Well that's more a limitation of your chosen CPU architecture (i80386) and operating system (Windows) rather than a limit on digital computers in general. But yes, I agree that archaic technology is not designed for parallelism, which is why you'll find that people who work with AI in every other field than videogames (like somewhat ironically Mr. Lamothe), uses a different platform.

This is the basic difference between FSM and NN'S
For the last time, a neural network IS a finite state machine - it just has more states than an expert system.

using FSM you must write a sequence of if..than statement
If by FSM you really mean Expert System (which is my reasoning) then you don't really have to write "a sequence". There are plenty better ways to do this (like using the Template Method Pattern).

Does it worth while using NN's?
Not if you don't understand the benefits. Catch-22 eh?

Can you really achieve much better results ?
That depends on how you define better.

If so, for what applications ?
Depends on how creative you are. However as I've mentioned countless times, games aren't inherently well-suited for using NNs. NNs are better suited for photo identification at airports and spam filters. In a game it's often desirable to have a reasonably predictable outcome, otherwise it's not really a (fun) game.

In a game it's often desirable to have a reasonably predictable outcome, otherwise it's not really a (fun) game.

I guess it depends what kind of game you're talking about. In my opinion, AI with a predictable outcome is boring (for example a tank game where the enemy's strategy can be predicted).

For the last time, a neural network IS a finite state machine - it just has more states than an expert system.

Are you sure? This may be true in the most basic case, but what about analog neural networks?

You could say everything computer = FSM, and since Expert Sytem = FSM and NN = FSM, therefore Expert System = FSM, but that's a little too abstract. You might as well say a Car = Apple because they're both made up of atoms.

FSM and NN are definitely NOT the same.

A FSM is state based with transition conditions.
Pro:
- Easy to describe, you can even use visual programming to design them. alternative there exist formal languages to do so as well.
- Consequence is that systems are "easy" to describe compared to NN where you must create a massive amount of training cases with input - output relations.

Con:
- They are static on their own.
- They can not train themself or adapt to states and transitions not known to them.
- Can become a monster to manage unless you use a visual creation software that generates the code for you (or the rule and transition tables)


A NN has no internal state nor has it a transition condition.
It has input and generates a normally not functional defineable output

Pro:
- Can adapt to data not known so far.
- Can be trained to give a specified output when getting a specified input
- Is capable to improvise for unknown input
- Simple to implement and manage the source

Con:
- You will never understand what it does as its mathematical complexity breaks anything imaginable. If you could understand it you could write a math function that does the same which would defeat the point of the NN. - Another negative point is the fact that you can not actively "teach" it stuff. You must enforce adaptions to situations to teach things. This sounds nice at first but it can lead to highly undesired outcomes new inputs. As well wrong or incorrect input can break the training. Can be overcome but needs experience.
- NN use pure computation which means it needs much more performance than an FSM which is basically an event based state transition system.
- AI is far harder to design using NN than FSM



There are systems that use both for different stuff (for example raw input -> system input transformations through an NN and then an expert system to handle that etc) so in the end, you might end up with things that could greatly benefit if you look over your little soup plates border of FSM OR NN and investigate and use the other technics available as well.
Simplest one for unpredictability for example are Fuzzy FSM.

In my opinion, AI with a predictable outcome is boring (for example a tank game where the enemy's strategy can be predicted).
Well IMO if you can't develop your own strategies to defeat said tank, because it's unpredictable, then the game quickly breaks down into:

a) Find Tank.
b) Shoot at it until either of you are dead.
c) Repeat.

You might as well say a Car = Apple because they're both made up of atoms.
Actually it would be a better analog (no pun intended) to say that a pick-up truck and a roadster are both cars, although they serve different purposes.

FSM and NN are definitely NOT the same.
No - nobody's said that. You can create a FSM that isn't a NN, however you cannot create (on existing technology) a NN that is not a FSM.

A NN has no internal state nor has it a transition condition.
Yes it does. Its state is described by the number of nodes, their weights and interconnection. Transition conditions are any time you want to manipulate that state (for instance backpropagation) or in some cases when you get input.

Can adapt to data not known so far.
This isn't necessarily true, depending on what you mean by "adapt" and the underlying implementation.

You will never understand what it does as its mathematical complexity breaks anything imaginable.
Neural Networks can be described using relatively benign differential equations.

Well IMO if you can't develop your own strategies to defeat said tank, because it's unpredictable, then the game quickly breaks down into:

a) Find Tank.
b) Shoot at it until either of you are dead.
c) Repeat.

Not really. "Unpredictable" does not mean "totally random". For example, what if you're driving your tank through a city, and you see an enemy tank drive across a cross street several hundred yards ahead of you. The enemy tank may now be waiting to shoot you as you drive by, retreating, or even attacking from behind for all you know. In other words, the behavior is unpredictable, not due to some random factor, but simply due to a well implemented FSM or NN that makes complex decisions.

Now, on the other hand, what if all tanks always turned toward you and always started attacking head-on 100% predictably. Would that get boring? It sure would for me.

Which is more fun? The predictable tank, or the unpredictable tank?

"Unpredictable" does not mean "totally random".
"Predictable" doesn't mean "Slave to habit". It means it doesn't do something unnatural. Predictable behavior is when something happens and you go "Oh, I could totally see how that went", where as unpredictable is when you find yourself going "The AI has to be cheating there's no way that could've ever happened".

While unpredictable behavior may not be technically random in nature, it may still appear that way to the observer.

Which is more fun? The predictable tank, or the unpredictable tank?
The natural tank. If there is no strategy element to it there's no point in playing IMO. When presented with a choice, the outcome should be somewhat predictable, otherwise you're basically playing a flashy slot machine.