pyot/radio.py

29 lines
527 B
Python
Raw Permalink Normal View History

2024-02-07 01:40:09 +01:00
import math
RADIO_IDLE = 0
RADIO_RX = 1
RADIO_TX = 2
RADIO_BUSY = 3
def distance(r1, r2):
a = abs(r1.x - r2.x)
b = abs(r1.y - r2.y)
return int(math.sqrt(a*a + b*b))
def neighbors(me, world, radius):
ney = []
for target in world:
if distance(me, target) <= radius:
ney.append(target)
return ney
class radio:
def __init__(self,x,y):
self.state = RADIO_IDLE
self.tick = 0
self.x = x
self.y = y
def tickle(self):
self.tick+=1