Solved

first steps -> How "Mazes" have been made

Posted on 2007-03-28
9
346 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
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…

757 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

17 Experts available now in Live!

Get 1:1 Help Now