## 3 Methods
### Facial Expression Recognition
Moreover, BIFL supports both UCB and Thompson Sampling for exploration-exploitation trade-off. In this work, UCB was used in real-time decision-making, while Thompson Sampling was used for theoretical convergence analysis. It is important to mention that traditional Reinforcement Learning (RL) approaches, such as Q-learning, require extensive offline training over multiple episodes and a well-defined reward function. However, in real-time interactions with neurodivergent children, cognitive states, emotions, and brainwave dynamics are unpredictable and non-stationary. Offline RL training within this context is not feasible, due to time constraints and the impossibility of replicating spontaneous emotional-cognitive fluctuations. Our BIFL approach processes real-time signals over a 10 s temporal window, allowing adaptive feedback based on immediate multimodal input. Although RL-based comparisons will be explored in future simulations, BIFL was more appropriate for on-the-fly decision-making and showed good real-time performance. ### Multimodal Engagement Score Computation

To quantitatively estimate dynamic child engagement during gameplay, we developed a multimodal engagement scoring model based on three sources: (i) game score, (ii) EEG concentration, and (iii) facial emotion. Each modality is normalized to a discrete score: 1 (Low), 3 (Medium), or 5 (High), with the following mappings:

* concentration \(>\) 70% \(\rightarrow\) Score 5 (High)
- 50-70% \(\rightarrow\) Score 3 (Medium)
- \(<\)50% \(\rightarrow\) Score 1 (Low)
* positive emotion (happy/surprised) \(\rightarrow\) Score 5
- neutral expression \(\rightarrow\) Score 3
- negative emotion (anger, disgust, sadness, fear) \(\rightarrow\) Score 1
* High points \(\rightarrow\) Score 5
- Medium points \(\rightarrow\) Score 3
- Low points \(\rightarrow\) Score 1

Then, the engagement score at each window (every 10 s) is computed as

\[E(t)=w_{EEG}(t)\times score_{EEG}(t)+w_{Facial}(t)\times score_{Facial}(t)+w_{ Game}(t)\times score_{Game}(t). \tag{8}\]

Values closer to 5 indicate higher engagement. To personalize the engagement score and account for variability between children, especially when observing neuro-diverse profiles, weights are dynamically assigned based on the confidence of each modality. The weights \(w_{EEG}\), \(w_{Facial}\), and \(w_{Game}\) are recalculated every 10 s using the inverse Jensen-Shannon divergence, which quantifies the temporal consistency of each modality's signals. A more stable signal (i.e., less fluctuation over time) receives a higher weight, ensuring that the engagement score emphasizes the most reliable input at each moment. The weights are computed as follows:

\[w_{i}=\frac{1-JS(P_{i}\parallel U)}{\sum_{j=1}^{n}(1-JS(P_{j}\parallel U))}. \tag{9}\]Given the empirical distribution \(P_{i}\) of recent values for each factor and a uniform reference distribution \(U\), the JS divergence is computed as

\[J(P_{i}\parallel U)=\frac{1}{2}KL(P_{i}\parallel M)+\frac{1}{2}KL(U\parallel M), \tag{10}\]

where \(M=\frac{1}{2}(P_{i}+U)\), and where \(KL(P\parallel Q)\) is the Kullback-Leibler divergence \(KL(P\parallel Q)=\sum_{x}P(x)\log\frac{p(x)}{Q(x)}\). In this formulation, lower JS divergence (i.e., more consistent or reliable behavior) leads to a higher weight, while factors with more variability receive less influence in the engagement computation. This adaptive weighting ensures that the engagement score reflects the most trustworthy and stable signals over time. The advantages of adopting dynamic weights are as follows:

* Adaptiveness: No fixed modality importance; adapts to each child. * Explainability: Weight evolution interprets engagement focus (e.g., child relying more on cognitive or affective cues). * Robustness: Avoids biases toward modalities insensitive to neurodivergent behaviors.