BBS: Inland Empire Archive Date: 01-19-93 (23:54) Number: 327 From: CORIDON HENSHAW Refer#: NONE To: ALL Recvd: NO Subj: Cellular Automata Conf: (2) Quik_Bas
Hello All! The code below is a simple Cellular Automata program. This is sometihing that I converted from (gack) C to BASIC. If you have any comments/changes, I'd like to see them. ===Chop=== 'NAME: CELULAR.BAS 'DESC: Simple Cellular Automata 'REQU: VGA adapter 'FROM: Coridon Henshaw (1:250/820) 'DATE: 19 JAN 93 'PORT: C -> BASIC 'BEGIN: SCREEN 13 DEF SEG = &HA000 RANDOMIZE TIMER DEFINT A-Z DIM ruletable(0 TO 7) AS INTEGER 'int ruletable[8] = {0,1,1,1,1,0,0,0} DIM oldbuff(0 TO 641) AS INTEGER DIM newbuff(0 TO 641) AS INTEGER ruletable(0) = 0 '0 ruletable(1) = 1 '1 ruletable(2) = 1 '1 ruletable(3) = 1 '1 ruletable(4) = 1 '1 ruletable(5) = 0 '0 ruletable(6) = 0 '0 ruletable(7) = 0 '0 oldbuff(319 \ 2) = 1 WHILE Exitflag = 0 FOR x = 0 TO 199 FOR i = 1 TO 320 nabecode = 4 * oldbuff(i - 1) + 2 * oldbuff(i) + oldbuff(i + 1) newbuff(i) = ruletable(nabecode) NEXT FOR i = 0 TO 319 pointer& = pointer& + 1 POKE pointer&, newbuff(i) oldbuff(i) = newbuff(i) newbuff = 0 NEXT NEXT pointer& = 0 Ikey$ = INKEY$ SELECT CASE LEN(Ikey$) CASE 1, 2 Exitflag = 1 CASE 0 FOR i = 0 TO 7'<8 ruletable(i) = INT(2 * RND) NEXT END SELECT WEND ===Chop=== That's all folks! \ Coridon Henshaw \ ³ \ Sirrus Software \ \ ³ / \ Sysop, \ ÄÄÄÄ*ÄÄÄÄ \ TCS Concordia \ / ³ \ \ 34:3416/18 \ ³ ...I intend to discover who are the prisoners and who are the warders. --- GEcho 1.00 * Origin: Politicly INcorrect and damn proud of it (1:250/820)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET