I’m working on a collection of demos (not a playable game) that should give you an idea of the possibilities of artificial neural networks (ANN) in games. Check it out on http://www.astragamingstudios.tk (recent post).
I’m using various sorts of networks such as Hopfield for pattern recognition and feedforward with backprogagation for learning. The GUI allows you to tweak some parameters so that you can experience the limits of ANN. In some cases the results are very usefull, but in other cases you can see that ANN do have their limits and not all problems require an ANN solution.
The Unity3D part is mostly just for visualisation. I wanted something more to look at instead of ones and zero’s.
The reading of csv files does not work in the webplayer due to security reasons !!!
This is a work in progress. More will be added soon. Suggestions / comments welcome.
Thanks for links but I already know them. I was and I’m still interested cause I got my neural network running in unity but is it extremly slow to learn even simple xor task… How do you managed learning process so it is not extremly slow and how do you manage it on runtime? I would be very glad if you can share some wisdom cause my simple xor example halt unity for ~2hours @ i7 CPU!
Everything you need is @ Redirecting.... All the ANN stuff is done bij his framework Encog. You can watch videos about all his code, he wrote a book about it (which is great) and all code is free to download. All I did was use it in the Unity evironment. I also just send you a mail with a sample of my XOR code. You seem to be struggling with that.
Yep, I recived email and I examined code. Now my eyes opened I was also experimenting with that same code as you pointed out in link, so our soulutions should be compatible. My main problem was when to stop learning and how to spread it while Unity is running. I switched to different NN in meanwhile and trying to adapt it to my needs. Now trying to make it work out of DLL. Thank you for input and advice. Maybe I will have some questions later.
Yes you should put a limit on how many iteration you want the network to perform while learning. I stop the training either after some fixed number of iterations or when the error is low enough (which ever is first). Besides from that I do max 10 iterations per frame. If you do all of them (let’s say 5000) in the start method, then the framerate drops to zero a the game seems stuck. Have fun. And isn’t it ironic that your profile pic is a cat and mine is a dog, both going for a snack …
I’m wondering how to measure performance of my network. I’m doing XOR operation with these parameters:
network configuration is 2, 2, 1
learning rate is 0.1
max error is 0.001
The problem is that whole learning usually takes ~8000 iterations but I’m unable to measure time to learn this network. I’m not thortling iterations or doing learning in Update. Even if output timestamp with precision of 25 decimal places, it show me 0 time. Learning of XOR is nearly instant?! I’m using this for measuring time spent for training:
float startTime = Time.time;
// training loop
// training is stopped when either max iterations are reached or current error is < max error
Debug.Log ("Time [ms]: "+(Time.time - startTime).ToString("f65"));
Is there something wring with this measuring method or just this network is doing it so quickly?
I’m not 100% sure but I think that smaler learning rate is important cause high rates can create false connections which can lead to wrong outputs. I think it’s called “overlearning”. My next step is to train brain for driving car. I have quite complicated sensory setup and 3D space so I’m full of expectations how it [Neural Network] will deal with it.
Hi! I’m very interested in neural networks and am trying to make game AIs for some projects with them. But I’m having trouble. I’ve checked out your link and found it very helpful. But do you think you could send me the sample code for XOR and maybe some other tutorial ones as well? Thanks. And if you can help with some code or tutorials for pattern recognition that would be awesome.
Hi, Boi. Thank you SO much for all your work on the Encog library. I have been wanting to learn ANN’s for quite a long time. The links above have helped immensely.
I’m hoping you can help with an issue I’m having. I’m a bit new to the plugins part of Unity and I’m having trouble getting the 3.1.0 version of the CS dll working correctly with Unity Pro 4.0.
In Visual Studio, I have created a very simple CS example that creates an XOR ANN, trains it, and it produces correct outputs.
When cut and paste the code to my CS Unity Script, and put the release CS dll in the Assets\Plugins folder, I get an error in Unity:
“Internal compiler error. See the console log for more information. output was:
Unhandled Exception: System.TypeLoadException: Could not load type ‘Encog.ML.Train.BasicTraining’ from assembly ‘encog-core-cs, Version=3.1.0.0, Culture=neutral, PublicKeyToken=3e882172b12155d4’.”
If I comment out “IMLTrain tr = new ResilientPropagation(nn, training_set);” and the rest of the training part, the error goes away, but I get further errors when the code gets to nn.Reset(): this time its unable to load the type Encog.App.Analyst.Script.AnalystScript.
I have tried setting the .NET target in the project settings from “.NET 2.0 subset” to “.NET 2.0” - to no avail.
Any further things I can try? Thanks in advance for your time.
[edit - just realized you arent the author of the library ]
Encog is using alot of .Net features that are not available in Mono(System.Linq, System.Drawing for example). That is why you get the System.TypeLoadException.