A Knowledge-Based Agent that navigates a Wumpus World grid using Propositional Logic and Resolution Refutation.
- Backend: Python 3 + Flask (inference engine, KB, CNF conversion)
- Frontend: Vanilla HTML/CSS/JS (no framework needed)
wumpus/
├── backend/
│ ├── app.py # Flask API + KB + Resolution engine
│ └── requirements.txt
└── frontend/
├── index.html
├── style.css
└── app.js
cd backend
pip install -r requirements.txt
python app.pyServer runs at http://localhost:5000
Open frontend/index.html in your browser, or serve it:
cd frontend
python -m http.server 8080Then open http://localhost:8080
When the agent visits a cell and receives percepts:
- No Breeze → all neighbors are safe from pits →
¬P(r,c)for each neighbor - Breeze → at least one neighbor has a pit →
P(n1) ∨ P(n2) ∨ ... - Same logic applies for Stench and Wumpus
All KB facts are stored directly in Conjunctive Normal Form:
safe_pit(r,c)→[¬Pit(r,c)](unit clause)or_pit(neighbors)→[Pit(n1) ∨ Pit(n2) ∨ ...]
To prove a cell (r,c) is safe:
- Negate the query: add
[Pit(r,c)]to KB - Repeatedly resolve pairs of clauses
- If the empty clause
[]is derived → contradiction → cell IS safe - If no new clauses can be derived → cannot prove safety
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/new_game |
Start game with {rows, cols} |
| POST | /api/move |
Move agent to {row, col} |
| POST | /api/auto_move |
Agent picks best safe move |
| GET | /api/state |
Get current game state |
Update the API constant in frontend/app.js to point to your deployed backend URL.
Frontend: https://wumpus-agent-614.vercel.app
Backend: https://wumpus-agent-614.onrender.com