当前位置: 首页>>代码示例>>C++>>正文


C++ Maze::GenerateMaze方法代码示例

本文整理汇总了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;
}
开发者ID:razimantv,项目名称:mazegenerator,代码行数:101,代码来源:main.cpp


注:本文中的Maze::GenerateMaze方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。