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>pegspins to fill the top &nbsp; <big><sup>1</sup>/<sub>3</sub></big> &nbsp; rows of the terminal screen.
 
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). &nbsp; Currently, it is
hard-coded to &nbsp; '''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 . /*obtain optional arguments from the CL*/
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 pull; return /* [↑] show a row.*/</lang>
This REXX program makes use of &nbsp; '''SCRSIZE''' &nbsp; REXX program (or
BIF) which is used to determine the screen
Line 2,939 ⟶ 2,944:
The terminal size used for this display was &nbsp; '''64'''<small>x</small>'''96'''.
 
{{out|output|text=&nbsp; when the REXX program was "stopped" by using the default inputs of &nbsp; and&nbsp; the<tt> program, was, paused100 at</tt> step&nbsp; '''76'''so as to showfreeze the program to thiscapture screena shotscreenshot:}}
<pre>
 
☼· ·☼ step 75100
 
·☼·
 
·☼· ·☼·
 
· ·☼· · ·
 
· · ·☼· ·
 
· ·☼· ·☼· · ·
 
· · · · ·☼· ·
 
· · ·☼· ·☼· · · ·
 
· ·☼· · · ·☼· · · ·
 
· · · · ·☼· · · · ·
 
· · · ·☼· · · · · ·☼· ·
 
· · · · ·☼· · · · · · ·
 
· · · · · ·☼· ·☼· · · · · ·
 
· · · · · ·☼· · · · · · · ·
 
· · · · · · · · ·☼· · · · · · ·
 
 
 
 
 
 
 
 
 
 
 
 
 
☼ ☼
☼ ☼
☼ ☼
☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼
</pre>
{{out|output|text=&nbsp; when using the default inputs; &nbsp; this is the final screenshot:}}
<pre>
· step 353
 
· step 148
 
· ·
Line 3,036 ⟶ 3,040:
· · · · · · · · · · · · · · ·
 
 
 
 
☼ ☼
 
☼ ☼
 
☼ ☼
 
☼ ☼
 
☼ ☼
 
☼ ☼ ☼
 
☼ ☼ ☼ ☼
 
☼ ☼
☼ ☼ ☼ ☼
☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼
Line 3,057 ⟶ 3,058:
☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼
☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼
</pre>