# -*- coding: utf-8 -*-
"""
TP13.2 : Graphes, parcours

PCSI2 - Albert Schweitzer - Le Raincy
"""


import numpy as np
import matplotlib.pyplot as plt

##Un exemple

M = [[1, 0, 1, 1, 1, 1, 1],
    [1, 1, 1, 1, 1, 0, 1],
    [1, 1, 1, 1, 1, 0, 1],
    [1, 1, 1, 1, 0, 1, 1],
    [1, 1, 0, 1, 1, 1, 1],
    [1, 1, 1, 1, 1, 1, 1],
    [1, 1, 1, 0, 1, 1, 1],
    [1, 1, 1, 0, 1, 1, 1]
    ]

##Q2





##Un exemple avec des obstacles

M = [[1, 0, 1, 1, 1, 1, 1],
    [1, 10, 2, 1, 1, 0, 1],
    [1, 10, 1, 1, 1, 0, 1],
    [1, 10, 1, 1, 0, 1, 1],
    [1, 10, 0, 1, 15, 1, 1],
    [1, 1, 1, 1, 12, 1, 1],
    [1, 1, 1, 0, 1, 1, 1],
    [1, 1, 1, 0, 1, 1, 1]
    ]
def visualise_terrain_bis(M):
	h, l = len(M), len(M[0])
	m = max([max(L) for L in M])
	I = np.zeros((h, l, 3), dtype = 'uint8')
	for x in range(h):
		for y in range(l):
			if M[x][y] == 1:
				I[x,y,0] = 255
				I[x,y,1] = 255
				I[x,y,2] = 255
			elif M[x][y] > 1:
				I[x,y,1] = 255
				I[x,y,2] = 255
				I[x, y, 0] = 255 - int(255 * M[x][y]/m)
	plt.imshow(np.array(I), interpolation = 'none')
	plt.show()

def visualise_chemin_bis(M, C):
	h, l = len(M), len(M[0])
	m = max([max(L) for L in M])
	I = np.zeros((h, l, 3), dtype = 'uint8')
	for x in range(h):
		for y in range(l):
			if M[x][y] == 1:
				I[x,y,0] = 255
				I[x,y,1] = 255
				I[x,y,2] = 255
			elif M[x][y] > 1:
				I[x,y,1] = 255
				I[x,y,2] = 255
				I[x, y, 0] = 255 - int(255 * M[x][y]/m)
	for (x, y) in C:
		I[x, y, 0] = 125
		I[x, y, 1] = 125
		I[x, y, 2] = 125
	plt.imshow(np.array(I), interpolation = 'none')
	plt.show()

##Q12