def cellsDirs(pos, size):
    """
    Returns all possible directions in a position within a 2D array of given size.
    """
    x, y = pos
    width, height = size
    dirs = []

    if x > 0: dirs.append([-1,0])
    if x < width-1: dirs.append([1,0])
    if y > 0: dirs.append([0,-1])
    if y < height-1: dirs.append([0,1])

    return dirs