# Help for school project

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

Correct me here if I am wrong, but the purpose of a homework assignment is to learn how to solve a problem, not to have others do it for you… If you point out WHY you think it doesn’t work, and ask specific questions about how a line or segment of code does or does not work is one thing. But to wholesale say “it doesn’t work” does not contribute to your learning experience. You need to show that you have made an effort to address the issue…

@Dave S: hey, you can read my mind.

@Rami Ghantous: in addition to describing your problem, what you tried and what your error is you can also read up on the naming of variables and the usage of magic numbers.

oh… and use the CODE tags to make it easier to read posted code segments