Algorithm for printing to the screen through a text maze

For my C ++ assignment, I basically try to search for a piece of text in a text file (which is transferred to my vector vec), starting from the second upper character on the left, This is for a text maze where my program at the end should print characters for the path through it .

An example of a maze will look like this:

###############
Sbcde####efebyj
####hijk#m#####
#######lmi#####
###############
###############
###############
###############
###############
###############
###############
###############
###############
###############
###############

Where "#" is an unstable wall, and you always start on the left on the second upper symbol. Alphabetic characters are moving squares. Exit is ALWAYS right. The maze always has a size of 15x15 in the maze.text file. Alphabetic characters are repeated in one maze, but not directly next to each other.

: , vec , . , , .

, , , :

    void pathcheck()
{
    if (isalpha(vec.at(x)) && !(find(visited.begin(), visited.end(), (vec.at(x))) != visited.end()) )
    {
        path.push_back(vec.at(x));
        visited.push_back(vec.at(x));
        pathcheck(vec.at(x++));
        pathcheck(vec.at(x--));
        pathcheck(vec.at(x + 16));
        pathcheck(vec.at(x - 16));
    }
}

visited - , .

, , , , (.. , )? , , /, , /, ?

+5
1

. , ( ), ( , ). , , , . :

http://en.wikipedia.org/wiki/Depth-first_search

http://en.wikipedia.org/wiki/Breadth-first_search

, ( "#" node, ). (.. , , , [S, b, c] - , S c). DFS BFS , , , , , . DFS BFS , DFS ( ), BFS (.. ).

, DFS :

  • node - S, - [S]. [S] ([[S]]).
  • ( , [S]).
  • , 1 node ( , b).
  • node 3 , . . (.. [S, b], b c S, S , )
  • 4 node, , . .
  • node 4, node, (.. [S] [S, b] , [[S, b]])
  • 2 6 , , , node.

. (, "e" s). , , "Node", . , "e" , , . ++, :

class Node:
    method Constructor(label):
        myLabel = label
        links = list()

    method addLink(node):
        links.add(node)

, "#", node .

EDIT: 3 Python, . .

s = "foo"
s == "foo"

Python . "==" Python . , Java, , "==" . , Java ++, , .

, , , node ( ==, strcmp()!), .

, - node , . !

+3

All Articles