Project Info
Inspiration
While we have worked a lot with AI in machine learning models and computer vision, our team had yet to work with agentic LLMs, especially using LangChain. After stumbling through ideas, we decided we wanted to simulate the mediation of political leaders going through different crisis'.
What it does
Our program generates AI leaders with unique personalities, backgrounds, and qualities. It then generates conflicts or natural disasters that occur between countries, leading to disputes that need to be addressed and resolved through the mediation of the user. They each have their own voices (provided by Google Cloud), so they can argue with each other or reach agreements.
How we built it
We used Python, LangChain, and Google Cloud to bring our backend together. We used Javascript, Flask and HTML for our frontend.
Challenges we ran into
We had a lot of trouble trying to create a web application implementing FastAPI with LangChain. We ended up switching to a more cohesive program with Flask.
Accomplishments we're proud of
We are proud we were able to design a simple UI. We were also proud to include many features, including AI generated speech and agentic LLMs, both of which were completely new to us.
What we learned
We learned how to make concise system prompts, make multiple models taking input from each other, and how to use Google Cloud TTS.
UN Diplomatic Simulation - Web Version
A sophisticated diplomatic simulation powered by Claude AI where you act as the UN Secretary-General, mediating international crises between AI-powered world leaders.
Features
- AI-Powered Leaders: Each country is led by a unique AI personality with distinct traits (honest, ambitious, empathetic, diplomatic, ruthless)
- Dynamic World State: Countries have evolving relationships, economic power, military strength, and populations
- Complex Events: Handle border disputes, economic crises, humanitarian disasters, and more
- Real-Time Diplomacy: Engage in multi-round diplomatic meetings with Claude AI generating realistic responses
- Consequence System: Your decisions have lasting impacts on the world state
- Time Progression: World evolves over multiple sessions with new challenges emerging
Setup Instructions
Prerequisites
- Python 3.8 or higher
- Claude API key from Anthropic
Installation
-
Clone or download the project files
# Ensure you have these files: # - index.html # - game.js # - server.py # - requirements.txt # - .env.template -
Install Python dependencies
pip install -r requirements.txt -
Set up environment variables
# Copy the template file cp .env.template .env # Edit .env and add your Claude API key # Replace 'your_claude_api_key_here' with your actual API key -
Get a Claude API key
- Visit Anthropic's website
- Sign up for an account and obtain an API key
- Add the key to your
.envfile
Running the Application
-
Start the Flask backend
python server.pyThe server will start on
http://localhost:5000 -
Open the web application
- Important: Go to
http://localhost:5000in your browser - Do NOT open
index.htmldirectly (this causes CORS errors)
- Important: Go to
Alternative - Easy startup:
python run.py
This will automatically start the server and open your browser to the correct URL.
Game Instructions
-
Start a New Game
- The game initializes with 3 countries, each with unique AI leaders
- Leaders have different personality traits that influence their behavior
-
Select Events
- Choose 1-3 events from the sidebar to address in your meeting
- Events represent international crises requiring diplomatic intervention
-
Conduct Diplomatic Meetings
- Start a meeting to begin multi-round discussions
- AI leaders will discuss the selected events based on their personalities
- Participate as the UN Secretary-General by sending messages
-
Make Diplomatic Interventions
- Your words influence the leaders and can change relationship dynamics
- Different approaches yield different outcomes
-
Manage Consequences
- Addressed events may be resolved or evolve
- Unaddressed events can escalate and cause problems
- The world state evolves over time
-
Progress Through Time
- After each meeting, the world advances by 6 months
- New events emerge and relationships change
- Your diplomatic legacy shapes the world's future
Technical Details
Architecture
- Frontend: Pure HTML/CSS/JavaScript
- Backend: Flask with Claude API integration
- AI Engine: Anthropic's Claude for generating leader personalities and responses
API Endpoints
POST /api/new-game- Initialize a new game sessionPOST /api/conduct-round- Process a round of diplomatic discussionPOST /api/end-meeting- Conclude a meeting and analyze outcomesPOST /api/time-skip- Advance the world state by 6 months
Game State
The game maintains a complex world state including:
- Countries: Economic power, military strength, population
- Leaders: Personality traits, backstories, ages
- Relationships: Dynamic diplomatic relations between countries
- Events: International crises with evolution over time
Troubleshooting
Common Issues
-
"Connection error" message
- Ensure the Flask server is running on port 5000
- Check that your Claude API key is correctly set in the
.envfile
-
No AI responses
- Verify your Claude API key is valid and has sufficient credits
- Check the browser console for JavaScript errors
-
Flask server won't start
- Ensure all dependencies are installed:
pip install -r requirements.txt - Check that port 5000 is not in use by another application
- Ensure all dependencies are installed:
Development Notes
- The game uses session-based state management
- Each game session maintains an independent world state
- AI responses are generated in real-time using Claude API calls
- The frontend automatically handles loading states and error recovery
Customization
Adding New Events
Edit the generate_events() function in server.py to add new crisis scenarios.
Modifying Leader Traits
Adjust the personality generation in the generate_leader() function to create different leader archetypes.
Changing Game Flow
Modify the round limits, time skip intervals, or consequence systems in the GameSession class.
Credits
Based on the original terminal-based diplomatic simulation. Adapted for web deployment with Claude AI integration for enhanced realism and dynamic storytelling.
Analysis
View
Metric
No commits on this project resolved to a GitHub account.
Technology
- FlaskIn code
- HTMLIn code
- JavaScriptIn code
- PythonIn code
- LangChainClaimed
4 of 5 appear in the indexed code. 1 claimed on Devpost could not be matched to code, which may simply mean the tool leaves no trace in the repository.
AI coding agents
No AI coding agent signals were found in this repository.
Detected from committed agent config files and commit authorship. Absence of a signal is not proof an agent was unused.
Codebase size
Source size
117 KB
Source files
10
Counts recognized source files only; vendored directories, binaries and lockfiles are excluded, so this is smaller than the repository on disk.
Repository
YugrajD/The-Moderator
15 files · 177 KB · @ 54aaaf2
Structure
Interface
1 file · 7%Screens, components and styles rendered to the user.
Application logic
6 files · 40%Domain rules, services and shared utilities.
Supporting
Layers are inferred from where files sit in the tree, not from reading the code. A project that names its directories unconventionally will read oddly here — open the file browser to check anything the diagram implies.
Languages
- Python44%
- JavaScript26%
- HTML18%
- Markdown12%
Share of indexed source by file size. Binary and vendored files are excluded.
Dependencies
requirements.txt
pypi · 5- flask
- flask-cors
- google-cloud-texttospeech
- langchain-anthropic
- python-dotenv
Declared in the repository’s manifests at the indexed commit. A declared package is not proof it is used, and runtime dependencies are listed first.
This project’s features have not been analysed yet.
Export this project's context (description, README, evidence, key source files) to chat with an AI agent elsewhere.