Wumpus World is a classic problem in artificial intelligence used to demonstrate reasoning under uncertainty. In this environment, an agent navigates a grid-based world filled with hazards like bottomless pits and a fearsome Wumpus. The agent's objective is to find gold and return to safety while avoiding dangers. The agent uses logic and inference to deduce the locations of hazards based on sensory input, making it a classic problem for studying search algorithms, logical reasoning, and planning in AI.
This repository serves as Machine Problem 5 in subject CS322-M-CS321L-M - Artificial Intelligence
- git clone
https://github.com/ChugxScript/Wumpus-World-AI.git
- git install
requirements.txt
- run
main.py
- Stench: Rooms adjacent to the Wumpus emit a stench.
- Breeze: Rooms adjacent to pits have a breeze.
- Glitter: Rooms with gold contain glitter.
- Wumpus: The agent can kill the Wumpus if facing it, emitting a scream audible throughout the cave
- +1000 points for exiting the cave with gold.
- -1000 points for being eaten by the Wumpus or falling into a pit.
- -1 point for each action, and -10 points for using an skill
- User can choose in game mode whether user want to play as an AI or play by the user
- User can choose what world size they want from 4x4 to 10x10
- Agent starts at [0, 0], facing right because why not.
- Wumpus and gold are randomly placed.
- Each room has a x probability of containing a pit, except [0, 0] depending on the world size.
- The number of Wumpus and gold generate base on the world size.
- DFS algorithm is use in generation of valid world
- Turn left, right, above, and below
- Grab gold
- Shoot skill
- Climb
- Perceive
Stench
if cell is adjacent to wumpusBreeze
if cell is adjacent to wumpusGlitter
if cell is adjacent to wumpusBump
if move to wall
- Agent perceives the scream if Wumpus is shot
- Pij: Pit in room [i, j].
- Bij: Agent perceives breeze in [i, j].
- Wij: Wumpus in [i, j].
- Sij: Agent perceives stench in [i, j].
- Vij: Room [i, j] visited.
- Gij: Gold (and glitter) in [i, j].
for (nrow, ncol), stats in self.adjacent():
if "S" in actual_components:
if "W?" in self.kb[nrow][ncol][self.W]:
if "V" not in self.kb[nrow][ncol]:
self.kb[nrow][ncol][self.W] = "W"
if self.skill != 0:
print(f"\n>> wumpus killed in self.kb[{nrow}][{ncol}]")
print(f">> self.skill: {self.skill}")
self.skill -= 1
self.load_skill_gold_()
self.update_perceive('enemy', (nrow, ncol))
elif "~W" not in self.kb[nrow][ncol][self.W]:
self.kb[nrow][ncol][self.W] = "W?"
else:
self.kb[nrow][ncol][self.W] = "~W"
if "B" in actual_components:
if "P?" in self.kb[nrow][ncol][self.P]:
if "V" not in self.kb[nrow][ncol]:
self.kb[nrow][ncol][self.P] = "P"
elif "~P" not in self.kb[nrow][ncol][self.P]:
self.kb[nrow][ncol][self.P] = "P?"
else:
self.kb[nrow][ncol][self.P] = "~P"
-
initial world, where it checks the current cell status
-
only in the safe and unvisitted cells that our agent can move but it can backtrack if there are no other cells and then move again to unvisitted safe cells. In this scenario, the agent moves to [1, 0] and perceive
Stench
so it mark the adjacent cells asW?
saying that theres mayba a wumpus then go back and check safe cells -
in this scenario, our agent detects
Stench
again and in the cell [1, 1] isW?
so therefore that cell is wumpus and the other cell is not
I would like to thank these guys helping me out to finish this project. Their repo serve as a guide and inspiration in the game logic <3
- @sudohumberto - https://github.com/sudohumberto/wumpus-world
- @thiagodnf - https://github.com/thiagodnf/wumpus-world-simulator