Each agent is a tiny feedforward neural network. Three range sensors (fired at -45°, 0°, +45° from its heading) and a normalized bearing-to-target angle form a 4-value input vector. The network has one hidden layer of 6 tanh neurons and outputs two values: turn rate and forward speed.
h = tanh(W1·x + b1) x ∈ R^4, h ∈ R^6
y = tanh(W2·h + b2) y ∈ R^2 (turn, speed)
turnRate = y0 · maxTurn
speed = (y1+1)/2 · maxSpeed
fitness = 1 / (1 + distance(pos, target))
Every generation lasts 12 simulated seconds. When it ends (or you force it), the network with the highest fitness survives unchanged (elitism) and every other agent's weights are re-seeded from it plus Gaussian noise scaled by the mutation strength — a simple (1 + λ) evolutionary strategy pushing the population toward better obstacle-avoidance and homing behavior over generations.
- Population — number of independent neural agents evolving in parallel each generation.
- Mutation strength — standard deviation of the Gaussian noise added to the elite's weights when breeding the next generation.
- Sensor range — maximum distance each agent's three rangefinders can detect an obstacle; shorter range means agents must react later.
- Time scale — speeds up or slows down simulated time relative to real time.
- New Gen — forces evolution immediately using the current best fitness instead of waiting out the timer.
This mirrors real neuroevolution methods (e.g. NEAT-style or evolution strategies) used to train small controllers for robotics and game agents when gradient-based training is impractical.