Advertisement
Bouix92i

Untitled

Mar 29th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.51 KB | None | 0 0
  1.     def sentir_zombie(self,carte):
  2.         """
  3.       Rend les coordonnées du zombie le plus proche
  4.       """
  5.         i_humain,j_humain = np.where(carte == self)      # Donne l'emplacement de l'humain
  6.         i_humain,j_humain = int(i_humain),int(j_humain)
  7.         self.place_matrice = i_humain,j_humain
  8.         liste_zombie = where_classe(Zombie,carte)
  9.         dmin = 10000000                                  # Distance supposée du zombie le plus proche
  10.         i_zombie = None
  11.         j_zombie = None
  12.         self.Zombie_le_plus_proche = (i_zombie, j_zombie)
  13.         self.liste_zombie = []
  14.         for e in range(len(liste_zombie)):
  15.             i_zombieTempo, j_zombieTempo = liste_zombie[e]
  16.             if i_zombieTempo in range((i_humain-Odorat_H),(i_humain+Odorat_H+1))\
  17.             and j_zombieTempo in range((j_humain-Odorat_H),(j_humain+Odorat_H+1)):         # L'humain est dans un voisinage +/- 10 du zombie
  18.                  self.liste_zombie +=[(i_zombieTempo,j_zombieTempo)]
  19.                  dz=math.sqrt((i_zombieTempo - i_humain)**2+(j_zombieTempo - j_humain)**2)
  20.                  if (dz<dmin):                        # Compare la distance H-Z la plus petite trouvée
  21.                     i_zombie = i_zombieTempo                                          # Garde en mémoire les coordonnées du zombie le plus proche
  22.                     j_zombie = j_zombieTempo                                          
  23.                     dmin=dz
  24.                     self.Zombie_le_plus_proche = (i_zombieTempo,j_zombieTempo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement