Programmable self-assembly in a thousand-robot swarm