So... ai... how does this work?

i finally made up my mind and decided to look into neural networks. everything i know so far is that it has to do with complex looking formulars which tell me nothing and "take input, make output" and "layers". is there an easy example out there which i can reproduce at home without spending weeks first, studying what types of nns exist and which type can do what?

i believe that once i get the basics, the rest should reveal itself. (this always works for me)

Neural networks, what artificial inteligence researchers use when they just don't know! ^^

Yes, I love them.

It's pretty simple. As far as the code that makes use of them goes you need to know the following: A neural network takes input generally in the form of a bunch of floats/doubles or booleans. The output is of the same format. This part is I think the trickiest as you'll have to translate the units sorroundings into such values. The neural network may become large and bulky.



Anyway, I'll start off with a single "neuron" a neuron has a couple of things:

  • an activation value (a float)
  • input connections (generally giving off float values as well)
  • output connections (can be float or boolean)



    a connection has the following:
  • Input value
  • Weight
  • output value



    The network gets it's answers a bit like this:

    type A:

    output = (totalInput) - (activationValue)

    type B:

    if (totalInput >= activationValue) output = 1 (or true)

    else output = 0 (or false)



    then the connection modifies the output from the node by multiplying it with it's own weight value and feeds the result to the node it connects to.



    This however, is what happens when the network is stable. The network has to learn first. You do this by changing the weight of the connections. If your network gets the answer right, all the weights that were activated become higher (based on their current value) and if your network gets it wrong all the ones that got activated get lowered.

    The exact formula is a bit more complicated but this is the principle. Also note that while neural networks can be very powerful without you having to understand one bit they can be very tricky to set up and may act completly bizarre after acting fine in the confined testing/learning process.

    Personally if you want such a serious AI I'd go for evolutionary programming. I myself have thought about neural networks but if a small network doesn't work you may end up with more that you can handle (molehills and whatnot).

Just googled a picture

http://1.bp.blogspot.com/_KRG734syqxQ/ST-Ce0jsIxI/AAAAAAAAAaA/I55zB7kRnyo/s400/400px-Artificial_neural_network.svg.png



The circles here are the "neurons" and the arrows are the connections. In this picture, the 3 input "neurons" could be x, y, z coordinates and the output "neurons" could be course adaptation (left/right and up/down for instance when using something with fixed speed like a simple plane). And yes, the output of a neuron, a weight or input can also be negative.

Well, that's kind of funny. I've just decided to look into neural networks also. We were taught a little bit about it in couple of lectures, but I dont remember the math behind it anymore. A friend of mine who has some experience in that field, recommended me the following site for sources http://www.heatonresearch.com/. There You can find entire courses like http://www.heatonresearch.com/course/intro-neural-nets-java. You might also try search for video lectures on youtube, like http://www.youtube.com/results?search_query=neural+networks&search_type=&aq=f.

HamsterofDeath said:


i already taught it to tell me if the sum of 3 doubles is less than 2 or greater than 2 :D. 3 input neurons, 6 hidden (no special reason for the numbers), 1 output neuron. however, i wonder - how good can a nn get?



Your brain is a neural network :), artificial neural network pretty much learns the same way as a human being, altough it's a simplified model.

Please let me know if you find some really simple example or lecture that make the basics very clear, since I just understand the general picture a bit.
http://www.heatonresearch.com/course/intro-neural-nets-java


this one is pretty good. takes a few hours to read, but it's worth the time.

Your brain is a neural network


it's much more. i can plan ahead.

Actually wether the brain is "just" a neural network is subject to discussion. While it is true that ANN's are essentially based on actual neural activity, there is a general consensus that there's more happening inside a brain than that.



And btw, neural networks may well be able to plan ahead, wether they know they are doing that is a different matter.



I'd like to clarify a few things about neural networks.

As said, they are essentially a black box, you give it an input, it does some things you have no idea of why it does it and it gives you an answer.

Neural networks are generally used when the problem isn't understood well. They have been used for example to try to distinguish between soviet and european tanks. So a neural network was made and pictures of soviet and western tanks were fed into it with the normal reinforcement learning I described above. The network never worked as all the pictures of western tanks were taken on a sunny day, so what the network was good at was telling what weather it was in a certain picture.



Now I'd like to clarify a few things mentioned here:

How good can an ANN get? Very good, it's used for face recognition at least a few times. As mentioned however the network may require a huge ammount of data to learn, this will NOT however make your network bigger! As a matter of fact, the speed at wich the network calculates something will not change after having learned any amount of data. It is possible however, to build a neural network that is too small to "grasp" the problem and solution well.

Can an ANN come up with a complex plan? Probably yes, especially if you reinforce such behaviors over non-plans. I think it would require a quite large neural network however and a ton of work, not good for games. You could try to experiment with "memory neurons" for some more simple planning.

How do I set up an ANN to work with my game? I have no clue. There's 2 big problems here:

  1. How do I feed all the data into the ANN?

    You will probably want your network to react to all the enemies in sight, the terrain, changes in enemies courses (although this could be done with memory cells), "mission objectives" and what not. You'll probably need to feed this into the ANN in the form of floats…
  2. When did the ANN do good?

    You'll probably want to call the ANN every frame (based on you using BaseGame). If you want to use suppervised learning (you telling the node if it did good or bad, wich is probably the way to go) you will have to call the network a whole damn lot of times. Every time this happens you will have to tell him if he did good or bad and preferably HOW good or bad. If not getting killed is clasiffied as good you'll most probably get an AI that sits around all day doing nothing. A solution to this might be calling the ANN only when the player is nearby and shift to an "idle" behaviour otherwise.



    To sum it up, I think you'll find it much easier to hardcode most of the AI and use neural network to dodge bullets in dogfights or some such thing.
To sum it up, I think you'll find it much easier to hardcode most of the AI and use neural network to dodge bullets in dogfights or some such thing.


i'm using antigravity movement during fights (avoid dangerous spots (where bullets are or will be soon), prefer attractive ones like ammo boxes or places that are in range of allies). that combined with a*-pathfinding works fine and is pretty challenging. i don't think any nn could keep up with this except i put really much work in it.

Can an ANN come up with a complex plan? Probably yes, especially if you reinforce such behaviors over non-plans.


i can imagine nns learing to do x if the situation is y, leading to situation z, which in turn makes the nn react with abc which looks to us like it was planning a few steps ahead. but actually planning head? i don't see that inside the structure of any nn i've read about so far.

Let's drop the planning discussion, it's more philosophical in nature anyway.

Oh you're not going to find anything inside the structure of an ANN, like you said, ANN's are black boxes.

Some good insight on ANNs is provided in this new thread on the topic.