本文整理汇总了C++中Maze::GenerateMaze方法的典型用法代码示例。如果您正苦于以下问题:C++ Maze::GenerateMaze方法的具体用法?C++ Maze::GenerateMaze怎么用?C++ Maze::GenerateMaze使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Maze
的用法示例。
在下文中一共展示了Maze::GenerateMaze方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
break;
case 1:
if (optionmap["-s"] < 1) {
std::cerr << "Invalide size " << optionmap["-s"]
<< " for hexagonal maze with triangular lattice\n";
usage(std::cerr);
return 1;
}
std::cout << "Hexagonal maze with triangular lattice of size "
<< optionmap["-s"] << "\n";
maze = new HexagonalMaze(optionmap["-s"]);
break;
case 2:
if (optionmap["-s"] < 1) {
std::cerr << "Invalide size " << optionmap["-s"]
<< " for honeycomb maze\n";
usage(std::cerr);
return 1;
}
std::cout << "Honeycomb maze of size " << optionmap["-s"] << "\n";
maze = new HoneyCombMaze(optionmap["-s"]);
break;
case 3:
if (optionmap["-s"] < 1) {
std::cerr << "Invalide size " << optionmap["-s"]
<< " for circular maze\n";
usage(std::cerr);
return 1;
}
std::cout << "Circular maze of size " << optionmap["-s"] << "\n";
maze = new CircularMaze(optionmap["-s"]);
break;
case 4:
if (optionmap["-s"] < 1) {
std::cerr << "Invalide size " << optionmap["-s"]
<< " for circular maze with triangular lattice\n";
usage(std::cerr);
return 1;
}
std::cout << "Circular maze with triangular lattice of size "
<< optionmap["-s"] << "\n";
maze = new CircularHexagonMaze(optionmap["-s"]);
break;
default:
std::cerr << "Unknown maze type " << optionmap["-m"];
usage(std::cerr);
return 1;
}
switch (optionmap["-a"]) {
case 0:
std::cout << "Maze generation using Kruskal's algorithm\n";
algorithm = new Kruskal;
break;
case 1:
std::cout << "Maze generation using Depth-first search\n";
algorithm = new DepthFirstSearch;
break;
case 2:
std::cout << "Maze generation using Breadth-first search\n";
algorithm = new BreadthFirstSearch;
break;
default:
std::cerr << "Unknown algorithm type " << optionmap["-a"];
usage(std::cerr);
return 1;
}
if (optionmap["-t"] < 0 or optionmap["-t"] > 1) {
std::cerr << "Unknown output type " << optionmap["-a"];
usage(std::cerr);
return 1;
}
std::cout << "Initialising graph..." << std::endl;
maze->InitialiseGraph();
std::cout << "Generating maze..." << std::endl;
maze->GenerateMaze(algorithm);
if (optionmap["-t"] == 0) {
std::cout << "Rendering maze to '" << outputprefix << ".svg'..."
<< std::endl;
maze->PrintMazeSVG(outputprefix);
} else {
std::cout << "Exporting maze plotting parameters to '" << outputprefix
<< ".plt' ..." << std::endl;
maze->PrintMazeGnuplot(outputprefix);
std::cout << "Rendering maze to '" << outputprefix
<< ".png' using gnuplot..." << std::endl;
system(("gnuplot '" + outputprefix + ".plt'").c_str());
}
return 0;
}