Computer Science & Software Engineering
In this assignment, you will continue to write the graphical program to implement the Wumpus World game.
In the first part you gained 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 2. The image at the right is from my coded solution, using Charlie Hand and Zachariah Valenzuela's images from 2015. Each of these images for the rooms is 100x100 pixels. They have graciously allowed us to use their images for this assignment (see bottom of assignment).
If you were unable to get your Cave and Room classes to work in the previous assignment, you might want to use mine as a model. Here are my solutions to the Cave.java and Room.java files.
Recall the description of the game from last time. This has not changed. What has changed is that now you must implement the additional classes that make the game actually run. These are WumpusWorld (the game controller, or the program with the main method in it), and Player, the class that represents the player on the screen. The instructions for Part 1 are included below, but additional instructions and hints for Part 2 are below that.
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, which is guaranteed to be safe (but it may still be smelly or breezy or glittery). The image above is one implementation of the game for Android. Yours does not have to look like that.
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.
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. 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. 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 and create and draw a valid wumpus world cave. Images have been provided for you that depict 64x64 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. In the eventual game, these will not show up until the player moves into that room. 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.
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 StdDraw.java 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.
The player always starts in position 0,0 (the lower left corner) of the cave. This space is guaranteed to be safe (no pits and no wumpus) but there may be a breeze or stench in that room. If you're really lucky, the gold could be there also. The only rooms that are actually displayed are those that the player has visited - the rooms not yet explored must show up as blank spaces.
The player moves by using the 'w', 'a', 's', and 'd' keys for up, left, down and right respectively. Your program should redraw the player on the screen if it makes a legal move, and it should check to make sure that the player does not move off the screen. If the player wishes to shoot the arrow, the 'i', 'j', 'k', and 'l' keys are used to shoot up, left, down and right respectively. If the wumpus is in line with the direction the arrow is shot, even if he is several squares away, he will die. Your program needs to handle removing the wumpus and stench from the cave if that happens. Finally, the key 'g' is used to grab the gold if the player is in the same room with it.
Your program should react appropriately if the player falls into a pit, is eaten by the wumpus, or grabs the gold. Any one of these signals the end of the game.
Images for the game:.
Sounds for the game: (if you choose to add sounds - you can also find and use your own sounds if you like - you will need to use StdAudio.java for this)
|Grade Item||Wumpus World II||Points Earned|
|Game Loop Runs Correctly|
|Responds to Movement Correctly|
|Arrow Shoots Correctly|
|Responds to Grabbing Gold Correctly|
|Appropriate Game End|
Page last updated: August 15, 2018