An AI that teaches itself to ski through a gate slalom course, trained from scratch using NEAT (NeuroEvolution of Augmenting Topologies), a genetic algorithm that evolves neural network and topology together, no backpropagation involved.
A population of skiers starts with no idea how to ski. Each one is controlled by a small neural network with random weights, and gets a score based on how well it navigates through a procedurally generated slalom course (alternating red/blue gates). Skiers that crash out or miss gates die early, skiers that clear gates and survive get to reproduce.
Over many generations, NEAT evolves both the network's weights and its structure, adding or removing neurons and connections, until the population reliably skis through gate after gate on its own, with no hardcoded skiing logic anywhere in the code.
- Inputs (4): the skier's horizontal velocity, its horizontal position, its horizontal offset from the next gate, and its vertical distance to the next gate.
- Outputs (4): steer left, steer right, accelerate, brake.
- Fitness function: rewards passing through gates and staying near the center line, penalizes crashing, going out of bounds, or steering left and right simultaneously.
- Each generation,
neat-pythonhandles selection, crossover, mutation, and speciation based onconfig-feedforward.txt.
├── SkAI_NEAT.py
├── SkAI_winner_run.py
├── config-feedforward.txt
├── requirements.txt
├── img/
│ ├── demo.gif
│ └── kenney/ # Tile/sprite assets (see Credits)
└── winners_pickle/ # Examples of saved genomes
- Python 3.8+
- pygame
- neat-python
0.92
pip install -r requirements.txtpython SkAI_NEAT.pyThis runs up to 500 generations (or fewer, if a genome hits the fitness threshold first) and saves the winning genome into winners_pickle/ as a timestamped .pkl file.
Controls while training:
S— slow mode (runs at 60 FPS so you can actually watch it)F— fast mode (uncapped framerate, for faster training)Esc— quit
python SkAI_winner_run.pyYou'll be prompted for a timestamp, enter the one matching a file in winners_pickle/, for example:
Date and time winner's training : 20260720-211908
- Art assets: "Tiny Ski" tileset by Kenney, used under CC0.
- Built with neat-python, an implementation of Kenneth Stanley and Risto Miikkulainen's NEAT algorithm.
The code in this repository is licensed under the MIT License. Third-party assets (Kenney tileset, neat-python) retain their own separate licenses as noted above.
