Here's the life program I wrote. As far as I know, it's functional. The problems are that it is very slow, all life dies quickly in anything lower than a 12x12 game, and the matrix that I'm saving to consumes too much space. Any help with this would be appreciated.


Code:

:1→A
:1→B
:Input D
:{D,D→dim([A]
:Fill 0,[A])
:D+1→D
:If 0:"RANDOM START"
:While B≠D:
:¦ If randInt(1,3)=1:Pxl-Change(A,B)
:¦ If 0:"MOVES ON BETWEEN CELLS"
:¦ A+1→A
:¦ If A=D:Then:
:¦ ¦ B+1→B
:¦ ¦ 1→A
:¦ End
:End
:If 0:"END"
:1→B
:While 1:
:¦ While B≠D:
:¦ ¦ If 0:"MARKS CELLS FOR DEL/CREATE"
:¦ ¦ pxl-Test(A,B)→C
:¦ ¦ pxl-Test(A,B-1)+pxl-Test(A,B+1)+pxl-Test(A-1,B)+pxl-Test(A+1,B)+pxl-Test(A+1,B+1)+pxl-Test(A+1,B-1)+pxl-Test(A-1,B+1)+pxl-Test(A-1,B-1)→P
:¦ ¦
:¦ ¦ Text(50,0,P)
:¦ ¦
:¦ ¦ If C=0 and P=3:1→[A](A,B)
:¦ ¦ If C=1 and P≤1 or P≥4:0→[A](A,B)
:¦ ¦ If 0:"END"
:¦ ¦ If 0:"MOVES ON BETWEEN CELLS"
:¦ ¦ A+1→A
:¦ ¦ If A=D:Then:
:¦ ¦ ¦ B+1→B
:¦ ¦ ¦ 1→A
:¦ ¦ End
:¦ ¦ If 0:"END"
:¦ End
:¦ 1→B
:¦ If 0:"MAKES CHANGES"
:¦ Text(50,0,"HERE"
:¦ While B≠D:
:¦ ¦ If [A](A,B)=1:Then:
:¦ ¦ ¦ Pxl-On(A,B)
:¦ ¦ ¦ Else:
:¦ ¦ ¦ Pxl-Off(A,B)
:¦ ¦ End
:¦ ¦ If 0:"MOVES"
:¦ ¦ A+1→A
:¦ ¦ If A=D:Then:
:¦ ¦ ¦ B+1→B
:¦ ¦ ¦ 1→A
:¦ ¦ End
:¦ ¦ If 0:"END"
:¦ End
:¦ 1→A
:¦ 1→B
:End
This is the game of life, correct? I've never seen a fast, working version in BASIC.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement