Most game AIs are fake smart.
Patterns, scripts, predictable behavior.
Block-Reign isn’t.
This is a lightweight Player vs AI grid battle game where the AI actually learns from every match you play — wins, losses, mistakes, all of it.
No GPU.
No fancy engines.
Just Python, reinforcement learning, and persistence.
🕹️ What Is Block-Reign?
Block-Reign is a 10×10 grid-based Player vs AI combat game built with:
- Flask + HTML for the frontend
- Python for the game server
- Reinforcement Learning (Q-Learning) for live gameplay
- DQN for advanced offline experimentation
You play in the browser.
The AI plays on the server.
After every match, it gets smarter.
🤖 The AI Philosophy
The core idea was simple:
What if the AI learned only from real games — not pre-trained data?
So the AI:
- Starts dumb
- Learns only from actual matches
- Saves its knowledge permanently
- Adapts to your playstyle
No synthetic data.
No scripted behaviors.
Just experience.
🧠 How Learning Works
- The running server uses a Q-learning AI
- After each completed match:
- Match data is sent to the server
- The AI updates its Q-table
- Progress is saved on disk
- Restart the server → the AI remembers everything
The project also includes a DQN trainer (ai_trainer.py) for experimentation.
📊 Current AI Progress
As of the latest run:
- Win rate: ~59%
- Matches played: 78
- Record: 46 Wins / 36 Losses
These stats are not hardcoded.
They are learned, stored, and persisted.
Delete the training folder, and the AI forgets everything.
🎮 Gameplay
- 10×10 grid
- Arrow keys to move
- Space to shoot
- Simple mechanics, strategic positioning
- Fast matches, instant feedback
Minimal visuals.
Maximum behavior learning.
🔁 Resetting the AI
Delete:
training/
or:
training/models/simple_ai.pkl
Restart the server and play again.
The AI starts from scratch.
🛠️ Why I Built This
This project wasn’t about graphics or polish.
It was about:
- Understanding reinforcement learning
- Watching an AI evolve organically
- Building adaptive systems without massive compute
🔗 Repository
https://github.com/DeveloperPuneet/Block-Reign
Final Thought
Block-Reign isn’t perfect.
But it’s honest.
An AI that earns its intelligence one loss at a time.
And nah — this isn’t the end.
Wilder strategies. Sharper gameplay. Better graphics.
Something crazier is coming. Wait for it 👀
Have any suggestions? comment
