Charcoal, 7777 63 bytes
NθNηJ‽θ‽η+W‹LKA×θη«J‽θ‽η¿¬℅KK«≔Φ⁴℅§KVκι¿ι§2064‽ι»»UE¹¦¹FθFη«J⊗ι⊗κF›KK+P✳IKK²+NθNηJ⊗‽θ⊗‽ηP+ ¦+W‹№KA+×θη«J⊗‽θ⊗‽η¿¬℅KK«≔⌕AKV ι¿ι«P+ P✳⁻χ⊗‽ι²+
Try it online!Try it online! Link is to verbose version of code. Outputs ana whitespace-bordered ASCII grid. Explanation:
NθNη
Input the width and height.
J‽θ‽η+J⊗‽θ⊗‽ηP+ ¦+
Jump to a random position and mark it with a +
surrounded with spaces. (Unfortunately Charcoal's Multiprint operator special-cases a leading +
so I have to output the +
separately.)
W‹LKA×θη«W‹№KA+×θη«
Repeat until w*h
positions+
s have been filled inoutput.
J‽θ‽ηJ⊗‽θ⊗‽η
Jump to a random position.
¿¬℅KK«
If the position is vacant,
≔Φ⁴℅§KVκι≔⌕AKV ι
find any filled neighboursneighbouring spaces,
¿ι§2064‽ι»»¿ι«
and if there is one mark its direction (choosing randomly if there are more thanat least one).
UE¹¦¹
Insert blank rows and columns to make an ASCII grid.
FθFη«
Loop over all the rows and columns., then
J⊗ι⊗κP+ P✳⁻χ⊗‽ι²+
Jump tosurround the (expanded)current position.
F›KK+
If this isn't the original +
with spaces,
P✳IKK²
then draw a -
or |
in the appropriatea random matching direction.
+
Replace the digit with, and finally draw a +
in the current position.