格仔自動機

格仔自動機，又叫細胞自動機，係種離散模型，可算性理論、數學、理論生物學都有研究渠。渠由無限格有規律、硬掘掘嘅格仔 組成，每格都處於有限種態之一。成個格仔網可以係任何有限維嘅。時亦都係離散嘅。每格響t 時嘅態由 t-1時嘅一集有限格嘅態決定。每一格嘅「鄰居」都係固定咗嘅。每次演進，每格都遵從同一規矩，一齊演進。

概覽 
格仔自動機嘅一例係一張無限大嘅格仔紙，每格一係黑、一係白。每格有八格「鄰居」，總共29 = 512 種可能嘅鄰域。格仔自動機嘅演變規律可用一張表來表示。由五百一十二種可能嘅鄰域，張表會講明下次呢格係黑定係白。呢樣就係二維CA嘅一例。Conway嘅生命棋就係其中最受歡迎者。

通常我哋會假設盤棋開始時，除咗有限咁多格，每格都屬同一態；而嗰有限咁多格就叫「位形」。推而廣之，亦可假設，除咗有限咁多格，初始棋盤係週期性嘅－－呢種做法響一維CA 常見啲。

通常我哋會用個有限大嘅格仔網來模擬一架格仔自動機。二維嘅自動機宇宙就會用長方形來模擬。咁當然會出問題：響條邊嘅格仔點算？做法嘅選擇會影響成個長方形嘅演變。一種做法係畀渠哋一個常值。另一種解係改「鄰域」嘅定義。例如，我哋可以拉畫面來整出一個錨環面。當一舊棋過咗上界，渠就會由下底同一位置出番來；過咗左界就會由右邊出番來。我哋可以睇渠做個長方形，左邊黏埋右邊，上邊黏埋下邊，成為一環面。第啲維度嘅宇宙都照做。咁做係為咗化解邊界鄰域嘅麻煩嘢。例如，響下面嘅一維自動機，嘅鄰域 of 格仔xit— 其中 t 係步數而 i 係 the index  一代裏面—係 {xi−1t−1, xit−1, xi+1t−1}。當左界一鄰域揾渠嘅左上格做渠鄰居，就會出問題。

史 

1940年代，響洛斯阿拉莫斯國家實驗室做嗰時，用過一簡單嘅來研究晶體增長。同時，渠同事就研究緊。初頭 von Neumann 嘅設計原理係「一隻機械人砌另一隻機械人」－又叫做郁模型。漸漸，von Neumann 明白砌隻自我複製嘅機械人有幾難，同埋要畀隻機械人海量嘅零件來砌嘢有幾咁貴。Ulam 叫 von Neumann 試吓圍繞住種數學抽象來發展渠嘅設計，好似 Ulam 自己嘅結晶模型。咁樣就出咗第一架格仔自動機。好似 Ulam 嘅格仔網，von Neumann架格仔自動機係兩維嘅；隻自我複製機就用算法來實現。其結果就係架，活動響一架細鄰域嘅格仔自動機入面，而每格有 29 態。von Neumann 證明咗有種棋形會響個格仔世界入面無止境咁砌自己嘅複製－叫做密鋪模型。

1970年代，出現咗生命棋－一架兩態、兩維嘅自動機。生命棋出咗名，尤其響電算社羣入面。

生命棋由John Conway發明，由Martin Gardner 響Scientific American嘅一篇文推廣。渠嘅規則係：若果一黑格有兩或三格黑鄰，咁渠就繼續黑；若一白格有剛啱三黑鄰格，咁渠就變黑；其餘情況下，嗰格下次都白。就咁，一盤生命棋可以有咁複雜得咁複雜，響似乎混亂同埋秩序之間搖擺。一種常見嘅棋形係「滑翔機」－會響棋盤上打斜郁嘅幾格棋。我哋可以砌到令尐滑翔機互相影響，來模擬出計算，甚至模擬普適Turing機。

或者多數人覺得生命棋屬於玩，係咁意探下啲得意嘢、睇下第啲有關棋則以外，好少有跟進。

但1969年德國電算先驅Konrad Zuse出版咗本《計出空間》Calculating Space，提出宇宙嘅規律嘅本質係離散嘅，而成個宇宙係架巨格仔自動機嘅先決(?)(deterministic)嘅計算結果。

1983年，Stephen Wolfram出咗渠一系列文嘅第一篇，討論一種好基本、但之前無人惏過嘅自種機 － 渠叫其做「基本格仔自動機」－ 睇下面。出奇嘅係，呢尐簡單嘅法則，演變出來好複雜。咁Wolfram 就猜測大自然嘅複雜性都係類似機制生出來嘅。重有，呢段時間 Wolfram 發展咗內蘊偶然混亂性同埋計算可約性，提出rule 110可能係 普適—後來Matthew Cook喺1990年代證咗。

