Self-organization of reflexive behavior from spontaneous motor activity