Assignment 5

Due: 6th December



Implement a text-based exploration/adventure game of the style popular in/since the '80s, as described below. With this assignment there is enormous opportunity for clever additions for extra credit. If you are in need of some points take advantage of this. The basic assignment is very basic, and does not make for a very exciting game (not that any of these games were ever very exciting), but is within the reach of everybody.

Basic Version

You, the programmer, have to design an artificial world as well as the program that allows real people to explore that world. The world is divided up into "locations", each of which has its own description.
        The description of a location consists of a simple label that is used to refer to it, a string of descriptive text, plus links to the locations that can be reached directly from it. These links are just the labels of the reachable locations. The simplest way to arrange the links to other locations is to assume that all movement is made by moving in one of the four cardinal compass directions, so every location description includes the labels of the four locations that can be reached from it in the order North, East, South, West. Any directions that are blocked can be left blank.
        The labels can just be numbers to get you started, but I would hope for something a little more sophisticated on turned-in versions.
        The description of the world should be kept in a file. Your program should read the file when it starts, but should not continually read information while the game is running. All the information should be read into memory somehow when the program starts.

Example of parts of the file:
1:An entrance hall:2:0:0:0:
2:A corridor with notice boards and a dirty carpet:3:4:17:1:
3:The ladies' rest-room:0:0:2:0:
4:A small office with no windows:0:5:2:0:
...
17:A pirate's treasure cave:17:89:0:106:gold
...
The idea is that players always start in location number 1. A player in location 1 is told something like "I am in An entrance hall", and is allowed to type a command. The basic commands are for movement in each of the four directions. If the user selects East, South, or West, he or she is told that it is not possible to go that way (note that the description of location 1 only has a link for the first direction, North, all others are zero). If the user commands a Northward movement, he or she finds himself or herself in location 2 and is told "I am in A corridor with notice boards and a dirty carpet", and the game continues.

You will notice that location 17 has an extra item after its four links. This is where a location's contents (if any) are listed. On entering location 17, the player is told "I am in A pirate's treasure cave. There is gold here". Apart from the four movement commands, there should be a command to pick up an object that is in the player's current location. While the player is holding an object, it moves around with him or her (of course), and the player should be free to put that object down in any location they visit.

That is the basic requirement. Try to make it interesting. Try to use some advanced and sophisticated programming. Remember these assignments are to give you practice so that exams and future classes will be more manageable. You may modify any part of this description to make a better or more interesting program after you have got the basic requirements working.