function dig(index, dir) {
      rooms[index] &= ~dir;
      let neighbour;
      switch(dir) {
        case LEFT:
          neighbour = index-1;
          rooms[neighbour] &= ~RIGHT;
          break;
        case RIGHT:
          neighbour = index+1;
          rooms[neighbour] &= ~LEFT;
          break;
        case TOP:
          neighbour = index-cols;
          rooms[neighbour] &= ~BOTTOM;
          break;
        case BOTTOM:
          neighbour = index+cols;
          rooms[neighbour] &= ~TOP;
          break;
      }
      rooms[neighbour] |= LINKED;
      return neighbour;
    }
/**
     * Link another room up
     * @param index {number} Dig from already linked room with this index
     * @param dir {number} in this direction
     * @return {number} index of room we just linked up
     */
Link another room up
@param index {number} Dig from already linked room with this index
@param dir {number} in this direction
@return {number} index of room we just linked up
Link another room up @param index { number } Dig from already linked room with this index @param dir { number } in this direction @return { number } index of room we just linked up
function dig(index, dir) {
      rooms[index] &= ~dir;
      let neighbour;
      switch(dir) {
        case LEFT:
          neighbour = index-1;
          rooms[neighbour] &= ~RIGHT;
          break;
        case RIGHT:
          neighbour = index+1;
          rooms[neighbour] &= ~LEFT;
          break;
        case TOP:
          neighbour = index-cols;
          rooms[neighbour] &= ~BOTTOM;
          break;
        case BOTTOM:
          neighbour = index+cols;
          rooms[neighbour] &= ~TOP;
          break;
      }
      rooms[neighbour] |= LINKED;
      return neighbour;
    }
function dig ( index , dir ) { rooms [ index ] &= ~ dir ; let neighbour ; switch ( dir ) { case LEFT : neighbour = index - 1 ; rooms [ neighbour ] &= ~ RIGHT ; break ; case RIGHT : neighbour = index + 1 ; rooms [ neighbour ] &= ~ LEFT ; break ; case TOP : neighbour = index - cols ; rooms [ neighbour ] &= ~ BOTTOM ; break ; case BOTTOM : neighbour = index + cols ; rooms [ neighbour ] &= ~ TOP ; break ; } rooms [ neighbour ] |= LINKED ; return neighbour ; }
Link another room up
 @param index {number} Dig from already linked room with this index
 @param dir {number} in this direction
 @return {number} index of room we just linked up
Link another room up @param index { number } Dig from already linked room with this index @param dir { number } in this direction @return { number } index of room we just linked up