# Emotion-Driven Music and IoT Devices for Collaborative Exer-Games
## 3 An IoT-Based Architecture for Exer-Games  
The main characteristics of our game model are as follows: it is multi-player, based on physical exercises, with each player individually performing exercises in a sensorized environment; players' emotions are recognized and incorporated into the game's control system; musical stimuli, based on those emotions, are generated to induce changes in the players' physical and emotional responses during exercises, and these stimuli are personalized and can be directed toward one or more players (often configured to evoke different reactions in each participant). This model serves as the conceptual foundation for programming various exer-games. Due to the complexity involved in programming these games, a robust software architecture and a set of highly reusable tools are necessary for game development. In this section, we present the architecture designed to implement exer-games based on the model described above. The proposed software architecture draws inspiration from architectural models commonly used in IoT systems. These models have evolved from solutions structured in three functional layers [36; 37] to more modern architectures consisting of six layers [37; 38]. The six-layer model has been recently adopted by major cloud service providers who offer an extensive catalog of services for programming IoT-based systems and by leading standardization initiatives in the IoT domain, such as the IoT Reference Architecture defined by ISO [39]. Figure 1 illustrates the six-layer architecture designed for the development of collaborative exer-games. Two types of actors are involved in these games: the players and the game manager. Players wear various devices (such as smart glasses, physiological monitors, or motion sensors) and must complete a series of physical tasks to reach the final goal of the game. Due to the collaborative nature of these games, the milestones achieved by one player may influence the progress of tasks for other players. The game manager oversees the overall progress of the game and can optionally introduce new challenges that modify the game's control and the tasks players must complete. The bottom layer of the architecture is composed of the Physical devices integrated into the controlled environment. In this work, particular focus is placed on virtual reality glasses, devices for monitoring players' physiological signals, and equipment used to deliver music as a stimulus capable of inducing changes in the player during the game. The Device management layer maintains a registry of the specific devices available in the environment and is responsible for ensuring the security requirements related to those devices. Devices generate various types of events related to players' actions, their physical and emotional responses during activities, the progress of the game, and more. These events must be transmitted to the functional components in the upper architectural layers, for example, to be interpreted for updating game conditions. Similarly, devices can receive response events from those components to modify game activities or adjust environmental conditions. The Messaging layer is responsible for managing this flow of events between devices and components. In this architecture, this layer serves as a transversal element, facilitating the integration of different distributed device environments. The functional core of the games is organized into three layers. The Ingestion layer filters and processes events received from devices to generate relevant knowledge for game control and player states. This knowledge is stored in data repositories, which are accessible to the other functional components in the solution. Some of these components provide general-purpose functionality, while others offer specific support for the development of exer-games; both are encapsulated as services. The Service layer integrates all these network-accessible components, which can be reused in the development of various games.