Page 1  of 1 
					
				Combinator Game of Life 
				Posted: Fri Jul 24, 2015 10:55 am 
				by DaveMcW 
				
I built a factory that plays 
Conway's Game of Life .
The game has three simple rules that govern cell life cycle.
if neighbors = 3, then cell is born 
if neighbors = 2, then cell does not change 
if neighbors = anything else, then cell dies  
That is easy to simulate, but I want to make it even easier.  So I subtract 1 from both sides.
if (neighbors - 1) = 2, then cell is born 
if (neighbors - 1) = 1, then cell does not change 
otherwise, cell dies 
The rewritten rules are simple enough to program in two decider combinators.
With the rules in place, I can build a complete cell.
I use 4 arithmetic combinators, to prevent neighbor cell wires from touching.  Only one of them is actually used to subtract 1. They are spaced far apart to be able to reach all 8 neighbor electric poles.
Since I use wires of both colors to connect to neighbors, I need to alternate the primary color of each cell.  The final blueprint is a checkerboard pattern.
It runs at 2 ticks per frame, or 30 Hz.
 
Setting the initial pattern using combinators would be a nightmare, so I use the console.  You need to run the setup program twice.  The first run sets the pattern, the second run starts the simulation.
Setup Program Code: Select all 
/c local start = {x = -347.5, y = -110.5};
local grid = {};
grid[1] = "....................................";
grid[2] = "....................................";
grid[3] = "....................................";
grid[4] = "....................................";
grid[5] = "....................................";
grid[6] = "....................................";
grid[7] = "....................................";
grid[8] = "....................................";
grid[9] = "....................................";
grid[10]= "....................................";
grid[11]= "....................................";
grid[12]= "........................O...........";
grid[13]= "......................O.O...........";
grid[14]= "............OO......OO............OO";
grid[15]= "...........O...O....OO............OO";
grid[16]= "OO........O.....O...OO..............";
grid[17]= "OO........O...O.OO....O.O...........";
grid[18]= "..........O.....O.......O...........";
grid[19]= "...........O...O....................";
grid[20]= "............OO......................";
grid[21]= "....................................";
grid[22]= "....................................";
grid[23]= "....................................";
grid[24]= "....................................";
grid[25]= "....................................";
grid[26]= "....................................";
grid[27]= "....................................";
grid[28]= "....................................";
grid[29]= "....................................";
grid[30]= "....................................";
grid[31]= "....................................";
grid[32]= "....................................";
grid[33]= "....................................";
grid[34]= "....................................";
grid[35]= "....................................";
grid[36]= "....................................";
stopped = not stopped;
for y, values in ipairs(grid) do;
	for x=1, values:len() do;
		local combinators = game.player.surface.find_entities_filtered{area = {{start.x + x*7 - 2, start.y + y*7 - 5}, {start.x + x*7, start.y + y*7 - 3}}, name="decider-combinator"};
		if (combinators[1]) then;
			local rule3 = combinators[1].get_circuit_condition(1);
			if (not stopped) then;
				rule3.parameters.comparator = "=";
				rule3.parameters.constant = 2;
			elseif (values:sub(x,x) == "O") then;
				rule3.parameters.comparator = "<";
				rule3.parameters.constant = 99;
			else; 
				rule3.parameters.comparator = "=";
				rule3.parameters.constant = 99;
			end;
			combinators[1].set_circuit_condition(1, rule3);
		end;
		combinators = game.player.surface.find_entities_filtered{area = {{start.x + x*7 - 5, start.y + y*7 - 2}, {start.x + x*7 - 3, start.y + y*7}}, name="decider-combinator"};
		if (combinators[1]) then;
			local rule2 = combinators[1].get_circuit_condition(1);
			if (stopped) then;
				rule2.parameters.second_signal = nil;
				rule2.parameters.constant = 99;
			else;
				rule2.parameters.second_signal = {type="virtual", name="signal-B"};
				rule2.parameters.constant = nil;
			end;
			combinators[1].set_circuit_condition(1, rule2);
		end;
	end;
end;
Here is the save file with the final factory.
 
			
				Re: Combinator Game of Life 
				Posted: Fri Jul 24, 2015 12:36 pm 
				by Choumiko 
				Just freaking wow!  
 
			
				Re: Combinator Game of Life 
				Posted: Fri Jul 24, 2015 2:11 pm 
				by Lupoviridae 
				Beautiful and well done! I was planning on building a GoL in my world but you beat me to it  
 
			
				Re: Combinator Game of Life 
				Posted: Fri Jul 24, 2015 2:51 pm 
				by DRE 
				THIS has began. 
			 
			
				Re: Combinator Game of Life 
				Posted: Sun Jul 26, 2015 10:28 pm 
				by Stickman 
				So where's the gifv or the video?
			 
			
				Re: Combinator Game of Life 
				Posted: Sun Jul 26, 2015 11:45 pm 
				by Gandalf 
				Dude I wanna hug you so hard right now!
So when are you gonna implement 
hashlife ? x)
 
			
				Re: Combinator Game of Life 
				Posted: Wed Jul 29, 2015 7:16 pm 
				by Lee_newsum 
				well that is v good, i playing with in une..... 
 i had so thorts can you pull the config from Smart chest, 1 Smart chest for each cell. and you can have a reseat chest, would that work?
as for an input system you can use "z" to put an item down if you put were an Inserter can get it and put it in a chest, you have a in put system  
 
			
				Re: Combinator Game of Life 
				Posted: Wed Jul 29, 2015 7:36 pm 
				by Zhab 
				Very impressive.
			 
			
				Re: Combinator Game of Life 
				Posted: Mon Aug 03, 2015 4:50 am 
				by Adil 
				You sir are amazing.
			 
			
				Re: Combinator Game of Life 
				Posted: Tue Aug 04, 2015 1:24 pm 
				by aka13 
				Impressive, very nice!