PathPact is a sophisticated multi-agent simulation that uses Google Gemini AI to resolve route conflicts between autonomous agents. Each agent has a distinct personality (Speedster, Scenic Cruiser, Efficiency Expert) and must negotiate for the best path based on real-time traffic, weather, and personal preferences.
- AI-Driven Negotiation: Uses Gemini 1.5 Flash to simulate complex reasoning and communication between three distinct agents.
- Real-Time Map Visualization: Built with Leaflet, featuring animated agents, offset paths for overlapping routes, and dynamic map styles.
- Dynamic Routing: Integrates OSRM (Open Source Routing Machine) for accurate road-network pathfinding.
- Environmental Factors: Simulates varying traffic conditions and weather hazards (Rain, Storms, Fog) that influence agent decisions.
- Interactive Simulation: Control simulation speed, toggle traffic layers, and switch between multiple map styles (Standard, Satellite, Dark, etc.).
- Frontend: React 18, Vite, TypeScript
- Styling: Tailwind CSS
- Maps: Leaflet, OpenStreetMap
- AI: Google Gemini 1.5 Flash (
@google/genai) - Animations: Motion (formerly Framer Motion)
- Icons: Lucide React
The application follows a clean, service-oriented architecture:
- Map Service: Handles geocoding (Nominatim) and route fetching (OSRM).
- Gemini Service: Manages the AI negotiation protocol, converting route data into a structured prompt for the LLM.
- Map Component: A highly optimized React component for rendering complex geospatial data and animations.
- State Management: Centralized in
App.tsxusing React hooks for reactive UI updates.
graph TD
A[Fetch Routes] --> B[Prepare Agent Profiles]
B --> C[Construct AI Prompt]
C --> D[Gemini 1.5 Flash Reasoning]
D --> E[Structured Negotiation Result]
E --> F[Route Assignment & Simulation]
export const AGENTS: Agent[] = [
{
id: "speedster",
name: "The Speedster",
emoji: "🚗",
personality: "Aggressive and time-sensitive. Values speed above all else.",
preferences: { speed: 0.9, safety: 0.2, scenic: 0.1, ... }
},
// ... other agents
];const prompt = `
You are a traffic coordinator for three autonomous agents:
${AGENTS.map(a => `- ${a.name}: ${a.personality}`).join('\n')}
Available Routes:
${routes.map(r => `- Route ${r.id}: ${r.duration}s, Traffic: ${r.trafficStatus}`).join('\n')}
Negotiate and assign exactly one route per agent. Provide a transcript of their reasoning.
`;- Node.js 18+
- A Google Gemini API Key
-
Clone the repository:
git clone https://github.com/harishkotra/pathpact.git cd route-negotiator -
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile in the root:VITE_GEMINI_API_KEY=your_api_key_here
-
Run the development server:
npm run dev
Contributions are welcome! Here are some ideas for new features:
- Dynamic Traffic Updates: Implement a system where traffic changes during the journey.
- Multi-City Support: Allow routes to span across multiple cities or countries.
- Agent Memory: Let agents remember past negotiations and build "relationships."
- Custom Agent Creator: A UI to define your own agent personalities and preferences.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Built with ❤️ by Harish Kotra Follow more builds at dailybuild.xyz