Genetic Algorithm Neural Network- Inputs for evolving creatures I made a GANN program for evolving creatures. The genes that get put into the GA for each ind are the weights that go into the neural net for each creature. The NN is a basic 1 hidden layer NN with bias neurons and it uses TANH so the weights are from -1 to 1. The GA uses .8 crossover rate (.3 elitism) and .003 mutation chance per gene/weight. Ranked selection is used and 1 point crossover.

The creatures go after food that spawns in a random location after pickup and there are also traps to avoid that done move. A food raises the fitness by 1 and the trap makes it lose 1 fitness point. They start at 1 fitness (health) and if they hit to many traps and get to 0 they die and their genes aren't used in the next evolution. But not many die anyway only like 5 to 10/50 per gen. There are 20 of both traps and food and 50 creatures. There are two sensors on the creatures. One on the left side about 30 degrees from the center face and one on the right. The inputs are each sensors dis from the closest food and from the closest trap.The outputs are 2 numbers. I pick which is highest get the abs value and multiply it by a max angle of 15 degrees and the creature rotates by that amount either right or left depending on which output neuron was the highest.

Before I added in the traps the creatures were very good at getting to food quickly and accurately. And they learned how to do it relatively quickly per test (after like 15 gens they were very good). Then I added in traps and just added the inputs that were the distances from the sensors to these traps just like with the food. With both inputs to food and traps they no longer learn. They just kind of make circles or do random stuff. They aren't dying that often (their fitness starts at 1 but if they hit food before they hit a trap they wont die just lose a fitness) but they aren't learning anymore. I tried normalizing (dividing by the env square side length) but didnt change anything. So is the issue with the inputs or something else?
If I understand well, your neural net have 4 inputs. But let's take this example :


The black circle is your creature
Grey circles are your sensors
Green circle is food
Red circle is a trap




Does the left sensor "see" the trap closer than the food ?

If yes, you're doing it wrong

A better way to do it would be to "simulate" real eyes, like this, where each sensor can only see what is in its field of view



Your neural net can take 2 inputs per sensor, as you did, with the distance to the closest food/trap it can see.

A second thing to try would be to only take in account the closest item for each sensor.

Another interesting thing to do would be to decrease the fitness over time, avoiding passive bots