Anonymous user
Galton box animation: Difference between revisions
→{{header|REXX}}: added code to automatically freeze the REXX program to enable to capture a point in time (for a screenshot); also changed wording in the REXX section header.
m (→{{header|REXX}}: implemented a better method to abvoid collisions.) |
(→{{header|REXX}}: added code to automatically freeze the REXX program to enable to capture a point in time (for a screenshot); also changed wording in the REXX section header.) |
||
Line 2,867:
Balls are dropped continuously (up to a number specified or the default), the default is enough rows of
<br>
Extra code could've been added to check for which OS (operating system) is being used and which REXX is
<br>running to determine which program to clear the terminal (screen). Currently, it is
hard-coded to '''CLS'''.
<lang rexx>/*REXX pgm simulates Sir Francis Galton's box, aka: Galton Board, quincunx, bean machine*/
trace off /*suppress error messages from a HALT. */
signal on halt /*allow the user to halt the program.*/
parse arg rows balls freez seed .
if rows =='' | rows=="," then rows= 0 /*Not specified? Then use the default.*/
if balls=='' | balls=="," then balls= 100 /* " " " " " " */
if freez=='' | freez=="," then freez= 0 /* " " " " " " */
if datatype(seed, 'W') then call random ,,seed /*Was a seed specified? Then use seed.*/
parse value scrsize() with sd sw . /*obtain the terminal depth and width. */
Line 2,928 ⟶ 2,933:
end /*g*/
do r=1 for g; _= strip(@.r, 'T'); if r==2 then _= _ left('', 9) info; say _
end /*r*/; if step==freez then
This REXX program makes use of '''SCRSIZE''' REXX program (or
BIF) which is used to determine the screen
Line 2,939 ⟶ 2,944:
The terminal size used for this display was '''64'''<small>x</small>'''96'''.
{{out|output|text= when the REXX program was "stopped" by using the
<pre>
·☼·
· · ·☼· ·
·
· · · · ·☼· ·
· ·
·
· · · · ·☼· · · · ·
· · ·
· · · · ·☼· · · · · · ·
· · · · ·
· · · · · ·☼· · · · · · · ·
☼
☼
☼
☼
☼
☼
☼
☼
☼
☼
☼
☼ ☼
☼ ☼
☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼
</pre>
{{out|output|text= when using the default inputs; this is the final screenshot:}}
<pre>
· step 353
· ·
Line 3,036 ⟶ 3,040:
· · · · · · · · · · · · · · ·
☼
☼
☼
☼ ☼
☼ ☼
☼ ☼
☼ ☼
☼ ☼
☼ ☼ ☼
☼ ☼ ☼ ☼
☼ ☼
☼ ☼
☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼
Line 3,057 ⟶ 3,058:
☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼
</pre>
|