| Life Game Operator
x = 0; y = 0;
neighbors = 0;
while ( y <= 15 ) do
x = 0;
while ( x <= 15 ) do
neighbors = 0;
if ( (y+1)<=15 ) then
if ( (x-1)>=0 ) then
if ( b[ x-1, y+1 ] >= 1 ) then
neighbors++;
end
end
if ( b[ x, y+1 ] >= 1 ) then
neighbors++;
end
if ( (x+1)<=15 ) then
if ( b[ x+1, y+1 ] >= 1 ) then
neighbors++;
end
end
end
if ( (x-1)>=0 ) then
if ( b[ x-1, y ] >= 1 ) then
neighbors++;
end
end
if ( (x+1)<=15 ) then
if ( b[ x+1, y ] >= 1 ) then
neighbors++;
end
end
if ( (y-1)>=0 ) then
if ( (x-1)>=0 ) then
if ( b[ x-1, y-1 ] >= 1 ) then
neighbors++;
end
end
if ( b[ x, y-1 ] >= 1 ) then
neighbors++;
end
if ( (x+1)<=15 ) then
if ( b[ x+1, y-1 ] >= 1 ) then
neighbors++;
end
end
end
if ( (b[ x, y ] == 0 ) and (neighbors == 3) ) then
b[ x, y ] = -1;
end
if ( (b[ x, y ] == 1 ) and ((neighbors < 2) or (neighbors > 3)) ) then
b[ x, y ] = 2;
end
x++;
next
y++;
next
y = 0;
while ( y <= 15 ) do
x = 0;
while ( x <= 15 ) do
select( b[ x, y ] )
case (-1):
b[ x, y ] = 1;
replace( board[ y ], "O", x, 1 );
break;
case 0:
replace( board[ y ], " ", x, 1 );
break;
case 1:
replace( board[ y ], "O", x, 1 );
break;
case 2:
b[ x, y ] = 0;
replace( board[ y ], " ", x, 1 );
break;
end
x++;
next
y++;
next
|