Anyone got experience with steering boids with a neural net?

General discussion and socializing.

Anyone got experience with steering boids with a neural net?

Postby Potjeh » Tue Oct 03, 2017 12:28 pm

Because I'm too lazy to make a stackexchange account, and there's plenty of programmers here.

So, I'm working on a football game, where the players are boids. I've tried manually writing a function for intercepting a ball, and it works fine most of the time, but there's still too many cases where a player misses the ball he should've easily intercepted. I was too lazy to do proper math, so I decided that this looks like a job for a neural network. I wrote an implementation of NEAT, and it does manage to train to consistently pick up the ball, but it does so in a terrible way. Namely it just sets target along the four diagonals, and travels along one until either the x or the y coordinate match the ball, and then proceeds to alternate between the two diagonals adjanced to the cardinal direction in which the ball is, and thus move towards the ball (the goal direction flips pretty fast so it doesn't deviate that much from the straight line to the ball). I consistently get this behavior in ~30 generation with a population of 300. I've tried scoring time to pick up the ball (distance to ball if it's not picked up by simulation's end) and closest distance to ball throughout the simulation. For outputs I've tried just target coordinates (offset from player's position), and target coordinates plus target speed (in previous case the boid always tried to move at max speed). For inputs I've tried just relative ball position and I've tried relative position and relative speed. No matter what, I always get the same results. Has anyone here had similar problems, and if yes can you tell me what's causing it and how to fix it?
Image Bottleneck
User avatar
Potjeh
 
Posts: 11812
Joined: Fri May 29, 2009 4:03 pm

Re: Anyone got experience with steering boids with a neural

Postby Potjeh » Tue Oct 03, 2017 4:22 pm

Whelp, apparently neural networks don't like non-normalized inputs. Stupid bitches, why can't they use input weights to normalize them during training? Anyway, that explains cardinal direction movement, will keep you posted with updates if anyone cares.
Image Bottleneck
User avatar
Potjeh
 
Posts: 11812
Joined: Fri May 29, 2009 4:03 pm

Re: Anyone got experience with steering boids with a neural

Postby Granger » Tue Oct 03, 2017 6:52 pm

Why do you need a neural network for this - do you build the game in hardware?
⁎ Mon Mar 22, 2010 ✝ Thu Jan 23, 2020
User avatar
Granger
 
Posts: 9254
Joined: Mon Mar 22, 2010 2:00 pm

Re: Anyone got experience with steering boids with a neural

Postby Potjeh » Tue Oct 03, 2017 7:37 pm

No, I just figured it would be easier to train a neural network than to write an actual decent football AI.
Image Bottleneck
User avatar
Potjeh
 
Posts: 11812
Joined: Fri May 29, 2009 4:03 pm

Re: Anyone got experience with steering boids with a neural

Postby _Gunnar » Tue Oct 03, 2017 10:51 pm

Please do post updates, sounds pretty interesting.
Image
User avatar
_Gunnar
 
Posts: 1430
Joined: Thu Dec 22, 2011 1:15 pm

Re: Anyone got experience with steering boids with a neural

Postby Potjeh » Tue Oct 03, 2017 11:23 pm

Well, normalizing relative ball position has drastically decreased learning rate (~3x I'd say), but now it's actually learning to move straight towards the ball (not quite there yet at 100 generations). Incidentally, while looking for stuff that was causing diagonal movement, I realized I was using parent A's genes during crossover for all the common genes and only used parent B's loose genes (if B was fitter, that is) :oops:
Image Bottleneck
User avatar
Potjeh
 
Posts: 11812
Joined: Fri May 29, 2009 4:03 pm

Re: Anyone got experience with steering boids with a neural

Postby ydex » Wed Oct 04, 2017 3:14 pm

A very intressting idea indeed! :D
bold
User avatar
ydex
 
Posts: 747
Joined: Mon Apr 11, 2011 4:08 pm


Return to The Inn of Brodgar

Who is online

Users browsing this forum: Claude [Bot] and 162 guests