Vacuum_world
This project extends the classic Vacuum World problem to a 2x2 grid environment. The environment and agent models have been updated to accommodate this new setup, and four different types of agents have been implemented and tested: Random Agent, Table-Driven Agent, Simple Reflex Agent, and Model-Based Reflex Agent.
Prerequisites (for Mac)
Ensure that Python is installed on your machine. You may also need to install some dependencies. All required packages are listed in the requirements.txt file. Installation
- Fork and Clone the repository:
https://github.com/aimacode/aima-python.git
cd aima-python
- Set up a virtual environment and install dependencies: *note: running these commands in terminal rather than vscode terminal seems to work better. Also, restart VScode if certain packages like ipykernel or numpy don't seem to be installed even though already installed.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
*note: make sure running the python environment in this virtual
It should like this in the upper right corner of the vscode:
- Also install ipykernel:
python3 -m pip install ipykernel -U --force-reinstall
python3 -m ipykernel --version
note:
- Run commands in terminal outside of VSCode.
- Check to make sure that you are in the correct environment.
- Restart VSCode if needed to update installed packages.
The agents.py file contains the AI agent implementations, while the vacuum_world.py file models the 2x2 grid environment via Jupyter notebook.
The environment is now a 2x2 grid, represented as follows:
Change the environment to:
loc_A, loc_B = (0, 0), (0,1)
loc_C, loc_D = (1,0), (1, 1)
note: '0' = clean, '1' = dirty
Location A is now at top left, B is top right. Location C is bottom left, and D is bottom right.
Agent Descriptions
- Random Agent
The RandomVacuumAgent selects actions randomly from the possible moves ('Up', 'Down', 'Left', 'Right', 'Suck', 'NoOp').
We added 'Up', and 'Down' commands, to be able to move in all diretion in a 2 x 2 environment.
-
Table-Driven Agent
The TableDrivenVacuumAgent uses the last known percept-action to determine its next action. Therefore, we needed only the 1 percept for the table to successfully run as expected.
-
Simple Reflex Agent
The SimpleReflexVacuumAgent acts based on condition-action rules:
Cleans a dirty cell.
Moves to adjacent cells according to a fixed sequence, which we determined would be a clockwise motion i.e. A -> B -> D -> C.
- Model-Based Reflex Agent
The ModelBasedReflexAgent will attempt to clean its cell if it is dirty. If its adjacent cell is dirty, it will move to it to clean it. The agent maintains an internal model of the environment and updates it based on percepts. It chooses actions to clean all dirty cells efficiently.
We used https://github.com/aimacode/aima-python as a starting reference point.