Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Conway's Game of Life
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Algorithms== Early patterns with unknown futures, such as the R-pentomino, led computer programmers to write programs to track the evolution of patterns in the Game of Life. Most of the early [[algorithm]]s were similar: they represented the patterns as two-dimensional arrays in computer memory. Typically, two arrays are used: one to hold the current generation, and one to calculate its successor. Often 0 and 1 represent dead and live cells, respectively. A nested [[for loop]] considers each element of the current array in turn, counting the live neighbours of each cell to decide whether the corresponding element of the successor array should be 0 or 1. The successor array is displayed. For the next iteration, the arrays may swap roles so that the successor array in the last iteration becomes the current array in the next iteration, or one may copy the values of the second array into the first array then update the second array from the first array again. A variety of minor enhancements to this basic scheme are possible, and there are many ways to save unnecessary computation. A cell that did not change at the last time step, and none of whose neighbours changed, is guaranteed not to change at the current time step as well, so a program that keeps track of which areas are active can save time by not updating inactive zones.<ref>{{cite web|url=http://www.ibiblio.org/lifepatterns/lifeapplet.html|title=About my Conway's Game of Life Applet|author=Alan Hensel|access-date=July 12, 2009|archive-date=July 16, 2009|archive-url=https://web.archive.org/web/20090716231902/http://www.ibiblio.org/lifepatterns/lifeapplet.html|url-status=live}}</ref> [[File:Trefoil knot conways game of life.gif|alt=Game of Life on the surface of a trefoil knot|thumb|The Game of Life on the surface of a [[torus|toroidal]] [[Trefoil knot#In religion and culture|trefoil knot]]]] To avoid decisions and branches in the counting loop, the rules can be rearranged from an [[Egocentrism|egocentric]] approach of the inner field regarding its neighbours to a scientific observer's viewpoint: if the sum of all nine fields in a given neighbourhood is three, the inner field state for the next generation will be life; if the all-field sum is four, the inner field retains its current state; and every other sum sets the inner field to death. To save memory, the storage can be reduced to one array plus two line buffers. One line buffer is used to calculate the successor state for a line, then the second line buffer is used to calculate the successor state for the next line. The first buffer is then written to its line and freed to hold the successor state for the third line. If a [[torus|toroidal]] array is used, a third buffer is needed so that the original state of the first line in the array can be saved until the last line is computed. [[File:Long gun.gif|thumb|right|Glider gun within a toroidal array. The stream of gliders eventually wraps around and destroys the gun.]] [[File:Игра "Жизнь".gif|thumb|right|Red glider on a square lattice with periodic boundary conditions]] In principle, the Game of Life field is infinite, but computers have finite memory. This leads to problems when the active area encroaches on the border of the array. Programmers have used several strategies to address these problems. The simplest strategy is to assume that every cell outside the array is dead. This is easy to program but leads to inaccurate results when the active area crosses the boundary. A more sophisticated trick is to consider the left and right edges of the field to be stitched together, and the top and bottom edges also, yielding a [[torus|toroidal]] array. The result is that active areas that move across a field edge reappear at the opposite edge. Inaccuracy can still result if the pattern grows too large, but there are no pathological edge effects. Techniques of dynamic storage allocation may also be used, creating ever-larger arrays to hold growing patterns. The Game of Life on a finite field is sometimes explicitly studied; some implementations, such as ''[[Golly (program)|Golly]]'', support a choice of the standard infinite field, a field infinite only in one dimension, or a finite field, with a choice of topologies such as a cylinder, a torus, or a [[Möbius strip]]. Alternatively, programmers may abandon the notion of representing the Game of Life field with a two-dimensional array, and use a different data structure, such as a vector of coordinate pairs representing live cells. This allows the pattern to move about the field unhindered, as long as the population does not exceed the size of the live-coordinate array. The drawback is that counting live neighbours becomes a hash-table lookup or search operation, slowing down simulation speed. With more sophisticated data structures this problem can also be largely solved.{{Citation needed|date=September 2023}} For exploring large patterns at great time depths, sophisticated algorithms such as [[Hashlife]] may be useful. There is also a method for implementation of the Game of Life and other cellular automata using arbitrary asynchronous updates while still exactly [[Emulator|emulating]] the behaviour of the synchronous game.<ref>{{cite conference|title=Self-Reproduction in Asynchronous Cellular Automata|first=Chrystopher L.|last=Nehaniv|date=15–18 July 2002|conference=2002 NASA/DoD Conference on Evolvable Hardware|conference-url=https://ieeexplore.ieee.org/xpl/conhome/8000/proceeding|publisher=IEEE Computer Society Press|location=Alexandria, Virginia, USA|pages=201–209|isbn=0-7695-1718-8|doi=10.1109/EH.2002.1029886|hdl=2299/6834|hdl-access=free}}</ref> [[Source code]] examples that implement the basic Game of Life scenario in various programming languages, including [[C (programming language)|C]], [[C++]], [[Java (programming language)|Java]] and [[Python (programming language)|Python]] can be found at [[Rosetta Code]].<ref>{{Cite web|url=https://rosettacode.org/wiki/Conway%27s_Game_of_Life|title=Conway's Game of Life|date=June 7, 2024|website=Rosetta Code|access-date=July 2, 2024|archive-date=July 18, 2024|archive-url=https://web.archive.org/web/20240718213019/https://rosettacode.org/wiki/Conway%27s_Game_of_life|url-status=live}}</ref>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Conway's Game of Life
(section)
Add topic