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

Tweaking MIT's bitcount algorithm to count words in parallel?

I want to use a version of the well known MIT bitcount algorithm to count neighbors in Conway's game of life using SSE2 instructions. Here's the MIT bitcount in c, extended to count bitcounts > 63 bits. int bitCount(unsigned long long n) { unsigned…
Johan
  • 74,508
  • 24
  • 191
  • 319
3
votes
2 answers

Game of life in html and javascript not working

so i tried to write the Game of Life in html canvas and JavaScript and with the help of many online tutorials i managed to write some code i still believe in. But when I launch the html page in the browser and start the game itself (that is, i was…
zubr
  • 33
  • 3
3
votes
4 answers

Game of Life Assignment

My board correctly detects groups with less than 3 neighbors and kills them off, but doesn't seem to detect and give birth to cells with 3 neighbors. Any thoughts? If I haven't provided enough information let me know, and I can paste more of the…
Justin
  • 111
  • 1
  • 1
  • 12
3
votes
1 answer

How does the _mm256_shuffle_epi8 make sense in this Game of Life implementation?

Making my homework for implementing Conway's Game of Life using intrinsic functions found the working code, but cannot understand the main part of it. This implementation first calculates amount of alive neighbors for each sell and store the result…
lolmosk
  • 55
  • 7
3
votes
0 answers

Conways Game of Life p5js

am trying to create conways game of life using p5js. (p5js website) here is a link to a gif of the simulation: Google Drive Link I have two 2d arrays, one to hold the current grid and one to hold the updated grid. the arrays hold a value of 0 =…
3
votes
2 answers

Conway's game of life neighbor count

def neighbors(matrix, r, c): live_neighbors = 0 if matrix[r][c-1] != 0: live_neighbors += 1 if matrix[r-1][c] != 0: live_neighbors += 1 if matrix[r-1][c+1] != 0: live_neighbors += 1 if matrix[r][c-1] !=…
3
votes
4 answers

Best way to render a bitmap/bitarray to 2d plane (with OpenGL)

Ok, this is what I have. I have a 1d bitmap (or bitarray, bitset, bitstring, but I'll call it a bitmap for now) containing the live or dead states from a conway game of life generation. The cell at (x, y) is represented by the bit at y * map_width +…
orlp
  • 112,504
  • 36
  • 218
  • 315
3
votes
1 answer

To use closures or not, John Conways Game of Life

I am currently making a game that illustrates John Conways 'Game of Life' I've been learning about closures and the modular patterns and am trying to implement more of what I'm learning in Javascript. You can check out my repo here if your…
3
votes
1 answer

How can I animate a set of points with matplotlib?

I have an implemented Conway's Game of Life as: def neighbors(point): x, y = point for i, j in itertools.product(range(-1, 2), repeat=2): if any((i, j)): yield (x + i, y + j) def advance(board): newstate = set() …
Yulian
  • 365
  • 4
  • 12
3
votes
2 answers

Why can't I make a copy of this 2d array in JS? How can I make a copy?

I'm implementing a John Conway Game of Life, but I'm having a weird problem. Here is a short version if the code giving me trouble: let lifeMap = [ [true, false, false], [false, false, false], [false, false, false] ]; let oldLifeMap =…
3
votes
4 answers

Can I speed up this function?

I'm trying to write John Conway's Game of Life in C, but I'm having trouble adding living cells to the board. The function I wrote to handle it is extremely slow. Thought process: I want to add n living cells to the board randomly, so while cells…
MaxG
  • 65
  • 3
3
votes
2 answers

Please help with my basic java implementation of Conway's game of life

I have spent quite a while trying to write a program to implement Conway's game of life - Link with more info. . I am following some online guides and was given the majority of the functions. I wrote the "next" and "neighbours" methods shown below.…
user476033
  • 4,607
  • 8
  • 32
  • 35
3
votes
1 answer

Conways Game of Life in PyGame

So I read about Conways Game of Life and tried to implement it with PyGame. I tried to make it object-oriented. The way it works is that I have a list of cell-instances, which then check how many neighbours they have and then either stay alive or…
sorh
  • 125
  • 1
  • 11
3
votes
1 answer

Stuck programming Conway's "Game of Life" in JS

We have to program a JavaScript version of Conway's Game of Life for a school project, but we're stuck on looping the edges. The whole thing works fine, but the function that calculates the number of neighbors doesn't work on the cells that are on…
Dat8StringGuy
  • 301
  • 1
  • 2
  • 10
3
votes
2 answers

I have started writing the Game of Life in Java and the count of surrounding cells is not correct

I am a beginner at Java programming (1st semester) and I have been writing code for the Game of Life. I am counting the surrounding cells of each cell in a two-dimensional array. I have reached the point where the program compiles well, but when I…
RedDree
  • 369
  • 7
  • 18
1 2
3
39 40