Gillespie Algorithms for Stochastic Multiagent Dynamics in Populations and Networks