ANN Zoo

Turtles learn to race

Here we have a bunch of turtles learning to race around a track. Each turtle tries to learn to go around the track quickly. At each moment, the turtles must decide to turn left or right or go straight. If a turtle hits the left or the right walls of the course, they stop racing. The turtles are rewarded for making it as far through the course as they can.

Once all the turtles have stopped racing, or once a certain number of laps have been completed, then they learn a little and try again. You can speed up the learning process by increasing the Speed hyperparameter. A genetic algorithm is used to select turtles for the next race based on how far the turtles made it in the last race.

The thick white line is the next checkpoint that the lead turtle is trying to reach. The green lines extending from the lead turtle are the turtle's sight lines.

Actions



Options


The brain of each turtle is a neural network with inputs of how far away the turtle is from a wall in front and possibly left or right, along the turtle's sight lines. The two outputs are the angle to turn left or right and the speed that the turtle runs.

The turtles use their brains for every frame. The network can be visualized with neurons as circles and the connections between those neurons as lines. The network can be visualized with neurons as circles and the connections between those neurons as lines. The thicker the lines, the stronger the connection. Black connections are positive , and red connections are negative.

The bars to the left of the input neurons indicate what the first turtle 'sees' right now.

Hyperparameters

Speed: 1
Track Difficulty: 1
Size: 100
Max checkpoints: 200
Mutation rate: 0.20
Lifespan: 30
Sight distance: 50
Sights max angle: 45
Neurons: 6