Assignment
In the (loose) spirit of the Colossal Cave Adventure and Zork, you will create a game program that prompts the player for commands and responds with text descriptions. You can use any language or OS you choose.
The Commands
Your game should respond to the following 1-word commands:
Command | Action |
---|---|
n, s, e, w | Move through an unlocked door to the next room to the north, south, east, or west respectively. |
get | Pick up an object. If the player is already holding another item, print a message and exchange the items. |
use | Use an item as the key to unlock a door if the key fits one of the doors in the room. When used, the item should disappear and the door should remain unlocked |
item | Describe the item the player is holding. |
look | Re-print long descriptions |
Components
Your game code should use dense arrays of component classes to manage the game data:
- Description: A component containing a short name and longer description of a room, item, or door. The first time the player sees something, you should print the long description, then just the name (unless they use the "look" command).
- Item: Each item should have a description. In component terms, this means a map from the ItemID to DescriptionID. You do not need the reverse direction (from DescriptionID to its ItemID).
- Room: Each room should have a description, and may have doors in any of the four directions. They can also optionally have one item on the floor of the room.
- Door: Each door should have a description and to-room. They can also optionally have one item that the player must have and use to unlock the door. Doors are one-way, so if you want to be able to travel back and forth between two rooms, you will need to set up two doors, one in each direction. This also allows doors to be unlocked in one direction and locked in the other.
- Player: There is just one player entity. The player has a room where they currently stand. They may also optionally have a single item that they are holding.
Use component existence as for boolean state. So a door is locked if there is an item in the DoorID to ItemID lock map, and unlocked if there's no item for that door in the lock map.
Data
You only need to initialize enough data to pick up a key, move to a second room, use the key, and move to a final room.
691 students
Read initialization data from one or more files.
Submission
Edit "assn3/README.txt" to describe your test computer (at least OS and CPU), what language and compiler you used, and how to build and run your project. Give a cheat script for what commands to use to go through to pick up a key, unlock a door, and move through it. Also include anything interesting we should know about your game and implementation.