Artificial societies in a community-based approach to ambient intelligence