Background

Wumpus World is a classical computer science puzzle game. The user is placed on a grid of cells that represents a cave, and can move to an adjacent cell by going up, down, left, or right. Each cell in the game might contain:

  • A Wumpus
  • A pit
  • Gold

There are many variants to the game, but in this assignment the goal is to find the gold, pick it up, return to the cave entrance (the starting position), and climb out. If the user lands on a cell that contains a Wumpus, then they will be eaten. If they land on a cell that contains a pit, they will fall in and die. If they land on a cell with the gold, they can pick it up and then make their way for the entrance.

To help avoid obstacles and find the gold, the user can:

  • Detect a glitter if they are on the cell that contains the gold
  • Detect a stench if they are adjacent to the cell that contains the Wumpus (this means to the left, right, up, or down)
  • Detect a breeze if they are adjacent to a cell that contains a pit

At each turn, the user can either move (left, right, up, or down), shoot an arrow (left, right, up, or down), grab for gold, or climb out of the cave.

Description

You will a program that plays Wumpus World from a randomly generated game. The constraints of the game will be as follows:

  • The dimensions will be between 4 and 6 rows and between 4 and 6 columns
  • The user always starts in the lower-left corner (biggest row, first column)
  • The board contains exactly one Wumpus (randomly placed)
  • The board contains exactly one piece of gold (randomly placed)
  • Each position that is not the start (lower-left) and does not contain gold has a 10% chance of having a pit

In the screenshot below, the user finds the gold and exits the cave: See image.

Note that when we run the program, even though the board placement is random, we can build this mental model (note that there are likely several more rows above this). Green cells are visited, and red cells are unvisited: See image.

Below, the user falls into a pit: See image.

Here is a mental model we can build (visited = green, unvisited = red). Again, there are likely more rows and more columns that we didnt visit. See image.

Below, the user is eaten by the Wumpus: See image.

Here is a mental model we can build (visited = green, unvisited = red). Again, there are likely more rows and more columns that we didnt visit. See image.

Below, the user kills the Wumpus, finds the gold, and exits: See image.

Here is a mental model we can build (visited = green, unvisited = red). Again, there are likely more rows and more columns that we didnt visit. See image.

Design Requirements

This program should contain four classes (Person, Cell, Board, and Proj5). Your program must compile (by command-line) with the statement:

javac *.java

It must then run with the command:

java Proj5

The started files for each class are available in the proj5start.zip file on K-State Online. Note that the Person and Cell classes are finished you do not need to make changes to them. The Board and Proj5 classes list which methods you should have as well as what they should do. DO NOT remove those methods or modify their parameters or return values. If you do want to add additional methods, that is fine.

Requirements

This section contains more details on requirements of the project:

  • If the user attempts to move past the bounds of the grid, tell them that they bumped into a wall and do not move them.
  • If the user lands on the same cell as a Wumpus or a pit, they will die and the game is over.
  • If the user tries to pick up the gold from a cell that does not contain gold, nothing happens
  • The user cannot put the gold back down once they have picked it up (not that they would want to)
  • If the user selects to shoot the arrow, they can select to shoot up, down, left, or right. If they select up, for example, then the shot will be successful if the Wumpus is in any cell in the same column as the user but above the users row. (The Wumpus does not have to be adjacent to the player for the shot to be successful.) If the user misses the shot, they lose their arrow and cannot shoot again.
  • If the user successfully shoots the Wumpus, you should print that a scream is heard. You should remove the Wumpus from the board, so that a stench is no longer detected in adjacent cells
  • If the user attempts to climb out of the cave when they are not at the starting position (lower-left corner), you should print an error and let them keep playing.
  • The game is over if the user climbs out of the cave at the starting position. If they are carrying the gold when they climb out, they win. If they are not carrying the gold, they lose.
  • Note that the lower-left corner in the grid will be at column 0 but in the last row (if there are 5 rows, it would be at row 4). Similarly, one row up in the grid means subtracting one from the row.
  • You should use the methods in the Player and Cell classes to keep them updated on position, whether the arrow has been used, whether the gold has been picked up, and whether a Cell contains a Wumpus, a pit, or gold.
  • You should accept either upper- or lower-case input for all command options. If the user inputs and invalid command, you should print an error and prompt again.

Documentation

The project has been documented for you. However, you should add your name under author at the top of those files. If you add any additional methods, you should add documentation for those methods as well.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.