SkillAgentSearch skills...

NeuralNetworkRacing

Neural networks race (demo)

Install / Use

/learn @TomasBrezina/NeuralNetworkRacing
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

NeuralNetworkRacing (demo)

[!NOTE]
I decided to remake this old project from scratch in C# and Godot, turning it into a sandbox simulation game. I've added new features like a track editor and neural network editor, with more to come! If you'd like to support me, please wishlist AI Learns To Drive on Steam 💖 available_on_steam

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

https://user-images.githubusercontent.com/46631861/161601803-30c7b0d2-ae7f-4145-b3fa-95378e36cd19.mp4

[!WARNING] This code is a product of my early programming days. I've refactored it, but it might not align with current best practices.

▶️️ HOW TO RUN?

Install packages

pip install -r requirements.txt

https://github.com/TomasBrezina/NeuralNetworkRacing/blob/e6ff65a77d38f0cdad01690a0a770a9eb9c2da2a/requirements.txt#L1-L3

Run main file

Should work with Python 3.0 and higher.

For example:

py -3.10 .\__main__.py

Or use a virtual environment.

Config (Optional)

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 | |--|--|

⚖️ LICENSE

Shield: CC BY-NC 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

CC BY-NC 4.0

View on GitHub
GitHub Stars276
CategoryEducation
Updated18d ago
Forks36

Languages

Python

Security Score

85/100

Audited on Mar 11, 2026

No findings