Conway's Game of Life: Difference between revisions

Content added Content deleted
(→‎{{header|Brainf***}}: Link to Example-Output)
(→‎{{header|AWK}}: ANSI escape codes)
Line 475: Line 475:


=={{header|AWK}}==
=={{header|AWK}}==

50x20 grid, filled with random cells, running for 220 generations,
using ANSI escape codes for output to terminal:
<lang AWK>
<lang AWK>
BEGIN {
BEGIN { c=220; d=619; i=10000; printf("\033[2J");
c=220; d=619; i=10000;
printf("\033[2J"); # Clear screen
while(i--) m[i]=0;
while(i--) m[i]=0;
while(d--) m[int(rand()*1000)]=1;
while(d--) m[int(rand()*1000)]=1;

while(c--){
while(c--){
for(i=52; i<=949; i++){
for(i=52; i<=949; i++){
Line 487: Line 493:
else if(m[i]==1 && d>3) n[i]=0;
else if(m[i]==1 && d>3) n[i]=0;
}
}
printf("\033[1;1H");
printf("\033[1;1H"); # Home cursor
for(i=1;i<=1000;i++)
for(i=1;i<=1000;i++)
{
{
Line 494: Line 500:
if(!(i%50)) printf("\n");
if(!(i%50)) printf("\n");
}
}
printf("%3d\n",c); x=30000; while(x--) ;
printf("%3d\n",c);
x=30000; while(x--) ; # Delay
}
}
}
}
</lang>
</lang>

=={{header|BASIC256}}==
=={{header|BASIC256}}==
[[File:Game of life BASIC-256.gif|right|236px|thumb|"Thunderbird" methuselah evolution in the Game of Life (created with BASIC-256)]]
[[File:Game of life BASIC-256.gif|right|236px|thumb|"Thunderbird" methuselah evolution in the Game of Life (created with BASIC-256)]]