💡 About the Project
The Inspiration
During HackNotts 2025, we set out to build something that combined our passion for economics, artificial intelligence, and game design. We were inspired by several converging ideas:
- Complex Systems: How can chaos theory explain market behavior?
- Emergent Intelligence: What happens when multiple AI agents with different strategies interact?
- Economic Realism: Can we simulate central bank policy effects in a game?
- Medieval Aesthetics: Why not make economics visually interesting with a fantasy theme?
This led to Chronomarket — a dual-application economic simulation that feels like a game but demonstrates serious mathematics and AI principles.
What We Learned
Building Chronomarket challenged us to master multiple domains:
Mathematical Modeling
We implemented:
- Stochastic differential equations for price dynamics using Geometric Brownian Motion
- Markov Chain Regimes with transition matrices:
$$ P_{ij} = P(\text{Regime}_j \mid \text{Regime}_i) $$ - Monte Carlo simulations with $N = 1000$ scenarios for forecasting
- Entropy calculations using the Gini coefficient and Shannon entropy:
$$ G = \frac{2\sum_{i=1}^{n}(i \cdot x_i)}{n \sum_{i=1}^{n}x_i} - \frac{n + 1}{n} $$ $$ H(X) = -\sum_{i} P(x_i) \log_2 P(x_i) $$
Reinforcement Learning
We trained trading agents using:
- Deep Q-Networks (DQN):
$$ Q(s, a) = \text{NN}(\mathbf{s}) $$ - Policy Gradient methods:
$$ \pi(a \mid s) = \text{softmax}(\text{NN}(\mathbf{s})) $$ - Real-time learning from market feedback
Distributed Systems
We created a real-time shared state system allowing two apps — Streamlit (analytics) and Pygame (visualization) — to sync seamlessly, demonstrating concepts from event-driven architecture and inter-process communication.
Economic Modeling
We simulated central bank policy with interest rate adjustments affecting prices through:
$$
\Delta P_{\text{grain}} = -5 \cdot \Delta r, \quad \Delta P_{\text{gold}} = +3 \cdot \Delta r
$$
How We Built It
Timeline: Built in 24 hours for HackNotts 2025
Stack:
- Frontend: Streamlit (analytics), Pygame (visualization)
- Backend: Python with FastAPI
- AI/ML: Custom RL agents, sentiment analysis
- Database: SQLite with SQLAlchemy
- Math: NumPy, SciPy for stochastic processes
Architecture Decision:
We chose a dual-application architecture — one for deep analytics (Streamlit), one for intuitive visualization (Pygame). This required a robust shared_state.py synchronization layer that broadcasts events between apps in real-time.
Key Systems Built:
- Chaos Engine – Calculates entropy and triggers market events
- Markov Regime System – Models market states with five regimes
- Monte Carlo Forecaster – Generates probabilistic price paths
- RL Agent Framework – DQN and Policy Gradient implementations
- Treasury Simulator – Central bank with policy stance determination:
$$ PS = 2(H - 0.5) - 2C - 1.5(1 - S) $$ - Auto Price System – Mean reversion with circuit breakers:
$$ \Delta P = R + M + C + T \in [-0.05, +0.05] $$
Challenges Faced
1. Mathematical Complexity
Challenge: Implementing proper stochastic processes that are both mathematically rigorous and computationally efficient.
Solution: Used Geometric Brownian Motion with mean reversion, jump diffusion for chaos events, and correlated random walks for multi-asset dynamics.
2. Real-Time Synchronization
Challenge: Keeping Streamlit and Pygame in sync when both have different update cycles.
Solution: Built an event broadcasting system with shared_state.py using thread-safe queues. Events propagate instantly, positions sync every 0.5 seconds.
3. Performance Optimization
Challenge: Running 1000+ Monte Carlo simulations without blocking the UI.
Solution: Implemented threading for auto-price updates, efficient NumPy vectorization for simulations, and caching for frequent calculations.
4. LaTeX Rendering
Challenge: Displaying complex mathematical formulas in Markdown.
Solution: Implemented LaTeX using $$ for block equations and $ for inline notation to ensure compatibility with GitHub’s MathJax renderer.
5. Emergent Behavior Debugging
Challenge: Tracing why agents made certain decisions when multiple systems (chaos, regimes, treasury) interacted.
Solution: Built analytics tracking every transaction, regime transition, and agent decision, and visualized agent conversations and portfolio evolution.
The Result
Chronomarket is more than a hackathon project — it’s a demonstration of how mathematics, AI, and software engineering converge to create emergent economic behavior.
The system showcases:
- 🧮 10+ academic concepts (stochastic calculus, information theory, game theory, reinforcement learning)
- 🤖 3 types of AI agents (traditional, RL, NLP) trading simultaneously
- 📊 Real-time dual visualization (analytics + game view)
- 🌪️ Chaos-driven dynamics affecting prices, agents, and regimes
- 👑 Policy simulation with treasury interventions
- 📈 Advanced analytics with Sharpe ratios, VaR, and win rates
All in a medieval-themed package that makes complex economics accessible and entertaining!
Future Vision
- Deploy to Ethereum testnet with real blockchain
- Deep RL training with larger networks
- Multiplayer rooms with real users
- Advanced chaos models (Lorenz attractors)
- Historical data backtesting
- Mobile app with React Native
Built with ⚔️ and enthusiasm at HackNotts 2025!
Built With
- brownian
- brownianmotion
- collections
- dataclasses
- datetime
- entropyshannon
- fastapi
- geometric
- ginicoefficient
- json
- markovchains
- montecarlosimulation
- natural-language-processing
- neural
- numpy
- pandas
- plotly
- pygame
- python
- randomjson
- reinforcement
- scipy
- sqlalchemy
- sqlite
- streamlit
- threading
Log in or sign up for Devpost to join the conversation.