Skip to content

harishkotra/pathpact

Repository files navigation

🛣️ PathPact: Multi-Agent AI Pathfinding

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.

Video Demo

Screenshots

Screenshot at Mar 25 10-14-44 Screenshot at Mar 25 10-15-03 Screenshot at Mar 25 10-15-12 Screenshot at Mar 25 10-15-43 Screenshot at Mar 25 10-16-17 Screenshot at Mar 25 10-16-31 Screenshot at Mar 25 10-16-41 Screenshot at Mar 25 10-17-00 Screenshot at Mar 25 10-17-09 Screenshot at Mar 25 10-17-20

Key Features

  • 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.).

Tech Stack

  • 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

Architecture

The application follows a clean, service-oriented architecture:

  1. Map Service: Handles geocoding (Nominatim) and route fetching (OSRM).
  2. Gemini Service: Manages the AI negotiation protocol, converting route data into a structured prompt for the LLM.
  3. Map Component: A highly optimized React component for rendering complex geospatial data and animations.
  4. State Management: Centralized in App.tsx using React hooks for reactive UI updates.

AI Negotiation Flow

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]
Loading

Code Snippets

Agent Personality Definition

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
];

AI Negotiation Prompt Logic

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.
`;

Getting Started

Prerequisites

  • Node.js 18+
  • A Google Gemini API Key

Installation

  1. Clone the repository:

    git clone https://github.com/harishkotra/pathpact.git
    cd route-negotiator
  2. Install dependencies:

    npm install
  3. Set up environment variables: Create a .env file in the root:

    VITE_GEMINI_API_KEY=your_api_key_here
  4. Run the development server:

    npm run dev

Contributing

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.

How to contribute:

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Built with ❤️ by Harish Kotra Follow more builds at dailybuild.xyz

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages