Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

first steps -> How "Mazes" have been made

Posted on 2007-03-28
9
Medium Priority
?
366 Views
Last Modified: 2013-11-15
Do you have a idea, how to present a "maze"  in C++. Especialy how to present a structure of DATA , I heard
that  I must to describe neibourgh cells e. tc?
0
Comment
Question by:sisqu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 6

Accepted Solution

by:
_iskywalker_ earned 672 total points
ID: 18806413
you can always use a matrix for it (a 2-dim array) like:
cell 1 = array[0][0];
cell 2 =array[0][1];
cell 11 = array[1][0];
if there are for example 100 cells divided in a quadratic maze
0
 

Author Comment

by:sisqu
ID: 18806523
Yes, but I mean how to present if the cell is wall,how to walk over the matrix and mark cells have already visited, how to return and change may way
this tings.........................
0
 
LVL 6

Expert Comment

by:_iskywalker_
ID: 18806718
well that you can define by the cell type like
typdef struct mazecell{
int type;
bool visited;
}

mazecell mymaze[10][10];
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:sisqu
ID: 18806744
There havent easier way :(
0
 
LVL 6

Expert Comment

by:_iskywalker_
ID: 18806796
what is hard in it? you can also create a class instead of a struct, but you need some data strcuture to describe your maze cell, if you need many information about the cell, you can also create for every information you need a matrix like:
int visited[10][10];
int type[10][10];
so i would propose the creating a class cell and making a matrix of it, since in the class you can add any property which will be add to every cell.
0
 
LVL 58

Assisted Solution

by:harfang
harfang earned 664 total points
ID: 18814116
I like this one (needs a non-proportional font, though)

char*M,A,Z,E=40,J[40],T[40];main(C){for(*J=A=scanf(M="%d",&C);
--            E;             J[              E]             =T
[E   ]=  E)   printf("._");  for(;(A-=Z=!Z)  ||  (printf("\n|"
)    ,   A    =              39              ,C             --
)    ;   Z    ||    printf   (M   ))M[Z]=Z[A-(E   =A[J-Z])&&!C
&    A   ==             T[                                  A]
|6<<11<rand()||!C&!Z?J[T[E]=T[A]]=E,J[T[A]=A-Z]=A,"_.":" |"];}

An old entry to the obfuscated C-code contest...

(°v°)
0
 
LVL 1

Assisted Solution

by:swiatlo
swiatlo earned 664 total points
ID: 18873396
What do you want to do with your maze (M)? You can represent M in many ways. I just thought that for 2D M, where there is 1 starting point you can build a 3-branch tree. Since from one point you can go FWD, LEFT, RIGHT. Starting point would be a top of the tree, there could be blind (nill pointers) directions, and somewhere at the bottom you will have a winning leaf (or more). while building that tree you would have to find where corridors join together and point to same leafs.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question