Questions tagged [conways-game-of-life]

The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. The "game" takes place on a 2D grid made up of cells that may either be "alive" or "dead". At each iteration, the state of each cell is computed based on the states of the cell and its 8 neighbors at the previous iteration.

From Wikipedia:

The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.

The "game" is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves.

594 questions
76
votes
24 answers

Code Golf: Conway's Game of Life

The Challenge: Write the shortest program that implements John H. Conway's Game of Life cellular automaton. [link] EDIT: After about a week of competition, I have selected a victor: pdehaan, for managing to beat the Matlab solution by one character…
45
votes
12 answers

Optimizing Conway's 'Game of Life'

To experiment, I've (long ago) implemented Conway's Game of Life (and I'm aware of this related question!). My implementation worked by keeping 2 arrays of booleans, representing the 'last state', and the 'state being updated' (the 2 arrays being…
OysterD
  • 6,660
  • 5
  • 34
  • 33
18
votes
2 answers

another Game of Life question (infinite grid)?

I have been playing around with Conway's Game of life and recently discovered some amazingly fast implementations such as Hashlife and Golly. (download Golly here - http://golly.sourceforge.net/) One thing that I cant get my head around is how do…
16
votes
1 answer

Game of Life patterns carried out incorrectly

My Conway's game of life implementation in Python doesn't seem to follow the rules correctly, and I can't figure out what could be wrong. When I put a final configuration into Golly, it continues past what mine did. I first identified the program by…
Luke Taylor
  • 8,631
  • 8
  • 54
  • 92
15
votes
1 answer

Conway's Game of Life - beyond the grid

Ok so there are a lot of "Conway's Game of Life" questions but this one is pretty specific. I'm going to have to throw a bunch of code at you first, break it down and show you where the issue is. So here is my Conway's Game of Life implementation so…
George Reith
  • 13,132
  • 18
  • 79
  • 148
13
votes
6 answers

What's an efficient implementation of Conway's Game of Life for low memory uses?

I'm looking for a fast and memory efficient approach for implementing Conway's Game of Life. Constraints: a 96x128 board, approximately 2kB RAM available and 52MHz processor (see the tech specs here: http://www.getinpulse.com/features). My current…
tlrobinson
  • 2,812
  • 1
  • 33
  • 35
12
votes
1 answer

A Haskell Game of life crashes when launched

I'm currently trying to develop a tiny Conway's Game of Life in Haskell. I wrote a library, lifegame, that enables to manage a grid of cells and to compute its generations (see github.com/qleguennec/lifegame.git). Generations is an infinite list. So…
qleguennec
  • 544
  • 4
  • 12
10
votes
2 answers

Confusing error in Game Of Life program

I have some working Game of Life code. It saves each population as a bitmap. Here's what the output looks like (cropped): When cleaning the code, I found that if I commented out or otherwise remove line 60: cout << "Survivor: " << x << ", " << y…
Quicksilver
  • 103
  • 4
9
votes
1 answer

Haskell parMap and parallelism

I have an implementation of Conway's Game of Life. I want to speed it up if possible by using parallelism. life :: [(Int, Int)] -> [(Int, Int)] life cells = map snd . filter rules . freq $ concatMap neighbours cells where rules (n, c) = n == 3…
cdk
  • 6,698
  • 24
  • 51
8
votes
7 answers

What do you call this JavaScript syntax, so I can research it?

1) In the following code, what is the reasoning behind making gameOfLive a variable and not just function gameOfLife()? 2) What is gol? It seems like an array, but I am unfamiliar with the syntax or what its called. I am studying…
jason
  • 4,721
  • 8
  • 37
  • 45
8
votes
5 answers

Multithreaded Java Program for Conway's game of life - contention at the border cells

I am learning concurrent programming in java, and writing a simulation for Game of Life. Here is what I am thinking: Use int[][] to store the states of the cells partition the int[][] into t segments and use t worker threads The t threads will read…
8
votes
2 answers

Brushes.White slows graphics demo down

Below is a (very naive) implementation of Conway's Game of Life in WPF. It's just a demo... xaml:
dharmatech
  • 8,979
  • 8
  • 42
  • 88
7
votes
3 answers

How to declare a two-dimensional array in Ruby

I want a twodimensional array in Ruby, that I can access for example like this: if @array[x][y] == "1" then @array[x][y] = "0" The problem is: I don't know the initial sizes of the array dimensions and i grow the array (with the << operator). How…
kadrian
  • 4,761
  • 8
  • 39
  • 61
7
votes
1 answer

Why does putStrLn slow down with each iteration?

I have made a small Game of Life program which iterates through generations by itself. The issue is that with each iteration, the putStrLn function slows down considerably, and I'm not able to figure out why. Here is the code: import…
Asgeir
  • 593
  • 6
  • 21
6
votes
1 answer

Why would setting a variable to its own address give different results on different program runs?

Yesterday I can across this obfuscated C code implementing Conway's Game of Life. As a pseudorandom generator, it writes code to this effect: int pseudoRand = (int) &pseudoRand; According to the author's comments on the program: This is a big…
templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
1
2 3
39 40