def makeNeighborLists(position, nRow, nCol):
    """
    Build a neighbor list for each cell
    This will create a list of all positions in a cell's Moore neighborhood. 
    Pos is the cell's position, nRow is the maximum width, nCol is the maximum height
    """
    
    r, c = position 

    neighborList = [(r+a, c+b) 
         for a in [-1, 0, 1]
         for b in [-1, 0, 1]
         if 0 <= r + a <= nRow
         if 0 <= c + b <= nCol
         if not (a == 0 and b == 0)]
    return neighborList