[python] distance func
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- def find_opponent_unit_distance(unit):
- attack_range = unit.data.get('attack_range')
- for opponent in unit.battalion.target.units:
- position_delta = (unit.position[0] - opponent.position[0], unit.position[1] - opponent.position[1])
- distance = numpy.linalg.norm(position_delta)
- if distance < 92:
- if opponent.opponents is None:
- return opponent
- else:
- return None
Editor
You can edit this paste and save as new:
File Description
- distance func
- Paste Code
- 23 May-2022
- 441 Bytes
You can Share it:
Latest Code Pastes