Commit c62d4bb5 authored by Jéhoiakim KINGNE's avatar Jéhoiakim KINGNE
Browse files

Commit

parent cd2f7f41
...@@ -23,9 +23,9 @@ print("heigth = ", heigth) ...@@ -23,9 +23,9 @@ print("heigth = ", heigth)
pix_mont_blanc=im_alt.getpixel((1573,1593)) pix_mont_blanc=im_alt.getpixel((1573,1593))
pix_sea_level=im_alt.getpixel((929,1666)) pix_sea_level=im_alt.getpixel((929,1666))
pix_sea=im_alt.getpixel((1,1)) pix_sea=im_alt.getpixel((1,1))
print(pix_sea,pix_sea_level,pix_mont_blanc) print(pix_sea,pix_sea_level,pix_mont_blanc) #rgb
def getAltitude(rgbValues): def getAltitude(rgbValues):
if rgbValues==(255,255,255): if rgbValues==(255,255,255):
res=0 #il y aura un effet sur les bord de la carte car sur la jonction les pixels ne sont pas parfaitement blanc res=0 #il y aura un effet sur les bord de la carte car sur la jonction les pixels ne sont pas parfaitement blanc
else: else:
...@@ -33,12 +33,14 @@ def getAltitude(rgbValues): ...@@ -33,12 +33,14 @@ def getAltitude(rgbValues):
res=4810/7921*(G-186)**2 res=4810/7921*(G-186)**2
return(res) return(res)
def getAltXY(pixel): def getAltXY(pixel): #Permet d'avoir l'altitude réelle pour un pixel
rgbValues=im_alt.getpixel(pixel) rgbValues=im_alt.getpixel(pixel)
# print("rgbValues = ", rgbValues) # print("rgbValues = ", rgbValues)
return(getAltitude(rgbValues)) return(getAltitude(rgbValues))
def getPopXY(pixel):
def getPopXY(pixel):#Permet d'avoir la population réelle pour un pixel
pop_max=3000 pop_max=3000
rgbValues=im_pop.getpixel(pixel) rgbValues=im_pop.getpixel(pixel)
if max(rgbValues)>=30: #la mer n'est pas totalement noire, on filtre donc if max(rgbValues)>=30: #la mer n'est pas totalement noire, on filtre donc
...@@ -47,19 +49,22 @@ def getPopXY(pixel): ...@@ -47,19 +49,22 @@ def getPopXY(pixel):
res=0 res=0
return(res) return(res)
def popCaseXY(pixel):
return(sum([sum([getPopXY((x,y)) for x in range(pixel[0],pixel[0]+15)]) for y in range(pixel[1],pixel[1]+15)]))
def altCaseXY(pixel): def popCaseXY(case): #Permet d'avoir la population moyenne réelle d'une cellule (donc prend une cellule en entrée)
return(max([max([getAltXY((x,y)) for x in range(pixel[0],pixel[0]+15)]) for y in range(pixel[1],pixel[1]+15)])) return(sum([sum([getPopXY((x,y)) for x in range(case[0],case[0]+15)]) for y in range(case[1],case[1]+15)]))
print(popCaseXY([0,0]))
def altCaseXY(case):#Permet d'avoir l'altitude moyenne réelle d'une cellule (donc prend une cellule en entrée)
return(max([max([getAltXY((x,y)) for x in range(case[0],case[0]+15)]) for y in range(case[1],case[1]+15)]))
#### from now on, the functions deal with the graph with cells of 15*15 pixels #### #### from now on, the functions deal with the graph with cells of 15*15 pixels ####
def denivele(graphe,p1,p2): def denivele(graphe,case1,case2): #Donne le denivelé entre deux cellules du graphe
return(abs(atan((graphe[p1[0]][p1[1]]-graphe[p2[0]][p2[1]])/15))) #positif return(abs(atan((graphe[case1[0]][case1[1]]-graphe[case2[0]][case2[1]])/15))) #positif
def lambdad(graphe,p1,p2): def lambdad(graphe,case1,case2):
d=denivele(graphe,p1,p2)
res=0 res=0
if d<pi/9: if d<pi/9:
res=(pi/9-d)*9/pi res=(pi/9-d)*9/pi
...@@ -79,6 +84,9 @@ def voisins(graphe,x,y): ...@@ -79,6 +84,9 @@ def voisins(graphe,x,y):
return(flat) return(flat)
print("alt = ",altCaseXY((1560,1590)))
print("pop = ",popCaseXY((1560,1590)))
y=1591 y=1591
x=range(4830) x=range(4830)
...@@ -87,12 +95,14 @@ print(max(z)) ...@@ -87,12 +95,14 @@ print(max(z))
plt.plot(x,z) plt.plot(x,z)
plt.show() plt.show()
print("alt = ",altCaseXY((1560,1590)))
newWidth=4830//15 newWidth=4830//15
newHeigth=3510//15 newHeigth=3510//15
graphe=[[[popCaseXY((i*15,j*15)),altCaseXY((i*15,j*15)),[0 for _ in range(15)]] for i in range(newWidth)] for j in range(newHeigth)] graphe=[[[popCaseXY((i*15,j*15)),altCaseXY((i*15,j*15)),[0 for _ in range(15)]] for i in range(newWidth)] for j in range(newHeigth)]
#### initialization of the graph #### #### initialization of the graph ####
pixelOutOfRize=[[4422,2108],[4422,2109],[4422,2110],[4422,2111],[4423,2109],[4423,2110],[4423,2111],[4424,2110],[4425,2111]] pixelOutOfRize=[[4422,2108],[4422,2109],[4422,2110],[4422,2111],[4423,2109],[4423,2110],[4423,2111],[4424,2110],[4425,2111]]
pixelOutOfRize.append([[i,2111] for i in range(4429,4436)]) pixelOutOfRize.append([[i,2111] for i in range(4429,4436)])
...@@ -104,16 +114,21 @@ pixelOutOfRize.append([[4435,j] for j in range(2104,2110)]) ...@@ -104,16 +114,21 @@ pixelOutOfRize.append([[4435,j] for j in range(2104,2110)])
for i in range(4422,4436): #pixels de rize for i in range(4422,4436): #pixels de rize
for j in range(2103,2218): for j in range(2103,2218):
if [i,j] not in pixelOutOfRize: if [i,j] not in pixelOutOfRize:
graphe[i//15][j//15][1]+=(-getPopXY(i,j)) graphe[j//15][i//15][0]+=(-getPopXY((i,j)))
graphe[i//15][j//15][2][0]+=getPopXY(i,j) graphe[j//15][i//15][0]+=getPopXY((i,j))
print(len(graphe), 'taille graphe')
def getZombiesOlder(listZombies): def getZombiesOlder(listZombies):
for i in range(15): for i in range(15):
listZombies[14-i]=listZombies[13-i] listZombies[14-i]=listZombies[13-i]
listZombies[0]=0 listZombies[0]=0
def getGraphOlder(graphe):
"""def getGraphOlder(graphe):
for i in range(newWidth): for i in range(newWidth):
for j in range(newHeigth): for j in range(newHeigth):"""
def stepOne(graphe): #def stepOne(graphe):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment