This package contains a complete agent-based modeling simulation of the Telephone game with trust dynamics. The simulation models 1,000 agents in a chain, each potentially altering a 6-character string based on their trust in other agents.
telephone_game_app/- Flask web applicationsimulation.py- Core simulation logicmain.py- Command-line simulation runnerplot_trust.py- Visualization scripttrust_scores.txt- Sample simulation resultsaverage_trust_score.png- Sample visualization
- Python 3.8 or higher
You can modify the simulation parameters in the code:
NUM_AGENTS: Number of agents in the chain (default: 1,000 for web, 10,000 for CLI)NUM_TIMESTEPS: Number of simulation rounds (default: 50 for web, 100 for CLI)- Learning rates and trust update mechanisms can be adjusted in
simulation.py
- Agents start with neutral trust (0.5) in all other agents
- Trust is updated based on observed deviations between input and output
- Agents adjust their behavior based on average trust levels
- Agents with low trust in others are more likely to alter messages
- Agents with high trust in others are less likely to alter messages
- Behavior changes gradually over time (humanistic behavior)
- Each agent remembers past interactions and outcomes
- Memory is used to evaluate performance and update trust
The simulation typically shows one of three patterns:
- Trust Decline: Trust decreases over time as agents observe message distortion
- Trust Increase: Trust increases as agents prove reliable
- Trust Stabilization: Trust reaches an equilibrium
The web interface provides:
- Real-time visualization of trust evolution
- Statistical summary of simulation parameters
- Analysis of convergence patterns
Edit simulation.py to change:
- Trust update algorithms
- String alteration probability
- Learning rates
- Memory mechanisms
Edit telephone_game_app/src/static/index.html to modify:
- Visual appearance
- User interface elements
- Analysis text
The Flask application in telephone_game_app/src/main.py can be extended with:
- Parameter controls
- Different visualization types
- Export functionality
- Real-time updates
Use the instructions above for local testing and development.
For production deployment, consider:
-
Using a production WSGI server
pip install gunicorn gunicorn -w 4 -b 0.0.0.0:5001 main:app
-
Docker deployment Create a Dockerfile:
FROM python:3.11-slim WORKDIR /app COPY . . RUN pip install -r requirements.txt EXPOSE 5001 CMD ["python", "src/main.py"]
-
Cloud platforms
- Heroku: Add
Procfilewithweb: python src/main.py - AWS/GCP: Use container services or serverless functions
- DigitalOcean App Platform: Direct deployment from Git
- Heroku: Add
-
Port already in use
- Change the port in
main.py:app.run(host='0.0.0.0', port=5002)
- Change the port in
-
Module not found errors
- Ensure you're running from the correct directory
- Activate the virtual environment
-
Slow simulation
- Reduce
NUM_AGENTSorNUM_TIMESTEPSfor faster results - The web interface uses smaller values by default
- Reduce
-
Memory issues
- Reduce the number of agents for large simulations
- Clear agent memory periodically if needed
For large-scale simulations:
- Use numpy arrays instead of Python lists
- Implement parallel processing for agent updates
- Use database storage for large memory requirements
- Consider distributed computing for very large agent populations
This simulation can be used to study:
- Trust dynamics in social networks
- Information propagation and distortion
- Collective behavior emergence
- Game theory applications
- Multi-agent system design
This simulation is provided for educational and research purposes. If you use this code in academic work, please cite appropriately.
For questions or issues:
- Check the troubleshooting section above
- Review the code comments for implementation details
- Modify parameters to suit your specific research needs
Note: This simulation demonstrates complex emergent behavior. Results may vary between runs due to the stochastic nature of agent decisions and random string generation.