def isalive((r,c), (lr,lc), grid, location, verbose= False):
	''' apply rules against the r,c based on the local grid[lr,lc]
	
	Parameters
	------------
	
		all parameters are keyword parameters
		
		(r,c) : interger tuple
			represents the location of the cell in the global matrix
			
		(lr,lc) : integer tuple
			represents the location in the local grid matrix
		
		grid : matrix
			represents the neighbours to analyse
		
		location: string
			either corner, edge, top or body
	
	'''
	
	countNumberOfAdjoiningCellsActive = []
	
	check(grid, lr, lc+1, countNumberOfAdjoiningCellsActive, verbose)
	check(grid, lr, lc-1, countNumberOfAdjoiningCellsActive, verbose )	
	
	check(grid, lr+1, lc, countNumberOfAdjoiningCellsActive, verbose )	
	check(grid, lr+1, lc+1, countNumberOfAdjoiningCellsActive, verbose )	
	check(grid, lr+1, lc-1, countNumberOfAdjoiningCellsActive, verbose )	
		
	
	check(grid, lr-1, lc, countNumberOfAdjoiningCellsActive, verbose )	
	check(grid, lr-1, lc+1, countNumberOfAdjoiningCellsActive, verbose )	
	check(grid, lr-1, lc-1, countNumberOfAdjoiningCellsActive, verbose )		
	
	if verbose:
		if len(countNumberOfAdjoiningCellsActive) != 0:
			print 'value %d, countNumberOfAdjoiningCellsActive %d' % (grid[lr,lc], len(countNumberOfAdjoiningCellsActive))

	isAlive = False
	#Any live cell with fewer than two live neighbours dies, as if caused by under-population.
	#Any live cell with more than three live neighbours dies, as if by overcrowding.
	if grid[lr,lc] == 1 and (len(countNumberOfAdjoiningCellsActive) < 2 
		or len(countNumberOfAdjoiningCellsActive) > 3) : # under or over populated then die out
		isAlive = False
	#Any live cell with two or three live neighbours lives on to the next generation.
	elif grid[lr,lc] == 1 and (len(countNumberOfAdjoiningCellsActive) == 2 or len(countNumberOfAdjoiningCellsActive) == 3): 	
		isAlive = True
	#Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
	elif grid[lr,lc] == 0 and (len(countNumberOfAdjoiningCellsActive) == 3): 
		isAlive = True
		
	return isAlive
 apply rules against the r,c based on the local grid[lr,lc]
	
	Parameters
	------------
	
		all parameters are keyword parameters
		
		(r,c) : interger tuple
			represents the location of the cell in the global matrix
			
		(lr,lc) : integer tuple
			represents the location in the local grid matrix
		
		grid : matrix
			represents the neighbours to analyse
		
		location: string
			either corner, edge, top or body
	
	
recipes/Python/578559_Conways_Game_of_Life_In_Python/recipe-578559.py