Python: Bulko

Programming Project 1:
An Adventure Game (Part 1)

In video game culture, an adventure game is a video game in which the player assumes the role of a protagonist in an interactive story driven by exploration and puzzle-solving. Early adventure games from the 1970s and early 1980s were text-based, using text parsers to translate the player's input into commands. As personal computers became more powerful, the games were augmented with graphics, and later moved into point-and-click intefaces.

Adventure, or "Colossal Cave", was released in 1976, and is widely accepted to be the first adventure game. Other notable adventure game series include Zork, King's Quest, The Secret of Monkey Island, and Myst. Many of these are now available to play for free online, such as here.

In this programming project, you will use object-oriented techniques to create a simple map for an adventure game. You will create objects representing the rooms of a house, a method to display the features (properties) of a room, and functions to navigate the map.

The map for our game will be a symbolic representation of this house:

floor plan

For our compass directions, "north" means towards the top of this webpage, "east" means to the right, etc. So we would say you could go through the door from the Living Room to the Dining room by going north, and from there, pass through the door to the kitchen by going west. Although there is no label on the floor plan, there is a "room" called the Upper Hall on the second floor representing the region connecting the Bathroom, Small Bedroom, and Master Bedroom by doors, and connected to the Living Room via the stairs. You would take the stairs by moving in the directions "up" or "down".

The Room class:

Your first task will be to create a Python class called Room. This class must contain at least the two following methods:

  1. __init__(). In addition to self, it takes seven arguments:

    A value of None for one of these arguments means you can't travel in that direction from this room.

  2. displayRoom()

The data structure:

This is the data structure you must build to represent the house:

class diagram

Writing the program:

A skeleton of your project has already been started for you. Download this file: Project1.py

Let's walk through the file from the bottom up.

Important: your code MUST be data-independent.

What does this mean? Your code should work regardless of what the map looks like. That means if you make references to "Living Room" or "Kitchen" anywhere in your code (other than in the assignment statements in loadMap()), you are doing it wrong and you will be penalized 20% on your grade for this assignment.

The idea is you are writing a framework for a game that should work no matter what map is provided. If we wanted to change the setting of this game from the house plan shown above to, say, your apartment or home, Carlsbad Caverns, or Hogwarts, we should just have to change the data provided in loadMap(). If you have code anywhere else in your program that refers to a specific room by name, it will not work with the new map without extensive rewriting.

Expected output:

Your output should look like the following:


Room name:  Living Room
   Room to the north:  Dining Room
   Room above:         Upper Hall

Room name:  Dining Room
   Room to the south:  Living Room
   Room to the west:   Kitchen

Room name:  Kitchen
   Room to the east:   Dining Room

Room name:  Upper Hall
   Room to the north:  Bathroom
   Room to the east:   Small Bedroom
   Room to the south:  Master Bedroom
   Room below:         Living Room

Room name:  Bathroom
   Room to the south:  Upper Hall

Room name:  Small Bedroom
   Room to the west:   Upper Hall

Room name:  Master Bedroom
   Room to the north:  Upper Hall

You are currently in the Living Room.
You can't move in that direction.
You can't move in that direction.
You are now in the Dining Room.
You are now in the Living Room.
You are now in the Upper Hall.
You are currently in the Upper Hall.
You are now in the Small Bedroom.
You can't move in that direction.
You are now in the Upper Hall.
You are now in the Master Bedroom.
You are now in the Upper Hall.
You are now in the Bathroom.
You are now in the Upper Hall.
You are currently in the Upper Hall.
You can't move in that direction.
You are currently in the Upper Hall.
You are now in the Living Room.
You are now in the Dining Room.
You are now in the Kitchen.
You can't move in that direction.
>>> 

Turning in the Assignment:

The program that you will write should appear in a file called Project1.py. There is no input data file for this assignment. Submit the file via Canvas before the deadline shown at the top of this assignment by attaching it to the Canvas "Assignment" called "Project 1".