Skip to content

yava-code/noitarl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

78 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ§™β€β™‚οΈ Noita RL β€” Reinforcement Learning Agent for Noita

Python License Build

Train an AI agent to play Noita β€” the physics-based roguelike β€” using reinforcement learning (PPO).

🎯 Goal: Teach an agent to navigate, fight, and survive in Noita's procedurally generated world using only pixel observations and game state data.


✨ Features

  • PPO Training β€” Proximal Policy Optimization with custom reward shaping
  • Lua-Python Bridge β€” Real-time communication between Noita's Lua mod and Python training loop via pollnet.dll
  • Custom Environment β€” Gym-compatible wrapper with pixel observations, health, mana, and inventory state
  • Episode Tracking β€” Automatic logging of rewards, deaths, and progression metrics
  • CI/CD β€” Automated tests on every push

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         pollnet.dll         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Noita Game    β”‚ ◄─────────────────────────► β”‚  Python Trainer  β”‚
β”‚   (Lua Mod)     β”‚        TCP / Shared          β”‚  (PPO Agent)     β”‚
β”‚                 β”‚         Memory               β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                                                  β”‚
       β–Ό                                                  β–Ό
  Game State                                         Neural Network
  - Pixel buffer                                     - CNN encoder
  - HP / Mana                                        - Policy head
  - Inventory                                        - Value head
  - Position                                         - Reward shaping

πŸš€ Quick Start

Prerequisites

  • Python 3.10+
  • Noita (Steam) β€” must be installed and launched at least once
  • Windows (for pollnet.dll integration)

Installation

# Clone the repository
git clone https://github.com/yava-code/noitarl.git
cd noitarl

# Install dependencies
pip install -r requirements.txt

# Copy and configure environment
cp .env.example .env
# Edit .env with your Noita path and training settings

Training

# Start training
python train.py

# Evaluate a trained model
python eval.py --checkpoint checkpoints/latest.pt

Configuration

Key settings in config.py:

Parameter Default Description
NOITA_PATH Auto-detect Path to Noita installation
LEARNING_RATE 3e-4 PPO learning rate
GAMMA 0.99 Discount factor
BATCH_SIZE 256 Training batch size
MAX_STEPS 10_000_000 Total training steps

πŸ“Š Training Progress

Metric Value
Episodes logged See data/episode_history.csv
Best reward Tracked in training logs
Checkpoints Saved to checkpoints/

πŸ“ Project Structure

noitarl/
β”œβ”€β”€ train.py              # Main training script
β”œβ”€β”€ eval.py               # Evaluation script
β”œβ”€β”€ config.py             # Configuration parameters
β”œβ”€β”€ callbacks.py          # Training callbacks & logging
β”œβ”€β”€ init.lua              # Noita Lua mod (game-side)
β”œβ”€β”€ bin/
β”‚   └── pollnet.dll       # Lua-Python communication library
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ episode_history.csv   # Episode metrics
β”‚   └── schemas/              # Game state XML schemas
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ lua_api_documentation.txt
β”‚   β”œβ”€β”€ component_documentation.txt
β”‚   └── Noita-ModdingAgreement-v100.rtf
β”œβ”€β”€ .github/workflows/
β”‚   └── tests.yml         # CI pipeline
└── ROADMAP.md            # Development roadmap

πŸ—ΊοΈ Roadmap

See ROADMAP.md for the full development plan.

Current priorities:

  • Improve reward shaping for exploration
  • Add multi-objective training (survival + progression)
  • Implement curriculum learning
  • Add wandb integration for experiment tracking

🀝 Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


πŸ™ Acknowledgments

  • Noita by Nolla Games β€” incredible game with amazing modding support
  • Stable Baselines3 β€” RL framework
  • pollnet β€” Lua-Python communication library

Made with ❀️ and a lot of dead agents

About

Reinforcement Learning agent for Noita - train AI to play the roguelike using PPO and custom Lua-Python bridge

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors