Hello all. I'm a student in a data structures class, and our professor just assigned us our 3rd project of the semester. I'll copy/paste a section of the project to give you an idea of what I'm supposed to do:
"Adventure is a game based on an imaginary world that can be envisioned as a series of connected
rooms. These rooms can be thought of as vertices of a large graph. In this text-based game, when
you enter each room, the computer produces a description, such as the following:
You are standing in a large dining hall. In front of you
is a table on which there sits a candelabra. Next to the
candelabra is a key resting on top of a folded piece of
paper. To the left is an open window. To the right is a
wooden door. Across from you, behind the table, is a
large curtain.
Users are allowed to enter simple commands, such as "pick up key," "read paper," or "exit
through window." In response, the computer will tell you the contents of the next room, the
contents of your pockets, or various other bits of information. Design an adventure game that has
at least ten rooms and seven types of objects. Observe that the rooms and their connections can
be modeled by a graph."
When I was first reading this, I saw the "connected rooms" part and immediately thought Linked List. However, when I noticed that there were possibly multiple exits to the room, linked lists suddenly didn't seem like a good idea. I've given it some more thought, but I can't really figure out which data structure would be appropriate for holding the rooms and items they could hold (keys, etc). Any help or suggestions would be greatly appreciated.
BTW, I had no clue which category this falls under so I just clicked Design and Architecture.
Loading
Sam HobbsPosted Nov 11, 2009, 3:59 PM
The following comment does not help much with your question but I want to include this comment anyway. A linked list could be more complicated if you needed to provide the ability to update the data, such as a parts list for something such as a bicycle or car or airplane because you must ensure that a component is not accidentally entered as containing a component that is also an assembly that the component is in, but since the components will not change after design time, and since a room will never have a room in it, it makes things much easier than data you are likely to encounter later in your education or career.
Serban CosminPosted Nov 11, 2009, 12:57 PM