Use genetic algorithms to evolve a car. The framework currently uses Box2D for the physics engine, pyglet for rendering and imgui for the UI.
The code to 'evolve' the cars from generation to generation has not yet been implemented. This is a work in progress.
Quite a lot of the code in the project is derived from the python Box2D examples.
- Python 3.11 or higher
Pre-built binaries for all supported platforms are available in the GitHub Releases section. Choose the appropriate binary for your platform:
evolve_a_car-linux-x86_64- Linux 64-bit Intel/AMDevolve_a_car-linux-aarch64- Linux 64-bit ARMevolve_a_car-windows-x86_64.exe- Windows 64-bit Intel/AMDevolve_a_car-windows-aarch64.exe- Windows 64-bit ARM (experimental)evolve_a_car-macos-x86_64- macOS Intelevolve_a_car-macos-aarch64- macOS Apple Silicon (M1/M2/M3/M4)
- Install UV -
curl -LsSf https://astral.sh/uv/install.sh | sh - Create virtual environment:
uv venv - Install the dependencies:
uv pip install -e . - On macOS follow the instructions below to fix OpenGL issues
- Run application:
uv run python src/app.py
# Install development dependencies
uv pip install -e ".[dev]"
# Run all tests
uv run pytest tests/ -v
# Run tests with coverage
uv run pytest tests/ --cov=src --cov-report=htmlThe project uses PyInstaller to create standalone executables for Linux, Windows, and macOS.
# Install development dependencies (includes PyInstaller)
uv pip install -e ".[dev]"
# Build binary for your platform
uv run pyinstaller evolve_a_car.spec
# Find the binary in the dist/ directoryThe project uses GitHub Actions for continuous integration and deployment:
- CI Workflow: Runs tests on every push and pull request across Python 3.11-3.12 on Linux, Windows, and macOS
- Build Workflow: Creates standalone binaries for multiple platforms and architectures when a version tag is pushed (e.g.,
v1.0.0). Binaries are uploaded as GitHub release artifacts.
Supported Platforms and Architectures:
- Linux
- x86_64 (amd64) - Fully supported
- ARM64 (aarch64) - Supported using QEMU emulation
- Windows
- x86_64 (amd64) - Fully supported
- ARM64 (aarch64) - Experimental (cross-compilation)
- macOS
- x86_64 (Intel) - Fully supported
- ARM64 (Apple Silicon M1/M2/M3/M4) - Fully supported
To trigger a release build:
git tag v1.0.0
git push origin v1.0.0The build workflow will create binaries for all 6 platform/architecture combinations and attach them to the GitHub release.
- On macOS Big Sur OpenGL is not found see discussion on StackOverflow for details.
- Temporary Fix:
- Find virtual environment path (should be
.venvin the project root) - Open
.venv/lib/python3.x/site-packages/OpenGL/platform/ctypesloader.py - Replace line
fullName = util.find_library( name ) - With line
fullName = "/System/Library/Frameworks/{}.framework/{}".format(name,name)
- Find virtual environment path (should be
