Neural Networks

Started by
10 comments, last by FuMo 23 years, 5 months ago
I''m currently trying to implement neural network for a snakes game. Time is fairly limited (i.e. a few days work on it no more than a week). Its just when I asked the 2 lectures who teach me AI told me that I’m going to be very hard pushed to get an it done in the time frame I’m talking about. So has any one else here tried to implement some sort of neural network for a game and if so am I being completely unrealistic? and due u have any tips
+---------------------------------------------+| "Hard work never killed anyone but I figure || why take the chance?" Ronald Regan |+---------------------------------------------+
Advertisement
sorry to break it to you, but you are being totally unrealisitic if you hope to build and train a neural network in a few days. Even a few weeks is asking a lot. It is possible to implement a Neural Network in a game.. but it takes a lot of time and effort.

I had a friend who (for his univeristy dissertation) wrote a pac-man clone (well 2 actually one without an ANN [artifical neural network]) with an ANN.. and that + the diseertation took him at least 6 months...
NightWraith
When I say a few days. that is a few days work Ie 9-5 over the next month
+---------------------------------------------+| "Hard work never killed anyone but I figure || why take the chance?" Ronald Regan |+---------------------------------------------+
I''ll write a perceptron ANN replacement for xor in a few minutes

"Paranoia is the belief in a hidden order behind the visible." - Anonymous
I haven''t implemented any neural networks for games, but implementing them are generally very simple. You don''t say what kind of NN you are trying to use so I can''t be more specific.

The most difficult part will probaply be training. If you are using some kind of supervised learning scheme (error back-prob or similar) then you will have to generate thousands or so training samples with correct behaviours in order to train your net. On the other hand, if you are using reinforcement learning then you can just let your AI play few hours and it will learn trough trial and error. But reinforcement learning could be harder to implement...

-Ratsia
No, no, no.

Evolve the neural nets weights using a genetic algorithm.

Mike
MikeD:

Have you actually tried that? If so, what kind of net were you using and in what situation? Did you get good results?

To me it sounds like there''s to much to do in that kind of approach. To get genetic systems work you need quite a large population and lots of generations. Now if it takes some time to evaluate how good every net is it might take too long to find best nets. Genetic algorithms also usually require lots of memory (youhave to store a whole generation of nets) while for most ''real'' learning algorithms you only need to store one net.

-Ratsia
I'm afraid the first few comments made me more determined to create an ANN. So I spent most of yesterday researching it and I’ve come up with a few ideas. They all involve NN but the data inputted and how they learn is slightly different. The first method with is the method that I think is most likely to give good results the easiest involves giving the snake instincts. For example one of the inputs is where “nibblet” is and I have implemented a A* algoithm that searches to a level of 5 (ie 5 moves ahead) but It also intend to implement alpha-beta pruning to limit the search space. I’m still not sure whether to increase the search depth but for the moment I did not want to over load the system. I then include other inputs like is there something in-front, left or right of you. There are a number of other inputs, about 9 in all depending on how you look at it. These inputs are then fed into a multilayer feed-forward network (I’m using one hidden layer at the moment but I am increase it to two) which has 25 nodes (again this may need adjusting a bit). To evolve my ANN, I’m currently using Gaussian random numbers to adjust the weights. At the moment I create 10 completely random snakes, I then play them against each other and the top 5 get to be mutated slightly (via the Gaussian random) to give 5 more snakes the process then repeats. Every 1000 generations I save the best 10 snakes so I can play them and see what state there at. One other method is to get rid of the instincts (may well require the NN to be made bigger) and just run the program in a similar fashion. The final method that would require a lot time and effort put in is to run the ANN in the back ground while you are playing and then teach the NN to match your playing style but because I’m fairly short for time I don’t think I will use this approach.
Due to coding past my bed time I have only just (I hope : ) got the bugs out of my test program so I’m going to leave this thing running while I’m off at lectures.
I hope this works.


Edited by - FuMo on December 7, 2000 8:22:59 AM
+---------------------------------------------+| "Hard work never killed anyone but I figure || why take the chance?" Ronald Regan |+---------------------------------------------+
FuMo : Glad to see it''s working out for you.

Ratsia : I haven''t evolved neural networks yet, although I will have by the end of December (it''s coursework, I''m using L-Systems to evolve the morphology as well as the weights). I have used genetic algorithms to evolve solutions before, specifically a minimal sorting network, which is still running. It''s at length 66, with the record standing at 60. I doubt I''ll get there but I should get _closer_.
A quick point though, you don''t need large populations to evolve with ga''s. A population of 50 works well and doesn''t require stupid amounts of memory. It may take a few thousand generations but it tends to find _an_ optimal solution eventually (for my MSN it''s been almost 48 hours, it found the solution it''s at now after 15 hours).

Mike
FuMo:
Your approach is interesting and I have a feeling it will work. Combining more traditonal methods (A*) with neural methods is good idea. I''m waiting to see what kind of system you will end up. You just have to remember that snake game shouldn''t have too good AI or it''s not fun to play anymore.

MikeD:
I admit that I exaggarated a bit but population of 50 is still a lot more than one or a few we would require with reinforcement learning scheme. Of course there are uses for genetic systems for as you said they will find global solutions, but if problem can be solved with some faster or lighter algoritm then it might be a bit overkill to use genetic algorithms.
Combining genetic algorithms with neural networks is anyway interesting approach as genetic systems find global solutions and neural nets are universal approximators...

-Ratsia

This topic is closed to new replies.

Advertisement