Imitating fireflies and the way they maximize lighting