Collaborating in Motion: Distributed and Stochastic Algorithms for Emergent Behavior in Programmable Matter