/* Collect maze from file or randomly generate it. Return the maze dimensions. */ maze_dimensions get_maze(char *argv[], max_maze array){ maze_dimensions dimensions; // Inspect and act on argv[1] if (strcmp(argv[1],"RANDOM") == 0) { dimensions = random_dimensions(); // Decide how big the random maze will be random_maze(array,dimensions); // Fill that portion of the array with a maze open_portals(array, dimensions); } else { // Read contents of file into mazeArray, and return given size dimensions = readMaze(argv,array); } return dimensions; }
int main (int argc, char const *argv[]) { // The default maze size is 20x10. A different size may be specified on // the command line. std::size_t x = 20; std::size_t y = 10; if (argc == 3) { x = boost::lexical_cast<std::size_t>(argv[1]); y = boost::lexical_cast<std::size_t>(argv[2]); } random_generator.seed(std::time(0)); maze m(x, y); random_maze(m); if (m.solve()) std::cout << "Solved the maze." << std::endl; else std::cout << "The maze is not solvable." << std::endl; std::cout << m << std::endl; return 0; }