Bioinspired robots can now learn to swarm on the go