[P] I built an AI that teaches itself to play Mario from scratch using Python — it starts knowing absolutely nothing
Hey everyone!
I built a Mario AI bot that learns to play completely by itself using Reinforcement Learning. It starts with zero knowledge it doesn’t even know what “right” or “jump” means — and slowly figures it out through pure trial and error.
Here’s what it does:
- Watches the game screen as pixels
- Tries random moves at first (very painful to watch )
- Gets rewarded for moving right and penalized for dying
- Over thousands of attempts it figures out how to actually play
The tech stack is all Python:
- PyTorch for the neural network
- Stable Baselines3 for the PPO algorithm
- Gymnasium + ALE for the game environment
- OpenCV for screen processing
The coolest part is you can watch it learn in real time through a live window. At first Mario just runs into walls and falls in holes. After a few hours of training it starts jumping, avoiding enemies and actually progressing through the level.
No GPU needed — runs entirely on CPU so anyone can try it!
🔗 GitHub: https://github.com/Teraformerrr/mario-ai-bot
Happy to answer any questions about how it works!
submitted by /u/Southern-Site4143
[link] [comments]