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
3
votes
1 answer

Dealing with large distance between cells in Hashlife

I am writing an implementation of Conway's Game of Life and decided to use a variation of the Hashlife algorithm, using quadtrees and a hashtable to store cells and handle collisions, somewhat similar to what is described here and here. The details…
Justin Hamilton
  • 570
  • 1
  • 5
  • 13
3
votes
1 answer

How do I iterate over a list of union cases and access each case's data?

How do I iterate over a list of union cases and access each case's data? I have this line: root.Neighbors |> Seq.filter(fun x -> print x) However, Neighbors is a list: Neighbors=[ One { State=Survives; Neighbors=[] } Two {…
Scott Nimrod
  • 11,206
  • 11
  • 54
  • 118
3
votes
1 answer

Conway's Game of Life New Values

The question revolves around Conway's Game of Life and how to implement all the rules at the same time for the new generations. The game follows three rules for new generations, which are: a dead cell with exactly three live neighbors becomes live,…
3
votes
1 answer

Making a 2D array toroidal

How can I make the array toroidal (wrap bottom to top and left to right), i.e the leftmost cell is regarded as the rightmost cell, like [0][0] and [5][5] are the same cells in int array[5][5]
Finlandia_C
  • 385
  • 6
  • 19
3
votes
2 answers

Undeclared identifier error where none seems apparent

I am trying to implement a simple version of Conway's Game of Life which consists of a header file and three .cpp files (two for class functions, one for main). Here I have included my header files and two class function declaration files ( the…
Chubzorz
  • 135
  • 1
  • 2
  • 7
3
votes
1 answer

Implementing Conway's Game of Life in JavaScript with

I've got some problems implementing Conway's Game of Life in JavaScript. At the German Wikipedia it says that this pattern here: Will create an empty world after 54 generations and the evolution looks like this: That means, the second generation…
Vincent
  • 3,965
  • 2
  • 22
  • 30
3
votes
1 answer

Game Of Life Java - Counting neighbors with 2D arrays and for loops

I am currently working on the Conway's Game of life program in Eclipse with @Test cases. All of my methods pass their tests except for the neighborCount method. I have seen posts of this method working with for loops and for some reason it does not…
user4590197
  • 35
  • 1
  • 1
  • 7
3
votes
1 answer

conways game of life in ruby

I am making conway game of life in ruby. This is my cell_spec.rb file. I'm getting failure/error in line 10 as: expect(GameOfLife::Cell.new_dead_cell).to be_dead I have a another file cell.rb where class cell is defined. How will implement…
Manish Singh
  • 151
  • 1
  • 10
3
votes
1 answer

Game of Life: find neighbours

I'm making a Life game and I made this method to find nearby neighbours private int getNeighbours(LifeBoard board, int row, int col){ if(board.get(row+1, col)){ neighbours++; } if(board.get(row-1, col)){ neighbours++; …
Michael
  • 644
  • 5
  • 14
  • 33
3
votes
1 answer

Attribute error: Object has no attribute Python

I am trying to program a version of conway's game of life however I keep getting the message 'Cell' Object Has no attribute 'nextState' when it seems like it should declare the value of nextState before asking to reference it. here is my code: from…
Chubzorz
  • 135
  • 1
  • 2
  • 7
3
votes
3 answers

How does the hashlife alg go on forever in Golly?

In hashlife the field is typically treated as a theoretically infinite grid, with the pattern in question centered near the origin. A quadtree is used to represent the field. Given a square of 2^(2k) cells, 2k on a side, at the kth level of the…
Naximus
  • 579
  • 6
  • 18
3
votes
1 answer

C++/Linux - Drawing to a Window

I"m taking an object oriented programming class, and we just did a project where we had to implement Conway's Game of Life. The project specification was just to output lines of text to the terminal, which shows the evolution of the cells, but it's…
Dan Forbes
  • 2,734
  • 3
  • 30
  • 60
3
votes
1 answer

Game of Life in Java, Overpopulation but can't figure out why

This is homework. I included relevant code at the bottom. Problem: In an attempted to allow the user to resize the grid, the grid is now being drawn severely overpopuated. Screen Shots: "Overpopulation" -…
user2272115
  • 986
  • 1
  • 10
  • 22
3
votes
3 answers

Explain the use of yields in this Game of Life implementation

In this PyCon talk, Jack Diederich shows this "simple" implementation of Conway's Game of Life. I am not intimately familiar with either GoL or semi-advanced Python, but the code seems quite easy to grasp, if not for two things: The use of yield. I…
oligofren
  • 20,744
  • 16
  • 93
  • 180
2
votes
1 answer

Getting values from previous "row" in 2D C array

I'm working on a 1D Game of Life (based upon the rules set out here at Mathworld). Essentially, each generation is represented as a row of 0's or 1's (dead or alive) and the next generation is created based upon the binary representation of a "rule"…
Richard Martinez
  • 692
  • 1
  • 8
  • 16