An agent-based model of ancient economies, designed for archaeological exploration. Built with Python and PySide6 (Qt).
A small classical/Roman-era town where merchants of three social classes (elite, middle, poor) move around a grid, trade with each other when they meet, build trust over repeated successful trades, earn daily income from their work, pay daily expenses and can go bankrupt if they run out of money.
Despite simple rules, the model produces emergent inequality, social mobility, bankruptcy patterns and class stratification, phenomena directly relevant to archaeological evidence.
- Install Python 3.9 or later.
- From the project folder, install dependencies:
This installs PySide6 (Qt for Python) and matplotlib.
pip install -r requirements.txt
python main.py
- Modern Qt-based interface with light and dark themes (Ctrl+T)
- Dockable Parameters panel β drag the header to undock or reposition
- Five chart tabs: trajectories, distribution, histogram, bankruptcies, summary
- Multi-run averaging for proper statistical analysis
- CSV and JSON export for further analysis in Excel, R, or Python
- Configuration save/load for reproducible experiments
- Live progress with elapsed time and ETA
- Hover tooltips explaining every parameter
- Input validation with helpful error messages
market_town/
βββ main.py β entry point
βββ simulation/ β model logic (Qt-independent)
β βββ merchant.py β Merchant agent
β βββ town.py β population builder
β βββ engine.py β simulation loop
βββ ui/ β Qt user interface
β βββ main_window.py β main window with docks/menus/toolbar
β βββ controls_panel.py β parameter controls
β βββ results_panel.py β chart tabs
β βββ parameter_row.py β reusable slider+spinbox widget
β βββ worker.py β background simulation thread
β βββ styles.py β Qt stylesheet generator
βββ data/ β data handling
β βββ config.py β defaults, themes, validation
β βββ exporter.py β CSV/JSON export
βββ results/ β saved output (auto-created)
- F5 β Run simulation
- Ctrl+T β Toggle light/dark theme
- Ctrl+S β Save configuration
- Ctrl+O β Load configuration
- Ctrl+Q β Quit