' Descending Cellular Automata ' (5 cell influence version) ' ' By Allan Crossman, September 6, 2002 startfractalnum = 4198926602 ' Use this to replicate patterns if needed. odd = 1 even = 2 dim createcell(31) firstcell = 1 randomize timer linearraysize = (screen height * 4) + 10 dim evenline(linearraysize) dim oddline(linearraysize) resize console 0, 20, screen width, screen height forecolor 65535, 65535, 65535 center = (screen height * 2) + 5 plotadjust = int(screen width / 2) - center RESTART: wait button up randomfactor = ((rnd * 1.2) + 0.4) / 2 for n = 0 to linearraysize evenline(n) = 0 oddline(n) = 0 next n fractalnum = 0 if startfractalnum then ' NOTE: startfractalnum will be 0 after the first run. for n = 31 to 0 step -1 if startfractalnum >= (2 ^ n) then createcell(n) = 1 startfractalnum = startfractalnum - (2 ^ n) fractalnum = fractalnum + (2 ^ n) else createcell(n) = 0 end if next n else for n = 0 to 31 if rnd > randomfactor then createcell(n) = 1 fractalnum = fractalnum + (2 ^ n) else createcell(n) = 0 end if next n end if cls text 20, 20, "Click to restart, press any key to end." text 20, 40, "Fractalnum = " + str$(fractalnum) leftedge = center rightedge = center iteration = 0 if firstcell then evenline(center) = 1 plot center + plotadjust, 0 end if MAIN: if button then goto RESTART if inkey$ <> "" then goto ENDPROG iteration = iteration + 1 if iteration > screen height then WAITLOOP: if button then goto RESTART if inkey$ <> "" then goto ENDPROG goto WAITLOOP end if leftedge = leftedge - 2 rightedge = rightedge + 2 if iteration mod 2 = 0 then linetodraw = even else linetodraw = odd end if gosub DOLINE goto MAIN DOLINE: if linetodraw = even then for n = leftedge to rightedge quint = 0 if oddline(n - 2) then quint = quint + 16 if oddline(n - 1) then quint = quint + 8 if oddline(n) then quint = quint + 4 if oddline(n + 1) then quint = quint + 2 if oddline(n + 2) then quint = quint + 1 if createcell(quint) then evenline(n) = 1 plot n + plotadjust, iteration else evenline(n) = 0 end if next n else for n = leftedge to rightedge quint = 0 if evenline(n - 2) then quint = quint + 16 if evenline(n - 1) then quint = quint + 8 if evenline(n) then quint = quint + 4 if evenline(n + 1) then quint = quint + 2 if evenline(n + 2) then quint = quint + 1 if createcell(quint) then oddline(n) = 1 plot n + plotadjust, iteration else oddline(n) = 0 end if next n end if return ENDPROG: disable done end