Skip to content

TomasBrezina/NeuralNetworkRacing

Repository files navigation

NeuralNetworkRacing

Neural network learns how to drive a car on a track. Simple 2D simulation with pyglet & numpy.

nnr.preview.mp4

Install packages

pip install -r requirements.txt

pyglet
numpy
pillow

Config

config.json

{
    "width": 1280
    "height": 720
    "friction": 0.1
    "render_timestep": 0.025 // time between frames in seconds - 0.025s = 40 FPS
    "timeout_seconds": 30 // maximum time for each gen
    "population": 40 // number of cars
    "mutation_rate": 0.6 // mutation rate after gen
}

default_nn_config.json - Default car config for new saves.

{
    "name" : "test" 
    "acceleration": 1
    "friction": 0.95
    "max_speed": 30 
    "rotation_speed": 4
    "shape": [6, 4, 3, 2] // neural network shape - do not change first and last layer
    "max_score": 0
    "gen_count": 0
}

NEURAL NETWORK

nn-architecture

EVOLUTION

Best cars in each generation are chosen to be the parents of the next, slightly mutated generation.

ENVIROMENT & TRACK GENERATION

image track-generation

Releases

No releases published

Packages

No packages published

Languages