29 lines
No EOL
527 B
Python
29 lines
No EOL
527 B
Python
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
|
|
|
|
|