1980年代尾，Wolfram 離開咗學院，專心砌Mathematica；跟住用其來推展渠嘅早期結果，到一廣泛系列嘅簡單抽象系統。2002年渠出咗本A New Kind of Science來講渠嘅格仔自動機嘅結果，重話呢啲發現唔係單丁嘅偶然事，而係硬淨嘅，重會影響每一門科學。呢本書無倡議用格仔自動機來砌基礎物理，但描述咗幾種基於CA 嘅物理模型，亦有畀基於性質完全唔同嘅抽象系統嘅模型。

Rudy Rucker喺渠2005年本書生命盒、海螺同埋靈魂推展Wolfram嘅理論到「普遍自動性」－用格仔自動機來模型來解釋簡單嘅規律點樣會產生複雜嘅結果。

最簡單 
最簡單嘅格仔自動機得一維；每格得兩態；每格嘅鄰居就係渠左右嘅兩格。一格同渠左右夾埋組成一鄰域，總共有 23=8 咁多種可能嘅棋形。  咁總共有 28=256種規律。呢啲自動機通常會用Wolfram 記號來表示。一架自動機嘅名就係個十進制數，其相應二進制表示就畀出個演化規律表。例如三十號機同埋一百一十號機嘅演化表就係 30x=00011110ii and 110x=1101110ii。咁，三十號機 00011110 最高位嘅 0 代表111-->0，次高位嘅0代表 110-->0，跟住 101-->0,  100-->1, 011-->1, 010-->1, 001-->1, 000-->0。若果我哋由單丁個1開始，三十號機同一百一十號機會整出：

咁一張表就完全定義好一架格仔自動機。例如，30號機嘅表就話：若果有左中右三格係100，咁中間嗰格下次就會變做1。

有幾篇文分析同比較呢二百五十六架機。30號同一百一十號機就特別好頑。

30號由唔算混亂嘅初始值生出混亂。Wolfram 提議用渠中間一棟來做架模擬亂值機；呢項提議過咗好多種標準嘅測試都；Wolfram 就喺Mathematica 應用咗。雖然30號機可由好多種輸入整出混亂，但亦有無限咁多種輸入會整出週期嘅結果。最基本嘅例係開頭全零。 Matthew Cook發現，任何有無限串'00001000111000'，之間隔住六格'1'，都得。

一百一十號機，好似生命棋，顯示出種Wolfram所謂嘅 「第四類行為」，既唔完全亂來，亦唔係完全 週期性嘅。有好幾種局部嘅結構會出現同埋互相影響。1994年，本A New Kind of Science重寫緊時，Cook證明咗 呢啲結構足夠支持普適性。咁樣就好頑：一百一十號機係架好簡單嘅一維系統，但要整到渠做特定嘅嘢就唔易。呢項結果好支持 Wolfram嘅觀點，第四類嘅系統本內就好可能係普適嘅。Cook喺1998年Santa Fe Institute格仔自動機會報告咗渠份證明，但 Wolfram阻住唔畀會議紀錄登份證明，因渠唔想份證明早過渠本《A New Kind of Science》出。2004年，Wolfram 份雜誌 Complex Systems (Vol. 15, No. 1) 終於登咗Cook嘅證－足足等咗十年。

可逆 
一架自動機叫可逆，若果渠上面每一種棋形都只得一幅前象。若我地當架自動機係一支函數，由一形狀彈去另一形狀，咁即係話支函數係雙射。

For one dimensional CA there are known algorithms for finding preimages, and any 1D rule can be proved either reversible or irreversible. For CA of two or more dimensions it has been proved that the reversibility is undecidable for arbitrary rules. The proof by Jarkko Kari is related to the tiling problem by Wang tiles.

Reversible CA are often used to simulate such physical phenomena as gas and fluid dynamics, since they obey the laws of thermodynamics. Such CA have rules specially constructed to be reversible. Such systems have been studied by Tommaso Toffoli, Norman Margolus and others.

For finite CAs that are not reversible, there must exist patterns for which there are no previous states. These patterns are called Garden of Eden patterns. In other words, no pattern exists which will develop into a Garden of Eden pattern.

Several techniques can be used to explicitly construct reversible CA with known inverses. Two common ones are the second order technique and the partitioning technique, both of which involve modifying the definition of a CA in some way. Although such automata do not strictly satisfy the definition given above, it can be shown that they can be emulated by conventional CAs with sufficiently large neighborhoods and numbers of states, and can therefore be considered a subset of conventional CA.

