So I have uploaded some Code here: QRYPDE83. Can somebody please tell me why it doesn't work?
Game of Life Code doesn't work
Root / Programming Questions / [.]
KevinTheDumbCatCreated:
Well first, you should use FOR instead of WHILE:
DEF RANDOM BOARD Y=3 X=3 WHILE Y<26 CELLS[X+2,Y+2]=RND(2) INC X,2 IF X==47 THEN X=3 INC Y,2 WEND NEIGHBORCHECK ENDcan be:
DEF RANDOM BOARD VAR X,Y FOR Y=3 TO 26-1 STEP 2 FOR X=3 TO 47-1 STEP 2 CELLS[X+2,Y+2]=RND(2) NEXT NEXT NEIGHBORCHECK ENDAnyway, I assume the main problem is with the edges This is because everything outside the board is treated as a living cell (because you made 0 = alive and 1 = dead, and it starts out filled with 0s)
Well first, you should use FOR instead of WHILE:Thanks! After changing the zeros and ones around, it works! And I've changed the while-loops to for-loops!DEF RANDOM BOARD Y=3 X=3 WHILE Y<26 CELLS[X+2,Y+2]=RND(2) INC X,2 IF X==47 THEN X=3 INC Y,2 WEND NEIGHBORCHECK ENDcan be:DEF RANDOM BOARD VAR X,Y FOR Y=3 TO 26-1 STEP 2 FOR X=3 TO 47-1 STEP 2 CELLS[X+2,Y+2]=RND(2) NEXT NEXT NEIGHBORCHECK ENDAnyway, I assume the main problem is with the edges This is because everything outside the board is treated as a living cell (because you made 0 = alive and 1 = dead, and it starts out filled with 0s)