1
\$\begingroup\$

This may not be the best forum for this question, but I know a lot of you have dabbled in the field of general AI for games so here it is.

I'm doing the cliche population evolution of creatures in a simulated ecosystem (with some cool irrelevant twists) where each creature is its own neural network. Specifically, I'm using the NEAT algorithm to evolve creature brains over generations.

My problem is that I can't figure out what to feed as input to the creature neural networks. I haven't found any relevant literature on it either.

The world right now is composed of prey/predator creatures and grass for the prey to eat. I want all creatures to see all three objects (prey, predators, and grass). The other important point is that the populations are not fixed. Prey can become endangered, grass can become limited, etc.

Initially I was going to have a list of all objects as relative positional vectors within a radius of a given creature as input, but variable sized inputs are basically a no go for neural networks. My second idea was just show everything in the scene (even if it may be a sensory overload), and when an object dies just replace it with a -1 hot vector. But that would just confuse the ANN.

I'm out of ideas and flailing in the water. Any thoughts are appreciated.

\$\endgroup\$
  • \$\begingroup\$ Instead of provibing variable sized "locations" would something like the number of grass, prey and predator near work? \$\endgroup\$ – Felsir Jun 28 '16 at 5:52
  • \$\begingroup\$ For feeding into a neural network, I'd be tempted to use an analogy of "scent". For each kind of thing your creature can smell, it needs just three inputs: the strength of that scent at its current position, and the x & y gradient of that scent, so it can determine in which direction the scent gets stronger. You can populate these inputs by grabbing every scent source in a radius around the creature and summing a scent density function. You could even bias this density falloff with wind and see if your predators learn to attack from downwind where their prey can't smell them as easily... ;) \$\endgroup\$ – DMGregory Jul 11 '16 at 0:07
0
\$\begingroup\$

A tutorial for "Enemy Sight" exists in Unity's documentation, here

Basically, it uses Raycasts to detect the presence of other objects within a certain radius. This is a simple but effective approach that will tell your creatures where everything is and also what it is.

The other approach (one that I have used in the past) is to create / obtain a cone mesh. The mesh is used to create a collider that is set to be a trigger zone. This results in a vision cone, and when an object moves within this vision cone, Unity calls OnTriggerEnter(), which is where you can put your logic of what the AI does when it encounters a particular entity.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.