Closed-loop task allocation in robot swarms using inter-robot encounters