Spaceship turret with it's own AI

Any idea how to make this work?