Course: Intelligent Agent Systems
Programming Language: Python
Agent Framework: SPADE (Smart Python Agent Development Environment)
Platform: GitHub Codespaces
This project implements a decentralized intelligent multi-agent system for disaster response and relief coordination. The system uses autonomous agents to detect disaster events, assess damage severity, and coordinate response operations under conditions of uncertainty and limited resources.
Configure the Python agent development environment and deploy a basic intelligent agent.
File: disaster_response/lab1_basic_agent_simple.py
The basic agent demonstrates:
- Agent lifecycle management (setup → start → stop)
- One-shot behaviors (execute once)
- Periodic/cyclic behaviors (execute repeatedly)
- Autonomous operation without external control
-
Agent Class:
SimulatedAgent- Manages agent state and behaviors
- Implements setup and lifecycle methods
-
Behaviors:
hello_behaviour(): Executes once at startupperiodic_behaviour(): Executes every 2 seconds (5 iterations)
-
Features Demonstrated:
- Asynchronous execution using
asyncio - Timestamped logging
- Self-termination after task completion
- Asynchronous execution using
cd /workspaces/codespaces-blank
python3 disaster_response/lab1_basic_agent_simple.pyThe agent will:
- Display startup information
- Execute the hello behavior once
- Perform 5 periodic checks (every 2 seconds)
- Stop automatically
- Display summary of demonstrated concepts
Implement agent perception of environmental and disaster-related events through a simulated disaster environment.
-
disaster_response/environment.py- Disaster Environment Simulator- Simulates dynamic disaster scenarios
- Models environmental conditions
- Generates random disaster events
-
disaster_response/lab2_sensor_agent.py- Sensor Agent Implementation- Monitors environmental conditions
- Detects disaster events
- Logs sensor readings and events
- FLOOD
- EARTHQUAKE
- FIRE
- DROUGHT
- STORM
- LOW (1)
- MODERATE (2)
- HIGH (3)
- CRITICAL (4)
- CATASTROPHIC (5)
Represents geographical locations with:
- Latitude and longitude coordinates
- Location name
- Ghanaian cities: Accra, Kumasi, Tema, Tamale, Cape Coast
Complete disaster event representation:
- Event ID
- Disaster type
- Location
- Severity level
- Timestamp
- Affected area (km²)
- Casualties count
- Infrastructure damage percentage
- Required resources (medical kits, food, water, rescue teams)
Sensor readings that agents perceive:
- Temperature (°C)
- Humidity (%)
- Wind speed (km/h)
- Air quality index (AQI)
- Seismic activity (Richter scale)
- Water level (meters above normal)
- Smoke detection (boolean)
- Active disasters list
- Reads environmental conditions at assigned location
- Samples every 3 seconds (configurable)
- Detects anomalies:
- High temperature (> 40°C)
- Strong winds (> 60 km/h)
- Poor air quality (> 200 AQI)
- Seismic activity (> 3.0 magnitude)
- Water level rise (> 0.5m)
- Smoke detection
- Identifies new disaster events
- Prevents duplicate alerts
- Logs all detections
-
Text logs:
logs/SENSOR-XXX_log.txt- Timestamped entries
- Percept readings
- Anomaly detections
- Disaster alerts with people affected and resources needed
-
JSON events:
logs/SENSOR-XXX_events.json- Structured disaster data
- Complete event metadata
- Resources needed tracking
- CRITICAL alerts for high-severity disasters
- WARNING alerts for lower-severity events
cd /workspaces/codespaces-blank
python3 disaster_response/lab2_sensor_agent.pyThe simulation will:
- Create a disaster environment
- Deploy 3 sensor agents to different locations
- Monitor for 20 seconds
- Detect and log any disasters that occur
- Generate log files and event JSON files
- Display agent summaries
SENSOR-001_log.txt- Accra monitoring logSENSOR-002_log.txt- Kumasi monitoring logSENSOR-003_log.txt- Tema monitoring logSENSOR-XXX_events.json- Detected disaster events (JSON format)
[10:52:08] SENSOR-001: Percept | Temp: 59°C | Wind: 27km/h | AQI: 215 | Humidity: 83%
[10:52:08] SENSOR-001: CRITICAL | Fire at Accra | Severity: CATASTROPHIC | People Affected: 109 | Resources: 13 teams
{
"event_id": "D0001",
"disaster_type": "Fire",
"location": "Accra (5.6037, -0.1870)",
"severity": "CATASTROPHIC",
"timestamp": "2026-01-29T08:52:12.598281",
"affected_area_km2": 5.18,
"casualties": 66,
"infrastructure_damage_pct": 50.28,
"resources_needed": {
"medical_kits": 77,
"food_packages": 292,
"water_bottles": 386,
"rescue_teams": 14
},
"detected_by": "SENSOR-003"
}- Python: Version 3.12.1 ✓
- SPADE Framework: Version 4.1.2 ✓
- Prosody XMPP Server: Installed and configured ✓
# Verify Python
python3 --version
# Install SPADE
pip install spade
# Install Prosody XMPP Server
sudo apt update
sudo apt install -y prosody
# Start Prosody service
sudo service prosody start
# Create agent credentials
sudo prosodyctl register testadmin localhost testpass123
sudo prosodyctl register sensor localhost sensor123
sudo prosodyctl register coordinator localhost coord123
sudo prosodyctl register rescue localhost rescue123
sudo prosodyctl register logistics localhost logis123/workspaces/codespaces-blank/
├── disaster_response/
│ ├── environment.py # Environment simulation
│ ├── lab1_basic_agent_simple.py # Lab 1 implementation
│ ├── lab1_basic_agent.py # Lab 1 (SPADE version)
│ └── lab2_sensor_agent.py # Lab 2 implementation
├── logs/
│ ├── SensorAgent_1_log.txt # Agent logs
│ ├── SensorAgent_2_log.txt
│ ├── SensorAgent_3_log.txt
│ └── SensorAgent_X_events.json # Event data
└── README.md # This file
✓ Agent creation and initialization
✓ Agent lifecycle management
✓ One-shot behavior execution
✓ Periodic/cyclic behavior execution
✓ Autonomous operation without external control
✓ Environment simulation with dynamic disasters
✓ Agent perception through sensors
✓ Periodic monitoring behavior
✓ Event detection and classification
✓ Multiple agents operating concurrently
✓ Agent autonomy in disaster detection
✓ Data persistence (logging)
✓ Anomaly detection
- Autonomy: Agents operate independently without constant human control
- Reactivity: Agents perceive and respond to environmental changes
- Proactivity: Agents take initiative in monitoring and detecting disasters
- Temporal Continuity: Agents run continuously over time
- Used Python's
asynciofor concurrent agent execution - Multiple agents monitoring different locations simultaneously
- Clean separation of concerns
- Reusable components (Environment, Agent, Percept)
- Dataclasses for structured data
- Text logs for human readability
- JSON files for machine processing
- Timestamped entries for audit trail
The foundation laid in Labs 1 & 2 enables:
- Lab 3: Inter-agent communication (FIPA-ACL)
- Lab 4: Coordinator agents for task allocation
- Lab 5: Rescue agents with action capabilities
- Lab 6: Logistics agents for resource management
- Lab 7: Multi-agent coordination and negotiation
- Lab 8: System evaluation and performance metrics
The current implementation uses simulation mode instead of full SPADE/XMPP integration for easier demonstration. The core agent concepts remain valid and can be extended to full SPADE agents when XMPP connectivity is required.
Disaster generation is random for demonstration purposes. The 10% probability per environment update creates dynamic, unpredictable scenarios similar to real-world uncertainty.
Laboratory Manual: Intelligent Agent Systems Course
Implementation Date: January 29, 2026
Platform: GitHub Codespaces
Development Environment: Ubuntu 24.04.3 LTS
✓ Screenshot of running agent (console output captured)
✓ Python source code (lab1_basic_agent_simple.py)
✓ Environment setup report (this document)
✓ SensorAgent code (lab2_sensor_agent.py)
✓ Event logs (logs/SensorAgent_log.txt)
✓ Event data (logs/SensorAgent_events.json)
✓ Brief explanation of percepts (documented in code and README)
- SPADE Documentation: https://spade-mas.readthedocs.io/
- FIPA Standards: http://www.fipa.org/
- Prometheus Methodology: Agent-Oriented Software Engineering
- Python asyncio: https://docs.python.org/3/library/asyncio.html
End of Laboratory Report