Engineering Agent Societies: A Case Study in Smart Environments