Skip to content

ChugxScript/Wumpus-World-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wumpus-World-AI

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

USAGE

  • git clone https://github.com/ChugxScript/Wumpus-World-AI.git
  • git install requirements.txt
  • run main.py

RULES

  • 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

PEAS description

  • +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

ENVIRONMENT

  • 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

ACTUATORS

  • Turn left, right, above, and below
  • Grab gold
  • Shoot skill
  • Climb

SENSORS

  • Perceive
    • Stench if cell is adjacent to wumpus
    • Breeze if cell is adjacent to wumpus
    • Glitter if cell is adjacent to wumpus
    • Bump if move to wall
  • Agent perceives the scream if Wumpus is shot

PREPOSITION

  • 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"

EXPLORATION

  • initial world, where it checks the current cell status

    image

  • 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 as W? saying that theres mayba a wumpus then go back and check safe cells

    image

  • in this scenario, our agent detects Stench again and in the cell [1, 1] is W? so therefore that cell is wumpus and the other cell is not

    image

SCREENSHOTS

  • Main page image

  • Select Game Mode image

  • Select World Size image

    • 4x4 image image

    • 6x6 image image

    • 8x8 image image

    • 10x10 image image

  • Controls image

  • Killed wumpus image

  • Win image

  • Lose image

ACKNOWLEDGMENT

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages