tpsai-py currently selects the nearest object which is XXX distance away. It probably makes sense to also congregate at a planet which may be closer.
The choice should be something like
nearest = choice.popclosest()
while len(choice) > 0:
if nearest is planet:
if distance to target from nearest > XXXX:
nearest = choice.popnextclosest()