Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sentir_zombie(self,carte):
- """
- Rend les coordonnées du zombie le plus proche
- """
- i_humain,j_humain = np.where(carte == self) # Donne l'emplacement de l'humain
- i_humain,j_humain = int(i_humain),int(j_humain)
- self.place_matrice = i_humain,j_humain
- liste_zombie = where_classe(Zombie,carte)
- dmin = 10000000 # Distance supposée du zombie le plus proche
- i_zombie = None
- j_zombie = None
- self.Zombie_le_plus_proche = (i_zombie, j_zombie)
- self.liste_zombie = []
- for e in range(len(liste_zombie)):
- i_zombieTempo, j_zombieTempo = liste_zombie[e]
- if i_zombieTempo in range((i_humain-Odorat_H),(i_humain+Odorat_H+1))\
- and j_zombieTempo in range((j_humain-Odorat_H),(j_humain+Odorat_H+1)): # L'humain est dans un voisinage +/- 10 du zombie
- self.liste_zombie +=[(i_zombieTempo,j_zombieTempo)]
- dz=math.sqrt((i_zombieTempo - i_humain)**2+(j_zombieTempo - j_humain)**2)
- if (dz<dmin): # Compare la distance H-Z la plus petite trouvée
- i_zombie = i_zombieTempo # Garde en mémoire les coordonnées du zombie le plus proche
- j_zombie = j_zombieTempo
- dmin=dz
- self.Zombie_le_plus_proche = (i_zombieTempo,j_zombieTempo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement