Elementary Cellular Automaton

 投稿者:しばっち  投稿日:2015年10月28日(水)22時16分48秒
  http://mathworld.wolfram.com/Rule28.html
http://mathworld.wolfram.com/Rule50.html

!'Elementary Cellular Automaton
CALL GINIT(800,400)
DIM M(50,25)
INPUT  PROMPT "RULE=":RULE !' 0<RULE<=255(2^8-1)
LET M(25,1)=1 !'初期値
FOR Y=1 TO 24
   FOR X=1 TO 50
      IF X-1>=1 THEN  LET CC=4*M(X-1,Y)
      LET CC=CC+2*M(X,Y)
      IF X+1<=50 THEN LET CC=CC+M(X+1,Y)
      IF BITAND(RULE,2^CC)>0 THEN
         LET M(X,Y+1)=1
      END IF
   NEXT X
NEXT  Y
SET WINDOW 0,1,1,0
MAT PLOT CELLS, IN 0 , 0 ; 1,1 : M
END

EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
!'SET WINDOW 0,XSIZE-1,YSIZE-1,0
SET POINT STYLE 1
SET COLOR MODE "REGULAR"
!'SET COLOR MIX(0) 0,0,0
!'SET COLOR MIX(1) 0,0,1
SET COLOR MIX(2) 1,0,0
SET COLOR MIX(3) 1,0,1
SET COLOR MIX(4) 0,1,0
SET COLOR MIX(5) 0,1,1
SET COLOR MIX(6) 1,1,0
SET COLOR MIX(7) 1,1,1
CLEAR
END SUB
 

戻る