Neural Network Racing AI
Genetic Algorithm-Trained Neural Network for Autonomous Car Racing in C# / MonoGame
A-Level Computer Science Non-Exam Assessment (NEA) at Rochdale Sixth Form College. The simulation renders a real-time top-down race track where a population of cars navigate by feeding sensor readings into a feedforward neural network. Tracks are procedurally generated using a Graham scan on random points, then smoothed with Bezier curves — every run produces a different layout. No car is ever told how to drive; all behaviour emerges from selection pressure across generations.
Training a neural network to drive without labelled training data or a differentiable reward signal rules out backpropagation. The challenge was designing a fitness function, mutation scheme, and selection process that could discover competent driving from a population of randomly-initialised networks.
Implemented in C# and MonoGame. Each car carries a feedforward neural network with sigmoid activations; inputs are five distance-sensor readings to the track edges, outputs are steer/accelerate decisions. Fitness is the total distance driven before crashing. Each generation, the top performers survive and produce offspring via weight mutation. A manual driving mode (WASD), save/load for both tracks and trained networks, and an auto-advance mode were also built.
All NEA objectives met. Cars progress from random thrashing to clean corner-following within tens of generations, visibly improving between each round. Received full marks for the NEA — the examiner's report praised the clarity of the evolutionary loop, the quality of the real-time visualisation, and the depth of the written analysis covering sigmoid functions, feed-forward, backpropagation theory, and the genetic algorithm.
