0
101 Apr 30, 2006 at 00:58

Hey everyone, I’m back. *audience boos* I have some more questions.

After successfully creating an evolving colony of creatures that eat, mate and die, I’ve chosen to move on to neural networks. Now, in my last post, someone explained these to me as simply as they could and, though I understood and still do understand the basic gist of it, it’s honestly still eluding me.

Having read a few more articles on it, I have a better understanding, and in turn, more questions.

One of the articles I read suggested an RTS game like Warcraft, with the peons having evolving neural networks; the best peons’ networks being passed along. This idea pretty much amazed me, and I’d like to eventually get around to it. Now, I DO have the skill and knowledge to code my own RTS, but it’s a big project, and I’m merely focusing on AI for now. As such, I would like to do something LIKE the said idea. I have a few ideas myself.

Now for my questions. I understand that in a neural network, neurons are given data. What do they receive. Let’s say I gave my creatures a basic neural network to govern movement with obstacles. What would the input be, look like, etc? After they receive input, I understand that they output something, and to my understanding it is either 0 or 1. Is it always 0 or 1, or just in the given examples? I don’t really understand how to control movement using 0s and 1s, besides to have four neurons (one for up, one for right, one for down, and one for left) and then putting the input into each one. I also don’t understand the whole idea of “weights”. I’m going to explain the situation as I understand it. Feel free to correct me, as that’s what I want.

Let’s say I have a colony of creatures, they have four neurons, ones for up, down, left and right. In every loop, certain data (?) is inputted into each neuron, and each then (not sure on this part) somehow calculates something (something to do with the input data * something, but I really don’t understand this, so an explanation would be appreciated) and then outputs 0 or 1. The only flaw I see in this system is: What if two neurons fire? It moves up and right, or whatever. What happens if three or four fire? Is there some way it can have priorities?

EDIT: Or another scenario: In every loop, certain data (?) is inputted into the first neuron (let’s say up), which then outputs 0 or 1 to a connected neuron (right) then to another (down) and lastly to another (left), which somehow outputs the movement data (four 0s and 1s?) I’m very confused.

ANOTHER EDIT: One more scenario, after some more thinking: In every loop, data (let’s say the distance of the food around the creature) is inputted into all four neurons, ones for up, down, left and right. Each of the neurons then multiplies the data (let’s say there’s a piece of food 20 feet up, and none anywhere else, so the input is 20 into the up neuron, and 0 into the others) by it’s own weight (is this correct)? Let’s say all the neurons had the same weight, simply 1, so the up neuron fires, moving the creature up, the others don’t fire, returning 0. Is this the correct method?

I’m not looking on these creatures “learning” yet, but that’d be an added bonus if it’s not too hard to implement.

My last question is: say you have some kind of creatures system, and they’ve evolved and learned, and yada yada. You’re ready to quit, but your precious colony has taken four hours to reach the point it’s at. How do you save the neural network data (the learnt data, etc) to a file? I’m not asking how to handle files, but how to store the data.

If I didn’t elaborate enough on anything, let me know and I’ll post a reply. Thanks for your input (no pun intended).

#### 5 Replies

0
101 Apr 30, 2006 at 22:39

Your Neural Networks or Genetic Algorithms can be used to feed, drive and evolve whatever parameters you decide to use in your system. You could try to feed your NN with things like “distance to closest enemy”, “health left”, “relative combat power”, and expect to get out parameters like “attack eagerness”, “desire to retreat”, etc. and use GAs to assign and evolve thresholds for those low level behaviours to execute. Expecting a neural network to tell you whether to go up or left is likely not going to cut it.

Modelling a good set of parameters for neural networks is an art in itself, but you also need a good infrastructure of “mechanical” code underneath. Even our brains rely on reflexes, instincts and whatnot for the low-level stuff like walking or touching your nose with a finger.

0
101 May 01, 2006 at 03:18

@Jare

