Dynamic task allocation and coordination in cooperative multi-agent environments