A C# simulation demonstrating different AI agent architectures for the classic "vacuum world" problem from artificial intelligence textbooks. This project implements and compares three agent types with increasing cognitive sophistication.
The vacuum world is a well-known problem in AI where an agent must navigate a grid environment and clean dirty cells. This simulation demonstrates how different agent architectures—from simple random behavior to sophisticated model-based reasoning—approach this task.
Key Features:
- Three agent types: Random, Simple Reflex, and Model-Based Reflex
- Real-time Windows Forms visualization with performance comparison
- Asynchronous simulation with cancellation support
- Performance scoring and internal agent reasoning logs
The simplest agent with no decision logic:
- Sucks when dirt is detected
- Moves randomly otherwise
- No memory of visited cells
- Cannot determine task completion
Rule-based decision making without memory:
- Sucks if current cell is dirty
- Follows a deterministic movement pattern (up → right → down → left)
- No memory of visited cells
- Cannot verify if task is complete
Maintains an internal map and can verify completion:
- Builds an internal map of visited cells
- Tracks grid boundaries through movement attempts
- Records which cells are clean/dirty
- Uses breadth-first search to navigate to unexplored cells
- Can definitively determine when all cells are cleaned
| Action | Score |
|---|---|
| Clean dirty cell | +10 |
| Any movement | -1 |
| Invalid action | -1 |
Higher scores indicate better performance.
- .NET SDK (for console app)
- Visual Studio 2019+ or Mono (for Windows Forms app)
# Build the entire solution
dotnet build
# Or build individual projects
dotnet build VWSim.Core
dotnet build VWSimConsoleConsole Application (Quick Testing):
dotnet run --project VWSimConsoleWindows Forms Application (Visualization):
dotnet run --project VWSimOr open VWSim.slnx in Visual Studio and run the VWSim project.
VWSim/
├── VWSim.Core/ # Core domain logic
│ ├── Agents/ # Agent implementations
│ │ ├── Agent.cs # Abstract base class
│ │ ├── AgentAction.cs # Action constants
│ │ ├── RandomAgent.cs # Random movement agent
│ │ ├── SimpleReflexAgent.cs # Rule-based agent
│ │ └── ModelBasedReflexAgent.cs # Map-based agent
│ ├── Environments/ # Environment abstraction
│ │ ├── Environment.cs # Base environment class
│ │ └── VacuumEnvironment.cs # Grid world implementation
│ ├── Models/ # Domain models
│ │ ├── Dirt.cs # Dirt particle model
│ │ ├── VacuumGrid.cs # Grid dimensions
│ │ ├── VacuumPercept.cs # Agent percept class
│ │ └── VacuumWorldState.cs # World state snapshot
│ ├── Simulation/ # Simulation orchestration
│ │ ├── AgentSimulation.cs # Single agent simulation
│ │ ├── VacuumSimulation.cs # Multi-agent orchestrator
│ │ └── SimulationStepResult.cs
│ └── Generators/ # World state generators
│ ├── VacuumWorldGenerator.cs
│ └── AgentPositionGenerator.cs
├── VWSim/ # Windows Forms GUI
│ ├── Forms/ # Main application forms
│ ├── Controls/ # Custom UI controls
│ ├── Rendering/ # Grid visualization
│ └── Utilities/
└── VWSimConsole/ # Console runner
┌─────────────┐ ┌──────────────┐
│ Environment │ ------Percept------→ │ Agent │
│ │ │ Program() │
│ │ ←------Action--------│ │
└─────────────┘ └──────────────┘
- Environment generates
VacuumPercept(position, dirt status, boundary info) - Agent's
Program()method processes percept and returns action - Environment's
ExecuteAction()applies the action, updates state and score - Repeat until completion or step limit
Suck- Clean current cellMoveUp,MoveDown,MoveLeft,MoveRight- MovementNoOp- No operation (task complete)
- Inherit from
Agentbase class - Implement
Program(VacuumPercept)returning action string - Override optional methods for UI feedback:
GetThought()- Current reasoningGetCompletionThought()- Final statusGetFinalReport()- Summary report
- Register in
VacuumWorldForm.InitSimulations()
The Windows Forms application displays:
- Side-by-side simulation panels for each agent
- Real-time grid visualization with agent position and dirt
- Performance score tracking
- Internal reasoning log for each agent
- Simulation progress visualization through a progress bar
- Simulation grid size customization
- Simulation steps configuration
- Simulation animation speed control
- VWSim.Core: .NET Standard 2.0
- VWSim: .NET Framework 4.7.2 (Windows Forms)
- VWSimConsole: .NET 10.0
This simulation is based on the vacuum world problem from:
- Russell, S., & Norvig, P. - Artificial Intelligence: A Modern Approach
This project is open source and available under the MIT License.