Totalistic 
A special class of CAs are totalistic CAs. The state of each cell in a totalistic CA is represented by a number (usually an integer value drawn from a finite set), and the value of a cell at time t depends only on the sum of the values of the cells in its neighborhood (possibly including the cell itself) at time t−1.  If the state of the cell at time t does depend on its own state at time t−1 then the CA is properly called outer totalistic, although the distinction is not always made. Conway嘅生命棋 is an example of an outer totalistic CA with cell values 0 and 1.

A notation exists to describe rulesets of two-state totalistic CAs consisting of an initial indicating the neighbourhood of each cell and sums following the letters S (for survival) and B (for birth) for which those changes occur. In this notation Conway's Game of Life is M:S23/B3. This notation has been extended for non-totalistic CAs, where a letter or letters follow each sum indicating what patterns of neighbours cause survival or birth events.

密碼學用 
Rule 30 was originally suggested as a possible stream cipher for use in cryptography. 

Cellular automata have been proposed for public key cryptography.  The one way function is the evolution of a finite CA whose inverse is believed to be hard to find.  Given the rule, anyone can easily calculate future states, but it appears to be very difficult to calculate previous states.  However, the designer of the rule can create it in such a way as to be able to easily invert it.  Therefore, it is apparently a trapdoor function, and can be used as a public-key cryptosystem.  The security of such systems is not currently known.

相關嘅自動機 
格仔自動機嘅概念有多種推廣。

One way is 可以唔用長方，用第啲形狀，如三角by using something other than a rectangular (cubic, etc.) grid.  For example, if a plane is tiled with equilateral triangles, those triangles could be used as cells.

Also, rules can be probabilistic rather than deterministic.  A probabilistic rule gives, for each pattern at time t, the probabilities that the central cell will transition to each possible state at time t+1.  Sometimes a simpler rule is used; for example: "The rule is the Game of Life, but on each time step there is a 0.001% probability that each cell will transition to the opposite color."

The neighborhood or rules could change over time or space. For example, initially the new state of a cell could be determined by the horizontally adjacent cells, but for the next generation the vertical cells would be used.

The grid can be finite, so that patterns can "fall off" the edge of the universe.

In CA, the new state of a cell is not affected by the new state of other cells. This could be changed so that, for instance, a 2 by 2 block of cells can be determined by itself and the cells adjacent to itself.

又有連續自動機。呢種機類似 totalistic CA，但渠地嘅態用埋演變律都係連續函數。   Certain CA can yield diffusion in liquid patterns in this way.

Continuous spatial automata have a continuum of locations. The state of a location is a finite number of real numbers. Time is also continuous, and the state evolves according to differential equations.  One important example is reaction-diffusion textures, differential equations proposed by Alan Turing to explain how chemical reactions could create the stripes on zebras and spots on leopards. When these are approximated by CA, such CAs often yield similar patterns. MacLennan  considers continuous spatial automata as a model of computation.

There are known examples of continuous spatial automata which exhibit propagating phenomena analogous to gliders in the Game of Life.

自然 biotic types 

有啲生物會用上自然嘅格仔自動機。

有啲海螺，如Conus同Cymbiola 屬，嘅紋形係由自然嘅格仔自動機生出來嘅。色素細胞住喺沿住個殼條邊嘅一條窄帶上。每粒細胞依佢週圍細胞嘅活唔活躍，用一條數來決定分唔分泌色素。呢條細胞帶會慢慢生，將啲色圖案留喺個殼上。例如，分布好廣嘅Conus textile 就着住種好似上面三十號自動機嘅圖案。

Plants regulate their intake and loss of gases via a CA mechanism. Each stoma on the leaf acts as a cell.

化學 types 
The Belousov-Zhabotinsky reaction is a spatio-temporal chemical oscillator which can be simulated by means of a cellular automaton. In the 1950s A. M. Zhabotinsky (extending the work of B. P. Belousov) discovered that when a thin, homogenous layer of a mixture of malonic acid, acidified bromate and a ceric salt were mixed together and left undisturbed, fascinating geometric patterns such as concentric circles and spirals propagate across the medium.  In the "Computer Recreations" section of the August 1988 issue of Scientific American Professor A. K. Dewdney presented a cellular automaton whose behavior closely resembles the Belousov-Zhabotinsky reaction. Whether the Belousov-Zhabotinsky reaction actually occurs as the result of a cellular automaton at the molecular level is not yet known. So far, no naturally occurring chemical cellular automata have been observed. All such reactions are done in laboratory settings.

