def nb_consecutives(x, y, dx, dy, position, color):
  """Maximum number of consecutive stones of color `color` in the board position
  `position`,starting from (x,y) and using slope (dx, dy).

  Parameters
  ----------
  x: int
    x-coordinate of the start position
  y: int
    x-coordinate of the start position
  dx: int
    x-coordinate slope
  dy: int
    y-coordinate slope
  position: numpy.ndarray
    position of the board
  color:
    what color we want the consecutive stones to be

  Return
  ------
  max_consec: int
    Max. number of consecutive stones of color starting at x,y, with slope dx/dy
  """
  m = len(position)
  # don't start counting if you're not the first stone of a series
  if ((0 <= x - dx < m) and (0 <= y - dy < m)
      and position[x - dx][y - dy] == color):
    return 0
  # check what is the biggest nb_coordinates that you can fit in direction dx/dy
  nb_consec = 0
  while (0 <= x < m) and (0 <= y < m and position[x][y] == color):
    nb_consec += 1
    x += dx
    y += dy
  return nb_consec