This repository serves as a high-fidelity Computational Model for distributed multi-agent systems (MAS) operating in stochastic, high-entropy environments. By simulating a decentralised naval fleet, the project explores the intersection of Consensus Protocols (Raft-lite), Probabilistic State Synchronization, and Spatial Optimization.
The model demonstrates how complex collective behavior—such as adaptive leadership and resilient task allocation—can emerge from simple, deterministic local rules even when the underlying communication graph is 60% disconnected.
Rather than assuming ideal communications, the core simulation layer implements a Bernoulli Loss Model (
The system utilizes a Term-Based Epoch System to enforce linearizability in a distributed environment. This prevents the "Split-Brain" syndrome common in multi-agent systems. The model uses:
- Heuristic ID Priority: A deterministic tie-breaker for leader election.
- Lease-based Heartbeats: Using temporal locks to maintain authority without centralized control.
Task allocation is modeled as a greedy spatial assignment problem. The Leader agent computes the Euclidean distance matrix
Traditional elections fail when "zombie" nodes reappear after a network lapse. Our Epoch/Term system ensures:
- Zero Confusion: Agents only obey the latest Term.
- Rapid Failover: New leader emerges in < 2.5 seconds when a crash is detected.
- Conflict Resolution: Deterministic ID-based "Bully" protocol for identical Terms.
When the network is jammed, a single "Assign" command isn't enough.
- Persistence: The Leader uses a 40% probability gossip loop to "re-whisper" active assignments.
- Reliability: 10/10 Robots confirmed task completion even under extreme stress tests.
Prevents "Task Flip-Flopping" during network jitters.
- Assignments are HARD LOCKED for 60s (
TASK_STABILITY_TIME). - Robots commit to their objective even if they momentarily lose contact with the fleet.
Witness the swarm in action. The visualizer simulates an Attrition Warfare scenario where leaders are systematically "killed" (removed) every 20-40 seconds.
# Run the real-time naval tactical display
python verify_visual.py| Asset Class | Symbol | Asset Class | Symbol |
|---|---|---|---|
| Optical Camera | C |
Thermal Sensor | T |
| LIDAR System | L |
Acoustic Sensor | A |
| Manipulator Arm | M |
Electronic Scanner | E |
| Payload Delivery | P |
Defensive Module | D |
| Scenario | Objective | Stress Level | Result |
|---|---|---|---|
| Leader Stability | Single stable leader emergence | Low | ✅ PASSED |
| Kill Chain | Crash recovery < 3.0s | High | ✅ PASSED |
| Scalability | 10 Assets (Heterogeneous) | Variable | ✅ PASSED |
| Electronic Warfare | 60% Packet Loss / Jamming | Extreme | ✅ PASSED |
The core agent is a Finite State Machine (FSM) designed for predictability:
tick: Global clock synchronization.receive: High-speed inbox processing.elect: Decoupled leader logic.assign: Gossip-based task distribution.work: Async execution with completion callbacks.
Every agent generates tagged logs for post-mission analysis:
[INFO] (Id: 1) Term 3: I am now the LEADER.[WARN] (Id: 4) Conflict! Yielding to higher term Leader 1.
-
Clone the Mission Data:
git clone https://github.com/sauravkeshrii/fault-tolerant-swarm-simulation- cd fault-tolerant-swarm-simulation- -
Run Stress Tests:
python verify_stress.py # 60% Packet Loss verification python verify_failure.py # Leader Crash verification
-
Launch the Visualizer:
python verify_visual.py
| Category | Tools & Technologies |
|---|---|
| Language | Python 3.8+ |
| Libraries | math, time, random, logging, enum (Standard Library) |
| Simulation | Custom Discrete-Event Environment |
| Visualizer | ANSI-Terminal Graphics / ASCII Render Engine |
| Modeling | Distributed State Machines & Stochastic Graph Theory |
This project is released under the MIT License.
Copyright (c) 2026
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