電算處理器Computer processors 
CA processors are a physical, not software only, implementation of CA concepts, which can process information computationally. Processing elements are arranged in a regular grid of identical cells. The grid is usually a square tiling, or tessellation, of two or three dimensions; other tilings are possible, but not yet used. Cell states are determined only by interactions with the small number of adjoining cells. Cells interact, communicate, directly only with adjoining, adjacent, neighbor cells. No means exists to communicate directly with cells farther away. Cell interaction can be via electric charge, magnetism, vibration (phonons at quantum scales), or any other physically useful means. This can be done in several ways so no wires are needed between any elements.

This is very unlike processors used in most computers today, von Neumann designs, which are divided into sections with elements that can communicate with distant elements, over wires.

改錯碼 (Error Correction Coding) 
有人用格仔自動機來設計改錯碼－睇下《Design of CAECC - Cellular Automata Based Error Correcting Code》，作者係   	
D. Roy Chowdhury, S. Basu , I. Sen Gupta , P. Pal Chaudhuri。呢篇文定義一種新計，用CA來砌 SEC-DED 碼，重幫呢套碼報告咗一架快嘅硬件解碼器。

CA 嘅例 
 Conway's Game of Life
 Life-like cellular automata
 Cyclic cellular automaton
 Langton's ant
 Wireworld
 Rule 30
 Rule 110
 Rule 184

自我複製 
 Byl's loop
 Chou-Reggia loop
 Codd's cellular automaton
 Evoloop
 Langton's loops
 SDSR loop
 von Neumann's Universal constructor
 Asynchronous cellular automaton

格仔自動機解決嘅問題 
 Majority problem
 Firing squad synchronization problem

相關課題 
 自然形態規律
 A New Kind of Science
 Automata theory
 Excitable medium
 The Ooze
 Spatial Decision Support System - Mentions cellular automata based models of land use dynamics which allow urban and regional planners to test intervention strategies.

攷 
"History of Cellular Automata" from Stephen Wolfram's A New Kind of Science 
Cellular automaton FAQ from the newsgroup comp.theory.cell-automata
Neighbourhood survey includes discussion on triangular grids, and larger neighbourhood CAs.
 von Neumann, John, 1966, The Theory of Self-reproducing Automata, A. Burks, ed., Univ. of Illinois Press, Urbana, IL. 
 Wolfram, Stephen, 1985, Cryptography with Cellular Automata, CRYPTO'85. 
Cosma Shalizi's Cellular Automata Notebook contains an extensive list of academic and professional reference material.
Wolfram's papers on CAs
 A.M. Turing. 1952. The Chemical Basis of Morphogenesis. Phil. Trans. Royal Society, vol. B237, pp. 37 - 72. (proposes reaction-diffusion, a type of continuous automaton).
 Jim Giles. 2002. What kind of science is this? Nature 417, 216 - 218. (discusses the court order that suppressed publication of the rule 110 proof).
Zuse´s publications on CA-based physics (1967, 1969, 1970), with comments by Juergen Schmidhuber
 Frish U., Hasslacher B., and Pommeau Y. Lattice gas method for partial differential equations. Phys. Rev. Lett., 56(1505), 1986.
 Peak, West, Messinger, Mott (2004) "Evidence for complex, collective dynamics and emergent, distributed computation in plants". Proceedings of the National Institute of Science of the USA 101 (4), 918-922

Mirek's Cellebration - Home to free MCell and MJCell cellular automata explorer software and rule libraries. The software supports a large number of 1D and 2D rules. The site provides both an extensive rules lexicon and many image galleries loaded with examples of rules. MCell is a Windows application, while MJCell is a Java applet. Source code is available.
Modern Cellular Automata - Easy to use interactive exhibits of live color 2D cellular automata, powered by Java applet. Included are exhibits of traditional, reversible, hexagonal, multiple step, fractal generating, and pattern generating rules. Thousands of rules are provided for viewing. Free software is available. 
Repeating Rule 30 patterns - A list of Rule 30 input patterns that produce repeating patterns.
Self-replication loops in Cellular Space - Java applet powered exhibits of self replication loops.
Web base CA generator - Experiment with creating image files containing pictures of 1D cellular automata. C++ source code is available.
EvoCell is a platform for evolving cellular automatons - Released under the GPL
Tiled CA - Windows software with source code for creating tiled CA.
Triangular, pentagonal, and hexagonal CA - Java applet powered interactive exhibits.
Free web-app to watch cellular automata grow in your browser - Build elementary 1D cellular automata.
Prenzl!! Artistic Cellular Automata - Open source software to run and develop artistic cellular automata and other dynamical systems
Open source Java code and application for multiple state CA on 2D lattice

電算