Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Output the maze before tearing down walls
- cout << "Maze before tearing down walls:" << endl;
- for (int i = 0; i < largura; i++) {
- for (int j = 0; j < comprimento; j++) {
- cout << layout[i][j] << " ";
- }
- cout << endl;
- }
- // Tear down internal walls to create loops
- vector<pair<int, int>> paredes_p_derrubar;
- for (int i = 1; i < largura - 1; i++) {
- for (int j = 1; j < comprimento - 1; j++) {
- if (layout[i][j] == '@' && (
- (layout[i - 1][j] == ' ' && layout[i + 1][j] == ' ') ||
- (layout[i][j - 1] == ' ' && layout[i][j + 1] == ' '))) {
- paredes_p_derrubar.push_back({i, j});
- }
- }
- }
- uniform_real_distribution<> dis(0.0, 0.7);
- double porcentagem_aleat = dis(g);
- int paredes_derrubar = floor(porcentagem_aleat * paredes_p_derrubar.size());
- shuffle(paredes_p_derrubar.begin(), paredes_p_derrubar.end(), g);
- for (int i = 0; i < paredes_derrubar; i++) {
- auto [x_d, y_d] = paredes_p_derrubar[i];
- layout[x_d][y_d] = ' ';
- }
- // Output the maze after tearing down walls
- cout << "Maze after tearing down walls:" << endl;
- for (int i = 0; i < largura; i++) {
- for (int j = 0; j < comprimento; j++) {
- cout << layout[i][j] << " ";
- }
- cout << endl;
- }
Add Comment
Please, Sign In to add comment