Welcome to the Frozen Lake Search Agents repository!
Here you'll find intelligent agents that solve the classic Frozen Lake maze problem using search algorithms.
Imagine a frozen lake represented as a grid, where each cell can be:
- S: Start position
- G: Goal position
- F: Frozen (safe to walk)
- H: Hole (danger! falls in)
Your agent must find the safest path from S to G without falling into any holes.
At each step, the agent can move:
- ⬅️ Left (0)
- ⬇️ Down (1)
- ➡️ Right (2)
- ⬆️ Up (3)
This repo includes two search-based agents:
- UCSAgent: Uniform Cost Search agent (explores all paths with equal cost)
- AStarAgent: A* agent (uses smart heuristics to find the shortest path faster)
- Manhattan distance heuristic 🏙️
- Euclidean distance heuristic 📏
- The environment is generated randomly for different grid sizes (4x4, 8x8, 16x16, 20x20).
- Agents use the environment's model to plan their moves.
- Performance (steps, reward, time) is compared for each agent and environment.
-
Install dependencies with Poetry
If you don't have Poetry, install it first:curl -sSL https://install.python-poetry.org | python3 -Then install all dependencies:
poetry install -
Explore interactively
Openfrozen_lake.ipynbfor step-by-step exploration and visualization.
After running, you'll see a comparison of UCS and A* agents on different maze sizes, showing:
- Reward earned 🏆
- Steps taken 👣
- Time spent ⏱️
main.py— Runs the agent comparisonucs_agent.py— Uniform Cost Search agenta_star_agent.py— A* agent with heuristicsmodel.py— Maze model and graph builderpriority_queue.py— Priority queue for searchfrozen_lake.ipynb— Interactive notebook
Enjoy solving the Frozen Lake challenge! ❄️🧠🚶♂️