So I am doing the game of life by John Conway on Xojo and I need help to create a algorithm that generate a glider inside the Cellular automaton.
A glider looks like this http://www.conwaylife.com/wiki/Glider
This is my code so far, but it doesn’t work
dim i,j,l as integer
dim random as boolean
dim w as byte
dim mom(6,6) as boolean
dim find as boolean
dim vivante(6,6) as integer // Coordinates of the live neighbor cell
dim morte(6,6) as integer // Coordinates of the dead neighbor cell
dim voisines_vivantes, voisines_mortes as int16 // number of live neighbor cells and number of dead neighbor cells
// generate a random configuration
while not find
for i=1 to 5
for j=1 to 5
w=floor(rnd*2)+1
if w=1 then
random=false
else
random=true
end if
gameoflife(i,j)=random
mom(i,j)=random
next j
next i
for l=1 to 4 // we do 4 times the games rules
for i=1 to 5
for j=1 to 5
voisines_vivantes=0
voisines_mortes=0
if gameoflife(i-1,j-1)=true then
voisines_vivantes=voisines_vivantes+1
else
voisines_mortes=voisines_mortes+1
end if
if gameoflife(i,j-1)=true then
voisines_vivantes=voisines_vivantes+1
else
voisines_mortes=voisines_mortes+1
end if
if gameoflife(i-1,j)=true then
voisines_vivantes=voisines_vivantes+1
else
voisines_mortes=voisines_mortes+1
end if
if gameoflife(i+1,j+1)=true then
voisines_vivantes=voisines_vivantes+1
else
voisines_mortes=voisines_mortes+1
end if
if gameoflife(i+1,j)=true then
voisines_vivantes=voisines_vivantes+1
else
voisines_mortes=voisines_mortes+1
end if
if gameoflife(i,j+1)=true then
voisines_vivantes=voisines_vivantes+1
else
voisines_mortes=voisines_mortes+1
end if
if gameoflife(i+1,j-1)=true then
voisines_vivantes=voisines_vivantes+1
else
voisines_mortes=voisines_mortes+1
end if
if gameoflife(i-1,j+1)=true then
voisines_vivantes=voisines_vivantes+1
else
voisines_mortes=voisines_mortes+1
end if
vivante(i,j)=voisines_vivantes
morte(i,j)=voisines_mortes
next j
next i
// the games rules
For i=1 to 5
for j=1 to 5
if gameoflife(i,j)=true and (vivante(i,j)=2 or vivante(i,j)=3) then
gameoflife(i,j)=true
else
gameoflife(i,j)=false
end if
next j
next i
// the games rules
For i=1 to 5
for j=1 to 5
if gameoflife(i,j)=false and vivante(i,j)=3 then
gameoflife(i,j)=true
end if
next j
next i
next l
// this is the part that I don’t think is working
for i=1 to 5
for j=1 to 5
if mom(i,j)=gameoflife(i+1,j+1) then find=true
next j
next i
wend
jeu.Invalidate
Thanks for the help