# démineur : 20x30 cases avec 10 mines
# pas de clic droit, que clic gauche
# _ case non cliquée, m pour mine

def init():
	plateau = [['_' for i in range(20)] for j in range(30)]
	l = 0
	c = 0
	for i in range(10):
		plateau[l][c] = 'm'
		l +=1
		c +=1
	return plateau

def print_plateau(plateau):
	for i in plateau :
		for j in i:
			if j in ('m','_') :
				print('_', end='')
			else :
				print(j, end='')
		print()

def bornes(line, col, plateau) :
	xmin, xmax, ymax, ymin = 0, 0, 0, 0
	if line > 0 :
		xmin = line - 1
	if line < 29 :
		xmax = line +1
	else : 
		xmax = line
	if col > 0 :
		ymin = col - 1
	if col < 19 :
		ymax = col +1
	else : 
		ymax = col
	return xmin, xmax, ymin,ymax

def nbVoisins(line, col, plateau) :
	xmin, xmax, ymin,ymax = bornes(line, col, plateau)
	n = 0
	for i  in range(xmin, xmax+1):
		for j in range(ymin, ymax+1) :
			if plateau[i][j] == 'm':
				n += 1
	return n

def devoiler(line, col, plateau) :
	if plateau[line][col] == '_' :
		plateau[line][col] = nbVoisins(line, col, plateau)
		xmin, xmax, ymin,ymax = bornes(line, col, plateau)
		print(xmin, xmax, ymin,ymax)
		for i  in range(xmin, xmax+1):
			for j in range(ymin, ymax+1) :
				if plateau[i][j] == '_':
					devoiler(i, j, plateau)

def play(line, col, plateau) :
	if plateau[line][col] == 'm' :
		print("La case",line,"-",col,"est minée...")
		return False
	else :
		devoiler(line, col, plateau)
		return True

if __name__ == '__main__':
	plateau = init()
	print(plateau)
	print_plateau(plateau)
	mine = False
	while not mine :
		line = int(input("Line?"))
		col = int(input("Colonne?"))
		play(line,col,plateau)
		print_plateau(plateau)

