Brownian tree: Difference between revisions

(→‎{{header|Uiua}}: updated description and comments)
 
(2 intermediate revisions by one other user not shown)
Line 2,798:
=={{header|Locomotive Basic}}==
{{trans|ZX Spectrum Basic}}
[[File:Cpcbasic brownian.png|thumb|Output]]
This program is ideally run in [https://benchmarko.github.io/CPCBasic/cpcbasic.html CPCBasic] and should finish after about 20 to 25 minutes (Chrome, desktop CPU). At normal CPC speed, it would probably take several days to run when set to 10000 particles.
<syntaxhighlight lang="locobasic">10 MODE 1:DEFINT a-z:RANDOMIZE TIME:np=10000
Line 2,815 ⟶ 2,816:
1020 y=RND*400
1030 RETURN</syntaxhighlight>
 
=={{header|Lua}}==
The output is stored in as a ppm-image. The source code of these output-functions is located at
Line 5,422 ⟶ 5,424:
=={{header|Uiua}}==
Uiua Pad will show well-shaped arrays as images directly. If running locally you can uncomment the final few lines to save it as a file instead. (Running local is ~10 times faster too.)
[[File:UiuaBrownianTree.png|thumb]] Sample with higher values than provided code.
 
The main move loop passes round a pair of points: here and previous position, so when we hit a set cell we can just back up one.
Line 5,449 ⟶ 5,450:
# &fwa "BrownianTree.png"
</syntaxhighlight>
 
Or if you like your code terse :-)
 
<syntaxhighlight lang="Uiua">
S ← 80
⍜⊡(+1)↯2⌊÷2S↯S_S0
Rp ← (⊟⍥(⌊×⚂S)2)
Sd ← ⊟.⍢(Rp◌)(=1⊡) Rp
Nx ← ⟨Sd◌|∘⟩:⟜(/××⊃(≥0)(<S)⊢)⊟∵(-1+⌊×⚂3).⊢
⍜now⍥(⍜⊡(+1)◌°⊟⍢Nx(=0⊡⊢)Sd)500
</syntaxhighlight>
{{out}}
[[File:UiuaBrownianTree.png|thumb]] |center||Sample with higher values than provided code.]]
 
=={{header|Visual Basic .NET}}==
65

edits