This project implements an autonomous delivery agent on a 2D grid city.
The agent must plan efficient package delivery routes while navigating:
- Terrain with variable movement costs
- Static obstacles (walls/buildings)
- Dynamic moving obstacles (vehicles)
Implemented planning algorithms:
- BFS – breadth-first search (uninformed, step optimal)
- UCS – uniform-cost search (cost optimal)
- A* – informed search with admissible Manhattan heuristic
- Local Replanning – reactively replans when dynamic obstacles block path
DeliveryAgent/ ├── agent.py # DeliveryAgent class: wraps environment + planner ├── environment.py # Models static & dynamic grids, loads maps ├── run_experiment.py # Main CLI runner for experiments ├── search/ │ ├── bfs.py │ ├── ucs.py │ ├── astar.py │ ├── local_replan.py │ └── utils.py # path neighbors + ASCII pretty-print ├── maps/ │ ├── small.txt # 5×5 test map │ ├── medium.txt # 10×10 test map │ ├── large.txt # 30×30 stress test │ ├── dynamic.txt # 5×5 dynamic test map │ └── dynamic_obstacles.json# schedule for moving car ├── tests/ │ ├── test_small.py # BFS/UCS/A* correctness + visual │ ├── test_medium_large.py # UCS vs A* on medium & large maps │ ├── test_dynamic_visual.py# Local replanning on moving obstacles └── results/ # (experiment logs / plots placed here)
git clone https://github.com/YOUR_USERNAME/DeliveryAgent.git
cd DeliveryAgent
### Create Virtual Environment (recommended)
Bash
python -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
### Install Dependencies
Bash
pip install -r requirements.txt
requirements.txt:
text
numpy
pytest
matplotlib # optional, if making plots
▶️ Usage: Running Experiments
From project root:
Small Map (5×5)
Bash
python run_experiment.py --map maps/small.txt --algo bfs
python run_experiment.py --map maps/small.txt --algo ucs
python run_experiment.py --map maps/small.txt --algo astar
Medium Map (10×10)
Bash
python run_experiment.py --map maps/medium.txt --algo bfs
python run_experiment.py --map maps/medium.txt --algo ucs
python run_experiment.py --map maps/medium.txt --algo astar
Large Map (30×30)
Bash
python run_experiment.py --map maps/large.txt --algo ucs
python run_experiment.py --map maps/large.txt --algo astar
(BFS will likely be impractical on large map — note as failure in report.)
Dynamic Map (moving car)
Bash
python run_experiment.py --map maps/dynamic.txt --algo local --dyn maps/dynamic_obstacles.json
🧪 Testing Correctness
This project includes pytest tests for reproducibility.
Run all tests:
Bash
pytest -v
For visual ASCII outputs during tests:
Bash
pytest -s tests/test_small.py
pytest -s tests/test_dynamic_visual.py