Skip to content
yerdnarthcPublic

About

An app simulator demonstrating different AI agent architectures for the classic "vacuum world" problem from artificial intelligence textbooks.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

36 Commits

Folders and files

Repository files navigation

VWSim - Vacuum World Agent Simulator

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.

Overview

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

Agent Architectures

1. Random Agent

The simplest agent with no decision logic:

  • Sucks when dirt is detected
  • Moves randomly otherwise
  • No memory of visited cells
  • Cannot determine task completion

2. Simple Reflex Agent

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

3. Model-Based Reflex Agent

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

Performance Scoring

Action Score
Clean dirty cell +10
Any movement -1
Invalid action -1

Higher scores indicate better performance.

Getting Started

Prerequisites

  • .NET SDK (for console app)
  • Visual Studio 2019+ or Mono (for Windows Forms app)

Build

# Build the entire solution
dotnet build

# Or build individual projects
dotnet build VWSim.Core
dotnet build VWSimConsole

Run

Console Application (Quick Testing):

dotnet run --project VWSimConsole

Windows Forms Application (Visualization):

dotnet run --project VWSim

Or open VWSim.slnx in Visual Studio and run the VWSim project.

Project Structure

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

Architecture

Agent-Environment Interaction Loop

┌─────────────┐                      ┌──────────────┐
│ Environment │ ------Percept------→ │     Agent    │
│             │                      │   Program()  │
│             │ ←------Action--------│              │
└─────────────┘                      └──────────────┘
  1. Environment generates VacuumPercept (position, dirt status, boundary info)
  2. Agent's Program() method processes percept and returns action
  3. Environment's ExecuteAction() applies the action, updates state and score
  4. Repeat until completion or step limit

Available Actions

  • Suck - Clean current cell
  • MoveUp, MoveDown, MoveLeft, MoveRight - Movement
  • NoOp - No operation (task complete)

Creating a New Agent

  1. Inherit from Agent base class
  2. Implement Program(VacuumPercept) returning action string
  3. Override optional methods for UI feedback:
    • GetThought() - Current reasoning
    • GetCompletionThought() - Final status
    • GetFinalReport() - Summary report
  4. Register in VacuumWorldForm.InitSimulations()

Screenshots

The Windows Forms application displays:

  • Side-by-side simulation panels for each agent

Screenshot of the simulation panels

  • Real-time grid visualization with agent position and dirt

GIF animation of the real-time grid visualization during a simulation run

  • Performance score tracking

Screenshot of the performance score tracking for individual agents

  • Internal reasoning log for each agent

GIF animation of the internal reasoning log for each agent side-by-side

  • Simulation progress visualization through a progress bar

Screenshot of the simulation progress bar

  • Simulation grid size customization

Screenshot of the simulation grid size customization section of the application

  • Simulation steps configuration

Screenshot of the simulation steps configuration section of the application

  • Simulation animation speed control

Screenshot of the simulation animation speed control

Technologies

  • VWSim.Core: .NET Standard 2.0
  • VWSim: .NET Framework 4.7.2 (Windows Forms)
  • VWSimConsole: .NET 10.0

References

This simulation is based on the vacuum world problem from:

  • Russell, S., & Norvig, P. - Artificial Intelligence: A Modern Approach

License

This project is open source and available under the MIT License.

About

An app simulator demonstrating different AI agent architectures for the classic "vacuum world" problem from artificial intelligence textbooks.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages