Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
37
Task/Maze-generation/Uiua/maze-generation.uiua
Normal file
37
Task/Maze-generation/Uiua/maze-generation.uiua
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
H ← 8
|
||||
W ← 18
|
||||
Ver ← 0
|
||||
Hor ← 1
|
||||
Vis ← 2
|
||||
|
||||
BreakNS ← ⊂Ver⊂⊃(/↥≡⊡0|⊡0_1)
|
||||
BreakEW ← ⊂Hor⊂⊃(⊡0_0|/↥≡⊡1)
|
||||
# ([here, next], maze) -> (maze')
|
||||
BreakWall ← ⍜⊡(0◌)⟨BreakNS|BreakEW⟩=°⊟≡⊢.
|
||||
|
||||
Neighbours ← +⊙¤[[¯1 0] [1 0] [0 1] [0 ¯1]] # Gives N4
|
||||
Shuffle ← ⊏⍏[⍥⚂]⧻.
|
||||
IsVisited ← ¬⊡⊂Vis
|
||||
MarkAsVisited ← ⟜(⍜(⊡|1◌)⊂Vis)
|
||||
OnlyInBounds ← ▽≡IsVisited ⊙¤,, # (finds the boundary 1's)
|
||||
|
||||
# (here, maze) -> (maze')
|
||||
Walk ← |2 (
|
||||
MarkAsVisited
|
||||
# (here, maze) -> ([[here, next] x(up to)4], maze)
|
||||
≡⊟¤⟜(Shuffle OnlyInBounds Neighbours)
|
||||
|
||||
# Update maze for each in turn. For each, if it
|
||||
# still isn't visited, break the wall, recurse into it.
|
||||
∧(⟨◌|Walk ⊡1 ⟜BreakWall⟩IsVisited◌°⊟,,)
|
||||
)
|
||||
|
||||
⊂↯H⊂↯W0 1↯+1W1 # vis (added 1's help bounds checks)
|
||||
⊂↯H⊂↯W1 1↯+1W 0 # ver
|
||||
↯+1H⊂↯W1 0 # hor
|
||||
⊂⊟
|
||||
# Stack: ([hor, ver, vis])
|
||||
Walk [0 0]
|
||||
|
||||
PP! ← ≡/⊂∵^! # Pretty print using switch.
|
||||
≡(&p$"_\n_")⊃(PP!⟨"+ "|"+--"⟩⊡Ver|PP!⟨" "|"| "⟩⊡Hor)
|
||||
Loading…
Add table
Add a link
Reference in a new issue