Chaos game: Difference between revisions

1,497 bytes added ,  21 days ago
(Added MSX Basic y GW-BASIC)
 
(6 intermediate revisions by 4 users not shown)
Line 326:
270 NEXT I
280 END</syntaxhighlight>
 
==={{header|IS-BASIC}}===
<syntaxhighlight lang="is-basic">100 PROGRAM "ChaosGam.bas"
110 RANDOMIZE
120 GRAPHICS HIRES 4
130 LET X=RND(800):LET Y=RND(600)
140 FOR I=1 TO 20000
150 LET VERTEX=RND(3)
160 SELECT CASE VERTEX
170 CASE 0
180 LET X=X/2
190 LET Y=Y/2
200 CASE 1
210 LET X=400+(400-X)/2
220 LET Y=600-(600-Y)/2
230 CASE 2
240 LET X=800-(800-X)/2
250 LET Y=Y/2
260 END SELECT
270 SET INK VERTEX+1
280 PLOT X,Y
290 NEXT</syntaxhighlight>
 
==={{header|Locomotive Basic}}===
Line 816 ⟶ 838:
=={{header|EasyLang}}==
 
[https://easylang.dev/show/#cod=Zc1BCoMwEIXhfU7xL20FO1aKuMhJQhbFKgrVQAiS3L5MkW66GJj5eMwbwztEBhGTncfiEFoRHoI35aSenqHDm4wlPvdX2GaumjPlT+YQWbG0pKAgIgbYwjGRKbrHaUxI0+novZxP1j3xBe2pMjXZLf7CjbuqdlWFmvLTxnwA Run it]
[https://easylang.dev/show/#cod=Zc1BCsJADAXQfU7xl1WhphaRLjzJMItSWypYA0OR5PYmUrpxwkD+IySDvKSgYyZNGXckMBpmXBmZbKObV9c6qMfSvx+yTDjGHNmfTL7v6dpglQB/BGCRzwiFRV/GYQXXbfzI874EvxxnKsUJmuZ8wBmX0DhVmavtWtMX Run it]
 
<syntaxhighlight lang="text">
color 900
x[] = [ 0 100 50 ]
Line 825 ⟶ 847:
y = randomf * 100
for i = 1 to 100000
move x y
rect 0.3 0.3
h = randomrandint 3
x = (x + x[h]) / 2
y = (y + y[h]) / 2
.
</syntaxhighlight>
Line 1,153 ⟶ 1,175:
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Chaos_game}}
 
'''Solution'''
 
[[File:Fōrmulæ - Chaos game 04.png]]
 
'''Test case. Sierpiński triangle'''
 
[[File:Fōrmulæ - Chaos game 05.png]]
 
[[File:Fōrmulæ - Chaos game 06.png]]
 
=={{header|FutureBasic}}==
Line 3,455 ⟶ 3,487:
XXX
</pre>
=={{header|Uiua}}==
<syntaxhighlight lang="Uiua">
Dim ← 500
Points ← [[50 ⌊÷2Dim] [-50Dim 50] [-50Dim -50Dim]]
# Uncomment to try different square or pentagonal references.
# Points ← [[50 50] [-50Dim 50] [50 -50Dim][-50Dim -50Dim]]
# Points ← [[50 ⌊÷2Dim] [⌊×0.4Dim 50] [⌊×0.4Dim -50Dim] [-50Dim 120] [-50Dim -120Dim]]
Colours ← [[1 0 0] [0 1 0] [0 0 1] [1 1 0] [1 0 1] [0 1 1]]
Rand ← ⌊×⚂
 
↯Dim_Dim_3 0
∧(⍜(⊡|[1 1 1]◌))Points
⊟Rand Dim Rand Dim
⍥(
Rand⧻Points
# Set next point and colour based on target.
⊃(⌊÷2+⊡:Points|⊙◌⊡:Colours)
⟜⍜⊡◌⊙:
)10000
# Uncomment to save image.
# &fwa "UiuaChaosGameSerpinski.png" &ime "png"
 
</syntaxhighlight>
{{out}}
[[File:UiuaChaosGameSerpinski.png|thumb|center|Render using colours associated with each target point.]]
 
=={{header|Wren}}==
{{trans|Kotlin}}
2,120

edits