Ejemplo n.º 1
0
void				Map::genRandMap()
{
  fillMap();
  digMap(std::make_pair(1, 1));
  removeWalls();
  fillMap();
}
Ejemplo n.º 2
0
void TriangularMaze::initialize() {
  UINT r,c;
  for(r = 0; r < m_horizontalWall.getRowCount(); r++) {
    for(c = 0; c < m_horizontalWall.getColumnCount(); c++) {
      m_horizontalWall(r,c) = MazeWall(wallPoint(r,c),wallPoint(r,c+1));
    }
  }
  for(r = 0; r < m_verticalWall.getRowCount(); r++) {
    for(c = 0; c < m_verticalWall.getColumnCount(); c+=2) {
      m_verticalWall(r,c) = MazeWall(wallPoint(r,c/2),wallPoint(r+1,c/2));
    }
    int m1 = (r % 2 == 0) ? -1 :  1;
    for(c = 1; c < m_verticalWall.getColumnCount(); c+=2) {
      m_verticalWall(r,c) = MazeWall(wallPoint(r+1,(c+m1)/2),wallPoint(r,(c-m1)/2));
    }
  }

  reduceWallMatrix1(m_horizontalWall);
  reduceWallMatrix1(m_verticalWall);

  for(r = 0; r < m_cell.getRowCount(); r++) {
    for(c = 0; c < m_cell.getColumnCount(); c++) {
      MazeCell  &cell = m_cell(r, c);
      WallArray &wa   = cell.getWalls();
      int        wc   = 0;

      if(r % 2 == 0) {
        if(c % 2 == 0) {
          ADDWALL(m_horizontalWall,r  , c/2    );
          ADDWALL(m_verticalWall  ,r  , c+1    );
          ADDWALL(m_verticalWall  ,r  , c      );
        } else {
          ADDWALL(m_horizontalWall,r+1, (c-1)/2);
          ADDWALL(m_verticalWall  ,r  , c      );
          ADDWALL(m_verticalWall  ,r  , c+1    );
        }
      } else {
        if(c % 2 == 0) {
          ADDWALL(m_horizontalWall,r+1, (c+1)/2);
          ADDWALL(m_verticalWall  ,r  , c      );
          ADDWALL(m_verticalWall  ,r  , c+1    );
        } else {
          ADDWALL(m_horizontalWall,r  , (c-1)/2);
          ADDWALL(m_verticalWall  ,r  ,  c+1   );
          ADDWALL(m_verticalWall  ,r  ,  c     );
        }
      }
    }
  }
  reduceCellMatrix();
  reduceWalls();
  initStartEnd();
  if(isOk()) {
    removeWalls();
  }
}
Ejemplo n.º 3
0
void HexMaze::initialize() {
  UINT r,c;
  for(r = 0; r < m_horizontalWall.getRowCount(); r++) {
    for(c = 0; c < m_horizontalWall.getColumnCount(); c++) {
      m_horizontalWall(r,c) = MazeWall(wallPoint(r,c),wallPoint(r,c+1));
    }
  }
  for(r = 0; r < m_verticalWall1.getRowCount(); r++)  {
    for(c = 0; c < m_verticalWall1.getColumnCount(); c++) {
      m_verticalWall1(r,c) = MazeWall(wallPoint(2*r,2*c),wallPoint(2*r+1,2*c));
    }
  }
  for(r = 0; r < m_verticalWall2.getRowCount(); r++) {
    for(c = 0; c < m_verticalWall2.getColumnCount(); c++) {
      m_verticalWall2(r,c) = MazeWall(wallPoint(2*r+1,2*c+1),wallPoint(2*r+2,2*c+1));
    }
  }

  reduceWallMatrix1(m_horizontalWall);
  reduceWallMatrix1(m_verticalWall1);
  reduceWallMatrix1(m_verticalWall2);

  for(r = 0; r < m_cell.getRowCount(); r++) {
    for(c = 0; c < m_cell.getColumnCount(); c++) {
      MazeCell  &cell = m_cell(r,c);
      WallArray &wa   = cell.getWalls();
      int        wc   = 0;

      if(r % 2 == 0) {
        ADDWALL(m_horizontalWall,r  ,2*c  );
        ADDWALL(m_horizontalWall,r  ,2*c+1);
        ADDWALL(m_verticalWall1 ,r/2,c+1  );
        ADDWALL(m_horizontalWall,r+1,2*c+1);
        ADDWALL(m_horizontalWall,r+1,2*c  );
        ADDWALL(m_verticalWall1 ,r/2,c    );
      } else {
        ADDWALL(m_horizontalWall,r  ,2*c-1);
        ADDWALL(m_horizontalWall,r  ,2*c  );
        ADDWALL(m_verticalWall2 ,r/2,c    );
        ADDWALL(m_horizontalWall,r+1,2*c  );
        ADDWALL(m_horizontalWall,r+1,2*c-1);
        ADDWALL(m_verticalWall2 ,r/2,c-1  );
      }
    }
  }
  reduceCellMatrix();
  reduceWalls();
  initStartEnd();
  if (isOk()) {
    removeWalls();
  }
}