Exemplo n.º 1
0
def buildMaze( filename ):
    infile = open( filename, "r" )
    
    # Read the size of the maze
    nrows, ncols = readValuePair( infile )
    maze = Maze( nrows, ncols )
    
    # Read the strating and exit position
    row, col = readValuePair( infile )
    maze.setStart( row, col )
    row, col = readValuePair( infile )
    maze.setExist( row, col )
    
    # Read the maze itself
    for row in range( nrows ):
        line = infile.readline()
        for col in range( len(line)):
            if line[col] == "*":
                maze.setWall( row, col )
                
    # Close the maze file and return the newly constructed maze
    infile.close()
    return maze