John

John

  • NA
  • 1
  • 0

Which data structure to use?

Nov 11 2009 9:46 AM
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.

Answers (2)