Conway's Game of Life: Difference between revisions

Content added Content deleted
Line 1,344: Line 1,344:


[[File:Captura_de_pantalla_de_2022-10-07_04-37-57.png]]
[[File:Captura_de_pantalla_de_2022-10-07_04-37-57.png]]

<p>Version 2</p>
<p>Me di cuenta de que la subrutina "Count NBR" era un poco lenta, y además, una función que cuente los vecinos en un radio dado, me es útil para hacer juegos, por lo que incluí esa función dentro de las funciones de HOPPER.</p>
<p>Además, reescribí el programa "a la Hopper", como debió ser desde un principio.</p>
<syntaxhighlight lang="text">
#include <jambo.h>
#define SIZER 90
#define SIZEC 120

Main
Cls
Hide cursor

Dim (SIZER, SIZEC), as zeros 'grid, neighbour_count'
Dim (SIZER, SIZEC), as fill '" ",disp grid'
c=0 , Let( c := Utf8(Chr(254)))

m={}
Set ' 0,1,1 ' Apend row to 'm'
Set ' 1,1,0 ' Apend row to 'm'
Set ' 0,1,0 ' Apend row to 'm'
[44:46, 59:61] Set 'm', Put 'grid'
Clr all marks
radio=1, r=0

Tok sep '""'

Locate (1,1)
Loop
i=1
Iterator ( ++i, Less equal(i,SIZER),\
j=1, Iterator ( ++j, Less equal(j,SIZEC), \
[i,j], Neighbour count (grid,radio), Put 'neighbour_count' ) )
Cartesian ( Greater equal(grid, 1)---Back up to 'r'--- Mul by 'neighbour_count';\
Out of range including '1,4' )
Get range, Set '0," "', Put 'disp grid', Put 'grid', Forget

Cartesian ( Not( r ); Mul by 'neighbour_count'; Is equal to '3' )
Get range, Set '1,c', Put 'disp grid', Put 'grid', Forget
Clr range

Clr all marks
Print table 'disp grid'
Break if ( Key pressed )
Back
Pause
Show cursor
End

</syntaxhighlight>
{{out}}
La salida es la misma, pero ahora va mucho más rápido... parecen estrellitas explotando :D


=={{header|APL}}==
=={{header|APL}}==