conways-game-of-life

Conway's Game of Life with Python

断了今生、忘了曾经 提交于 2019-12-03 03:41:18
I took a liking to Conway's Game of Life and began to try and write it in python. At this moment I have yet to write any code for the borders of the program so I am just asking for help with what I have right now. I seem to have trouble when initialization a "blinker" formation. Instead of oscillating like it should, it seems to turn itself into a cube. #File: gameoflife.py #Description: This is a basic "life" simulation that follows three distinct rules: #1.Any live cell with fewer than two live neighbours dies #2.Any live cell with two or three live neighbours lives #3.Any live cell with

another Game of Life question (infinite grid)?

放肆的年华 提交于 2019-12-03 01:55:50
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 coders implement the infinite grid? We can't keep an infinite array of anything, if you run golly and get a few gliders to fly off past the edges, wait for a few mins and zoom right out, you will see the gliders still there out in space running away, so how in gods name is this concept of infinity dealt with programmatically? Is there a well

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

三世轮回 提交于 2019-12-02 19:29:25
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 naive solution that represents each cell as a single bit in a matrix (96*128/8=1,536 bytes) works but is too slow. What tricks can be used to improve performance? Storing the coordinates of live cells (for example in this implementation http://dotat.at/prog/life/life.html ) would use too much memory. Looks like a fun piece of hardware. Storing 1 bit

(Game of Life) How to loop through outer layer of a matrix without checking outside of it, simultaneously checking for neighbors?

陌路散爱 提交于 2019-12-02 17:09:34
问题 Each point in the matrix represents a cell, living or dead. I have to count how many ALIVE neighbors each cell has. I have a function that does the job, but it checks for cells outside its boundary.I don't know how I can simultaneously check for neighbors and keep track of edges without doing a massive amount of if-else statements. void Neighbours(int rows, int cols, cell world[rows][cols], int neighbors[rows][cols]) { //Loop through each cell in the matrix. for(int rCell = 0; rCell < rows;

(Game of Life) How to loop through outer layer of a matrix without checking outside of it, simultaneously checking for neighbors?

寵の児 提交于 2019-12-02 13:01:31
Each point in the matrix represents a cell, living or dead. I have to count how many ALIVE neighbors each cell has. I have a function that does the job, but it checks for cells outside its boundary.I don't know how I can simultaneously check for neighbors and keep track of edges without doing a massive amount of if-else statements. void Neighbours(int rows, int cols, cell world[rows][cols], int neighbors[rows][cols]) { //Loop through each cell in the matrix. for(int rCell = 0; rCell < rows; rCell++){ for(int cCell = 0; cCell < cols; cCell++) { //Reset neighbor count for each cell. neighbors

Bash - populate 2D array from file

痞子三分冷 提交于 2019-12-02 12:59:44
问题 I know it's probably something easy but i'm struggling really hard with this. Problem description: I have a text file with coordinates in format: 1 2 3 7 ... where first column == 'x' and second column == 'y' coordinate. Now i want to populate a 2D array of size N x M using this coordinates from file by printing 'X' for points that are specified in file and '.' otherwise. Example: array[1][2] = 'X', array[3][7] = 'X', array[0][1] = '.' So far I have tried: separating x,y columns and storing

Wrapping in Conway's Game of Life C++

孤者浪人 提交于 2019-12-02 08:25:56
I am trying to write a program that implements Conway's game of life on a 20x60 cell board. The grid will wrap around so the left side will be connected to (neighbouring) the right side and the top will be connected to the bottom. Thus any cell with position (1, col) , will have a neighbour at (maxRow, col) . Any cell with position (row, 1) will have a neighbour at (row, maxCol) . The following function is supposed to count the number of neighbouring cells. It works for coordinates not on the edges, but not for ones that are. For instance, if there are points at (1, 10) , (1, 11) , and (1, 12)

Conway's Game of Life Update(Next Generation)

岁酱吖の 提交于 2019-12-02 06:48:28
问题 I am working on Conway's game of life java code and I am having a struggle with my update method also known as the next generation creator. I will post my code I have written so far and please let me know what I can do to fix the update method. A cell is born if there was none at time T 1 and exactly three of its neighbors were alive. An existing cell remains alive if at time T 1 there were either two or three neighbors A cell dies from isolation if at time T 1 there were fewer than two

Conway's Game of Life Update(Next Generation)

我与影子孤独终老i 提交于 2019-12-02 06:30:15
I am working on Conway's game of life java code and I am having a struggle with my update method also known as the next generation creator. I will post my code I have written so far and please let me know what I can do to fix the update method. A cell is born if there was none at time T 1 and exactly three of its neighbors were alive. An existing cell remains alive if at time T 1 there were either two or three neighbors A cell dies from isolation if at time T 1 there were fewer than two neighbors. A cell dies from overcrowding if at time T 1 there were more than three neighbors. public class

Bash - populate 2D array from file

喜你入骨 提交于 2019-12-02 04:01:49
I know it's probably something easy but i'm struggling really hard with this. Problem description: I have a text file with coordinates in format: 1 2 3 7 ... where first column == 'x' and second column == 'y' coordinate. Now i want to populate a 2D array of size N x M using this coordinates from file by printing 'X' for points that are specified in file and '.' otherwise. Example: array[1][2] = 'X', array[3][7] = 'X', array[0][1] = '.' So far I have tried: separating x,y columns and storing them in arrays like this: xcoords="xcoords.txt" ycoords="ycoords.txt" head $geneFile | grep " " | awk -F