Solved

first steps -> How "Mazes" have been made

Posted on 2007-03-28
9
353 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
9 Comments
 
LVL 6

Accepted Solution

by:
_iskywalker_ earned 168 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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 166 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 166 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Iteration: Iteration is repetition of a process. A student who goes to school repeats the process of going to school everyday until graduation. We go to grocery store at least once or twice a month to buy products. We repeat this process every mont…
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now