'---------------------------------------------
'  _ɏzusLife game
'---------------------------------------------
system.err.exit=1'\G[̃vO~

X_SIZE=50
Y_SIZE=20

clr

'f[^쐬

for y=1 to Y_SIZE
for x=1 to X_SIZE
'ϐrandɂ胉_ɔzu
if rand > rand then scr[x][y]="_" else scr[x][y]="#"

next x
next y



Loop1:

for y=1 to Y_SIZE
for x=1 to X_SIZE

data[x][y]=scr[x][y]

next x
next y

'goto scr_print:

for y=1 to Y_SIZE
for x=1 to X_SIZE

'a: łZ̎͂3̐ĂZΎ̐ł͐iajB 

Birth = 0
if data[x][y]<>"_" then goto Birth_end:
if data[x-1][y]="#" then Birth = Birth + 1
if data[x+1][y]="#" then Birth = Birth + 1
if data[x][y-1]="#" then Birth = Birth + 1
if data[x][y+1]="#" then Birth = Birth + 1
if data[x+1][y+1]="#" then Birth = Birth + 1
if data[x+1][y-1]="#" then Birth = Birth + 1
if data[x-1][y+1]="#" then Birth = Birth + 1
if data[x-1][y-1]="#" then Birth = Birth + 1
if Birth=3 then scr[x][y]="#"

Birth_end:

'ێ: ĂZ̎͂23̐ĂZΎ̐łcB 
'S: ȊȌꍇɂ͎̐ł͎ʁB

Dies = 0
if data[x][y]<>"#" then goto Dies_end:
if data[x-1][y]="#" then Dies = Dies + 1
if data[x+1][y]="#" then Dies = Dies + 1
if data[x][y-1]="#" then Dies = Dies + 1
if data[x][y+1]="#" then Dies = Dies + 1
if data[x+1][y+1]="#" then Dies = Dies + 1
if data[x+1][y-1]="#" then Dies = Dies + 1
if data[x-1][y+1]="#" then Dies = Dies + 1
if data[x-1][y-1]="#" then Dies = Dies + 1
if Dies<2 then scr[x][y]="_"
if Dies>3 then scr[x][y]="_"

Dies_end:

next x
next y

scr_print:

for y=1 to Y_SIZE
str=""
for x=1 to X_SIZE

str=str+scr[x][y]

next x
location y,1
print str
next y

location 1,1
print ""
location 1,1
print ""
location 1,1
print ""
location 1,1
print ""

goto Loop1:


