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