Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7617947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:16:23+00:00 2026-05-31T03:16:23+00:00

As an assignment for my C++ module, I have to build a text-adventure game.

  • 0

As an assignment for my C++ module, I have to build a text-adventure game. The problem I’m facing is a conceptual one; everyone is saying I should use a tree data structure to represent my game. What I don’t get is why.

Let’s say I have a house of 4 rooms. We can imagine this as an 2×2 array. In each room I have two objects. I want to display this data in such a way that I can easily move my character from 0x0 to 0x1 either way (directly – 1 step, or indirectly – 3 steps), while carrying one object with me.

Why is it better to use a tree to hold all data and how will my character move form one node to another? Or is the character a node as well? Shouldn’t my character be an object with a list as its inventory?

I’m a little confused about this. I’m not looking for any code, just a better understanding of data representation and manipulation.

The suggestion was for maps. But then I don’t understand how my character will “navigate” a map, either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:16:24+00:00Added an answer on May 31, 2026 at 3:16 am

    What you’re looking for isn’t a tree, but a graph.

    The reason it’s preferable is that an array of “places” doesn’t necessarily represent what you want. There isn’t necessarily a door between all adjacent rooms, so you may not be able to go directly from one to another. At the time time, in a typical text adventure type of game, you may have some hallways (or whatever) that take you more or less directly from one room to another that’s not exactly (or even close to) adjacent. In addition, you may have one-way passages that will take you from one place to another, but you can’t turn around and go back. All of these are easy to represent with a directed graph, but difficult to represent with an array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been given an assignement for a graphics module, one part of which
I have a config.cfg which I parse using the python-module ConfigParser. In one section
The assignment at my first year uni computing course says my program should read
For a school assignment I have to write x86 assembly code, except I can't
For my university assignment I have to design some basic managment system for sicknesses
For a database assignment I have to model a system for a school. Part
For my assignment I have been assigned the task of creating a DTD for
For my university assignment I have to make a networkable version of pacman. I
I have an assignment in a language-independent class, and part of it is using
I have an assignment to create a GUI using MATLAB GUIDE and am having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.