Montana Tech of The University of Montana
Computer Science & Software Engineering

CSCI 135
Fundamentals of Computer Science I
Fall 2017

ASSIGNMENT 9 - Wumpus World: Part 1

In this assignment, you will be writing a graphical program to implement the Wumpus World game. In the first part you will gain experience in multidimensional arrays and in object oriented design and programming. In the second part, you will learn more about object oriented design, and how it all works together. The assignment posted today is for Part 1.

The Game. The Wumpus World game takes place in a cave with different rooms in it. You can think of the cave as an NxM rectangular grid. The player always starts in position 0,0 (in the lower left hand corner of the cave), which is guaranteed to be safe (but it may still be smelly or breezy or glittery).

The objective of the game is to find the gold. The player will know when he/she is in a room with the gold because there will be a "glitter" in that room. If the player detects a glitter, he/she can pick up the gold and the game is won.

Bottomless pits are present in some of the rooms. There is a 20% chance that any given room will have a pit. All rooms adjacent to a pit are breezy, that is, a player entering a room adjacent to a pit will detect a breeze. If the player moves into the room with a pit, he/she falls in and dies a horrible death. "Adjacent" to means up down, left or right - you don't have to worry about diagonals.

There is only one wumpus in the cave, and he is also placed at random. Rooms adjacent to the wumpus are smelly, that is, a player will detect a stench in a room adjacent to a wumpus. The wumpus cannot move. If the player enters a room with the wumpus, he/she will be eaten, and, once again, die a horrible death.

There is also only one room in the cave that contains the gold. Unlike the other objects, the player has to be in the same room as the gold in order to detect a glitter. Like the wumpus, the gold is placed at random.

The player can move up, down, left, or right. The player also has one arrow. Once it's used up, it's gone. It can be used to shoot a wumpus, and can be shot in any direction the player can move in. The wumpus does not need to be in the next room in a given direction - an arrow shot in some direction should travel in that direction until it either hits a wall or the wumpus. If the player is successful in shooting the wumpus, the wumpus will emit a blood-curdling scream, and will no longer be a threat. The only other action the player can perform is to "grab gold".

When the player first starts the game, he/she does not know (and cannot see) where the location of pits, gold and the wumpus are. The only clues are whether the current room is breezy, smelly, or glittery.

The Assignment: The overall assignment is to produce this game with a graphical interface. You are strongly encouraged to work in pairs, though if you absolutely don't want to do this, you are not required to. If you would like to work with a partner, but don't know who to work with, let me know, and I'll see if I can pair people up. The assignment is divided into two parts, which have separate due dates.

Part 1: The first part of this assignment is to develop the code for the Cave and Room classes. As you recall from lecture, even though these are not the classes that will run the eventual game, you can still put main methods in them to test that they are working correctly. You will have to put some thought into what goes into each of these classes, both their instance variables and their methods. You will have completed this part of the assignment if your Cave class can take two integer input parameters from the command line (Run Configuration) and create and draw a valid wumpus world cave. Images have been provided for you that depict 100x100 tiles for rooms in the cave. You will need to populate your cave with a wumpus, gold and pits, and also determine which rooms are smelly, glittery and/or breezy (they can be all three, and more). When you draw the cave in your test main, you can draw each room according to what it contains, as if it was "visited" already by the player. In the eventual game, these will not show up until the player moves into that room. Note that some images will have to drawn over top of other images (e.g. draw the room image in a position first, and if it is breezy, draw the breezy image on top of the room image.)

Because you will all potentially be producing different solutions it is particularly important that you document your code well. In particular, there should be comments for every method that describe what it does, what it expects for input parameters, and what it returns, if anything, and what you should test it with.

The 100x100 images for the game are below.
NotVisitedMapTile.png (a dark blank tile where you can't see anything yet)
VisitedMapTile.png (a tile where you can see the room, but nothing is in it - you will draw over the top of this as you add items))

Some things that may help you in drawing the cave:
1. Since the images are 100x100 pixels, you probably want to set your canvas size so that it has rows*PIXELS and columns*PIXELS as its dimensions.
2. Similarly, you will want to set the X and Y scale of your canvas to run from 0 to rows*PIXELS and from 0 to columns*PIXELS to make it easier to place images.
3. When placing an image, remember that the x and y coordinates that you give are where the image will be centered. If you place the image at, say map location 0,0 only the upper right quadrant of the image will show on the canvas.
4. You will want to use for the image drawing routines.

Part 2: The second part of this assignment is to write the rest of the code to implement the Wumpus World game. Don't be surprised if, as you write code for the second part, you find places where you need to change the previous code. It's often difficult to think through the problem in enough detail to think of everything as you design the solution.


Grade Item Wumpus World I Points Earned
Program Compiles
Program Runs
Header Comment
Creates an NxM Cave
Uses a 2D Array for the Cave
Cave Creates a Room for Each Entry
Displays Images Correctly
Populates Cave with Wumpus, Gold and Pits Correctly
Determines Room Characteristics Correctly

Part 1. Submit your Java files for and to Moodle, under Assignment 9. If you are working as a pair, only submit one set of files, but make sure both of your names are on all files.

Page last updated: August 15, 2018