2
I’m using the Codeblocks.
I have a. txt file that represents a maze, everything that is after the :
are rooms:
The first line of the file shows the start coordinate, which in this case is AS
. Every letter w
represents a wall. So my BFS has as initial node (or initial root) the AS
.
To represent this labyrinth in a graph would look like this:
I have to represent this graph in an adjacency matrix. And I stuck to this part, that I have to generate this matrix, because to make the BFS the code needs to know the graph. I couldn’t think of a way to represent this adjacent matrix by reading this file, please, any suggestions, ideas, material, would help me a lot.
Note: My code can already obtain and store the maze in an array, without the letters before the :
and without the initial coordinate. I have the complete labyrinth in a matrix. Telling who is next door to whom and generating the graph is what I’m not able to do.
@nbro, your assumption is correct, are just names for each of the rooms of the labyrinth. The acronyms before the
:
It is like a numbering, because in this problem there are rooms that contain jewels, and to indicate that a room contains a jewel the following is done: ;AN: AO S AM BI
*AO: AP T AN BJ
AP: w U AO BK
*AO:
there is the character*
, and it indicates that in all subsequent rooms of nameAO
there are jewels.w
. Continues...– Filipi Maciel
Continuation of the... However, to make the BFS I have to have the graph, which says who is next door to whom, and this part that I cannot solve, how can I create the graph, that is, the adjacent matrix, with all the relationships of the rooms? Please, any hint or suggestion will help me a lot.
– Filipi Maciel
@All the graphs that I worked, applied in the search algorithms, were informed by hand, because they were small. I’ve never worked with search algorithms where we should generate the graph from the algorithm. I’m not familiar with the "Adjacent list".
– Filipi Maciel
@nbro, Interesting, I will follow your suggestion. I will search for Nodes and adjacent lists and try this. Thanks for the suggestion and the tip, as soon as I get results I update the post here.
– Filipi Maciel