Your Neural Networks or Genetic Algorithms can be used to feed, drive and evolve whatever parameters you decide to use in your system. You could try to feed your NN with things like “distance to closest enemy”, “health left”, “relative combat power”, and expect to get out parameters like “attack eagerness”, “desire to retreat”, etc. and use GAs to assign and evolve thresholds for those low level behaviours to execute. Expecting a neural network to tell you whether to go up or left is likely not going to cut it.

Modelling a good set of parameters for neural networks is an art in itself, but you also need a good infrastructure of “mechanical” code underneath. Even our brains rely on reflexes, instincts and whatnot for the low-level stuff like walking or touching your nose with a finger.

Sorry if I come across as a totally ignorant MMORPG-desiring kid, please don’t take me as one.

The reason I have so much trouble with the concept of NNs is the fact that they essentially “think”. Using your idea, let me make a new scenario:

A creature is given a set of parameters, distance of the nearest enemy, health, etc. The NN works it’s magic and outputs a value (this is where one of my biggest questions comes in, CAN IT ONLY OUTPUT 0 OR 1?), assuming it can output something other than 0 or 1, let’s say it outputs the eagerness to persue the enemy. Here’s my other big question, let’s say it outputs 23. To decide whether to attack, do you run this through an IF THEN? Like “If eagerness > 22 Then attack” or what? I understand that the NN makes the “decision”, but it doesn’t make any action happen. It doesn’t make the creature attack, or if it does, how so?

I’m very sorry for my persistent and seemingly ignorant questions, I’m just trying to learn. Thank you very much for your kind and generous help.

0
167 May 01, 2006 at 04:30

Part of the definition of a neural network involves a threshold level for each node. The node is “activated” if its output value (the weighted sum of its inputs) is greater than the threshold. The thresholds and the weights can both be controlled by your GA or whatever ‘learning’ system you are using. You might want to do something like normalize the weights, i.e. divide all the weights going into each node by their sum, so that the weights add up to 1. But I don’t think this is necessary. Experiment and see what works best.

As for making action happen, what Jare is trying to say is that you don’t need to let your NN do everything. Assume that your creatures already “know” how to attack something - you can use, for instance, an RPG-style combat system here. The task of the NN is just deciding whether to attack. You can have this decided by a threshold system, or you can make it probabilistic - say the “attack” output is 23, and the “retreat” output is 52, then you could choose a random number in [1, 75] (that’s 23 + 52), attack if the number is <= 23, and retreat otherwise, so that the two outputs are relative probabilities of attacking or retreating. There are probably other ways you could figure out how to do this too.

0
101 May 01, 2006 at 14:49

@Reedbeta

Part of the definition of a neural network involves a threshold level for each node. The node is “activated” if its output value (the weighted sum of its inputs) is greater than the threshold. The thresholds and the weights can both be controlled by your GA or whatever ‘learning’ system you are using. You might want to do something like normalize the weights, i.e. divide all the weights going into each node by their sum, so that the weights add up to 1. But I don’t think this is necessary. Experiment and see what works best. As for making action happen, what Jare is trying to say is that you don’t need to let your NN do everything. Assume that your creatures already “know” how to attack something - you can use, for instance, an RPG-style combat system here. The task of the NN is just deciding whether to attack. You can have this decided by a threshold system, or you can make it probabilistic - say the “attack” output is 23, and the “retreat” output is 52, then you could choose a random number in [1, 75] (that’s 23 + 52), attack if the number is <= 23, and retreat otherwise, so that the two outputs are relative probabilities of attacking or retreating. There are probably other ways you could figure out how to do this too.

Thanks again, Reedbeta, you seem to have answered my questions for now. If something else comes up, I’ll reply here or make a new post. Thanks again =)

0
101 May 01, 2006 at 20:00

@Ethanbot

I’m very sorry for my persistent and seemingly ignorant questions

On the contrary, I thought your questions were very relevant, focused and well presented. I wish you the best of lucks in researching and implementing these techniques, and hope to read about the results in the future. :)