Reinforcement learning-driven adaptive game therapy for cognitive impairment patients with improved vision transformer based detection model Authors: Youseef Alotaibi, Surendran Rajendran Published: 2026 ABSTRACT BackgroundCognitive impairment is the growing challenge that requires early diagnosis and personalized management of neurodegenerative conditions like Alzheimer’s disease. Neuroimaging modalities like Magnetic Resonance Imaging (MRI) provide valuable structural and functional insights into brain changes associated with cognitive decline. However, existing deep learning (DL) based diagnostic models have the challenges in non-consideration of long-range spatial dependencies and contextual information across brain slices that lead to suboptimal classification accuracy.MethodsTo overcome the limitations, this research introduces the framework that combines an Improved Vision Transformer (Im-ViT) with the Residual Simple Recurrent Unit (ResNet-SRU) based Multilayer Perceptron (MLP) to capture spatial and temporal dependencies in neuroimaging data. Preprocessing using Multiscale Gaussian Filter (MGF) enhances feature clarity by removing multiscale noise. In addition, the system integrates the Visual Working Memory (VWM)-based game therapy, where difficulty levels dynamically adapt using the proposed Iterative Hiking-based Reinforcement Learning (ItHRL) approach.ResultsThe analysis of the proposed model based on various assessment measures like Accuracy, Recall, Precision, F-Score, Specificity, and Mean Squared Error (MSE) acquired the values of 99.62%, 99.33%, 98.97%, 99.56%, 99.62% and 0.018 respectively.ConclusionsThe proposed model with combined detection and game therapy approach yield higher classification accuracy, faster convergence and patient engagement. Introduction Cognitive impairment is the condition where an individual experiences difficulties with mental abilities like memory, attention, language, problem-solving and decision-making [1]. These deficits lead to mild cognitive impairment (MCI) that affect daily functioning, and the severe condition leads to dementia or Alzheimer’s disease [2]. It drastically impacts the independence and quality of life of the affected patient. Cognitive impairment is not a specific disease; rather it is a neurological change associated with aging, brain injury, neurodegenerative diseases, or psychiatric conditions [3]. Early detection of cognitive impairment is critical because it enables timely intervention that slows the progression of neurodegenerative disorders and improves the management of reversible causes like vitamin deficiencies or depression [4]. Traditionally, cognitive impairment has been assessed through standardized neuropsychological tests, clinical interviews, and questionnaires like Mini-Mental State Examination (MMSE), Montreal Cognitive Assessment (MoCA) and Clock Drawing Test [5, 6]. Still, the assessment methods require trained personnel and are time-consuming that makes them less practical for large-scale screenings or rural settings [7, 8]. Deep learning (DL) methods of cognitive impairment detection overcome the limitations of traditional cognitive impairment detection techniques [9, 10]. Unlike manual assessments that are time-consuming and subjective, DL models automatically learn complex patterns from large volumes of multimodal data like neuroimaging scans like Magnetic Resonance Imaging (MRI), Positron Emission Tomography (PET), voice recordings, electronic health records, and behavioral data [11, 12]. Convolutional Neural Networks (CNNs), Recurrent Neural Networks (RNNs), Transformers, and hybrid architectures provides the enhanced outcome using the feature extraction, spatial–temporal modeling, and classification [13, 14]. The DL models are less affected by demographic biases like age, education, or language that are trained on large datasets [15, 16]. Besides, DL frameworks provide continuous, real-time assessments through mobile or wearable devices that enable remote screening and early intervention [17, 18]. Using the automated complex diagnostic tasks and enabling large-scale deployment, DL significantly enhances the accessibility, objectivity and accuracy of cognitive impairment detection [19]. Game therapy is the serious game and cognitive training games are considered as the valuable therapeutic tool for individuals with cognitive impairment. Game therapy makes the patients engage in mentally stimulating tasks that promote neuroplasticity [20, 21]. It stimulates the brain's ability to reorganize and form new neural connections. The traditional therapy is monotonous and passive. The game-based interventions require being interactive, adaptive and are enjoyable to increase patient motivation and adherence [22, 23]. The games must be targeting specific cognitive functions based on attention, memory, reasoning, and executive function and hence provide personalized and goal-oriented training [24, 25]. Furthermore, games integrated with adaptive difficulty adjustment mechanisms and neurofeedback are challenges to the user’s cognitive capacity in real-time that ensure neither under-stimulation nor frustration [26, 27]. Elderly individuals or patients with early dementia can use the game therapy to slow cognitive decline, improve mood, reduce anxiety and enhance social interaction. The game therapy with theDL continuously monitors cognitive performance by providing valuable insights into the progression or improvement of the condition [28, 29]. Thus, game therapy serves as a non-invasive approach and is utilized in real-world data for ongoing cognitive assessment and makes it a vital component in modern neurocognitive rehabilitation strategies [30]. Therefore, this research introduces the DL based cognitive impairment detection and game therapy approach for enhancing the detection accuracy and diagnoses patients. The major contributions of the research are:Design of improved vision transformer (Im-ViT) for cognitive impairment detection: The cognitive impairment detection is employed using the proposed Im-ViT model. The proposed Im-ViT captures spatial dependencies, wherein the Residual Simple Recurrent Unit (ResNet-SRU) based Multilayer Perceptron (MLP) models temporal and contextual relations across slices.Design of iterative hiking based reinforcement learning (ItHRL) based game therapy: The Visual Working Memory (VWM) based game therapy with ItHRL based next level difficulty adjustment is proposed. Design of improved vision transformer (Im-ViT) for cognitive impairment detection: The cognitive impairment detection is employed using the proposed Im-ViT model. The proposed Im-ViT captures spatial dependencies, wherein the Residual Simple Recurrent Unit (ResNet-SRU) based Multilayer Perceptron (MLP) models temporal and contextual relations across slices. Design of improved vision transformer (Im-ViT) for cognitive impairment detection: The cognitive impairment detection is employed using the proposed Im-ViT model. The proposed Im-ViT captures spatial dependencies, wherein the Residual Simple Recurrent Unit (ResNet-SRU) based Multilayer Perceptron (MLP) models temporal and contextual relations across slices. Design of iterative hiking based reinforcement learning (ItHRL) based game therapy: The Visual Working Memory (VWM) based game therapy with ItHRL based next level difficulty adjustment is proposed. Design of iterative hiking based reinforcement learning (ItHRL) based game therapy: The Visual Working Memory (VWM) based game therapy with ItHRL based next level difficulty adjustment is proposed. The research is organized as follows: "Related works" section details the related works with the problem statement. "Proposed methodology" section explains the detailed proposed methodology. The results are presented in "Result and discussion" section and the conclusion in "Conclusion" section. Related works Patil & Kukreja [31] designed an advanced technique for early detection of cognitive skill impairment using a hybrid Deep Reinforced Cognitive Analytics Model (DRCAM). The methodology combined a Convolutional Neural Network (CNN) for spatial feature extraction with a Reinforcement Learning (RL) agent that dynamically optimized decision policies based on evolving cognitive scores [32]. The model was trained in neuropsychological test data and sensor-based inputs to mimic real-time decision-making during cognitive evaluations. The designed DRCAM achieved high accuracy in early impairment detection and demonstrated adaptability to temporal changes in cognitive behavior. However, the challenge involved balancing the complexity of RL with real-time clinical deployment due to computational overhead. Rykov et al. [33] aimed to predict cognitive scores in mild cognitive impairment patients using wearable-derived digital physiological features and machine learning (ML). The designed model conducted clinical trial by collecting continuous physiological signals and fed them into Random Forest (RF), Support Vector Machine (SVM), and Gradient Boosting models. The designed approach successfully predicted cognitive decline markers and correlated them with clinical cognitive scores and demonstrated non-invasive early detection potential. However, challenges included individual variability in physiological signals and limited interpretability of the black-box ML models. Ching et al. [34] aimed to improve Alzheimer’s disease classification using transfer learning with the EfficientNet-B0 CNN model. MRI images were preprocessed and fed into the pre-trained EfficientNet-B0 and then fine-tuned for Alzheimer’s disease classification. The model was trained to distinguish between various classes of disease. The study achieved competitive accuracy and reduced training time and demonstrated the effectiveness of transfer learning in medical imaging. The challenge was the risk of domain mismatch, because the pre-trained network was originally developed for natural images and possibly limiting feature generalization. Jayaprakash and Kanimozhiselvi [35] aimed at the early detection of autism spectrum disorders (ASD) using Multinomial Logistic Regression (MLR) model. Behavioral and diagnostic features from early developmental assessments were used as inputs to the MLR classifier to categorize subjects into multiple ASD risk levels. The model provided simple and interpretable results with moderate performance in classifying early symptoms. Still, the linear nature of MLR limits the ability of the model to capture non-linear relationships present in behavioral data and makes the model more challenging for higher classification accuracy. Chen et al. [36] designed automated Alzheimer’s disease classification framework by integrating Soft Non-Maximum Suppression with an Improved ResNet50 model. The designed model utilized feature extraction based on ResNet50 and Soft Non-Maximum Suppression for effective region proposal filtering to reduce redundancy. The designed approach led to high classification accuracy and improved focus on informative brain regions by suppressing less relevant activations [37]. The advantages included enhanced precision in region selection and reduced false positives in imaging interpretation. The main challenge associated with the model was the computational load due to DL depth and post-processing that may hinder real-time applications in clinical settings. Ma et al. [38] designed the transformer-based model that utilized the multi-head self-attention with structured health records and imaging features that enables the model to learn complex relationships across heterogeneous inputs. The designed method utilized the feature embedding, positional encoding and attention-based interpretability mechanisms make the model to highlight clinically relevant biomarkers. The designed model achieved high predictive accuracy and improved computational efficiency. Still, the challenges like high computational requirements, dependency on large annotated datasets and potential overfitting limits the performance. Liu et al. [39] designed the transformer-based multi-channel model for detecting K-complex events in electroencephalogram (EEG) signals. The designed method considered multi-channel EEG inputs with the transformer architecture to capture both temporal dynamics and inter-channel correlations that enabling precise identification of K-complex patterns across different brain regions [40]. The designed model achieved superior detection accuracy and consistency using the temporal modeling, multi-channel feature consideration and applicability for early cognitive impairment monitoring. Still, challenges like computational complexity, the requirement for high-quality annotated EEG datasets and limitations in generalizing across diverse patient populations and recording conditions degrades the performance [41]. The summary of literature review is presented in Table 1.Table 1Summary of literature reviewS. NoProposed MethodAchievementsChallenges[31]DRCAM (DL + RL)High accuracy with adaptive learningHigh complexity, real-time limitation[32]UNet + 3DCNN hybridImproved feature extraction accuracyHigh computation and data requirement[33]Wearable ML prediction modelClinical relevance with sensor dataSignal variability, low interpretability[34]EfficientNet-B0 transfer learningHigh accuracy, faster trainingDomain mismatch, generalization issues[35]Multinomial Logistic RegressionSimple, interpretable classification approachLimited nonlinear modeling capability[36]ResNet50 with Soft-NMSReduced false positives, improved detectionComputational overhead, model complexity[38]Transformer-based prediction modelLong-range dependency learning, explainabilityLarge data, high computation cost[39]Multi-channel transformer EEG modelTemporal, multi-channel feature learningData dependency, generalization limitations Table 1Summary of literature reviewS. NoProposed MethodAchievementsChallenges[31]DRCAM (DL + RL)High accuracy with adaptive learningHigh complexity, real-time limitation[32]UNet + 3DCNN hybridImproved feature extraction accuracyHigh computation and data requirement[33]Wearable ML prediction modelClinical relevance with sensor dataSignal variability, low interpretability[34]EfficientNet-B0 transfer learningHigh accuracy, faster trainingDomain mismatch, generalization issues[35]Multinomial Logistic RegressionSimple, interpretable classification approachLimited nonlinear modeling capability[36]ResNet50 with Soft-NMSReduced false positives, improved detectionComputational overhead, model complexity[38]Transformer-based prediction modelLong-range dependency learning, explainabilityLarge data, high computation cost[39]Multi-channel transformer EEG modelTemporal, multi-channel feature learningData dependency, generalization limitations Summary of literature review Problem statement The development of DL makes the cognitive impairment detection more efficient and existing methods of cognitive impairment detection still face limitations in accurately classifying impairment stages and adapting to patient-specific cognitive changes. Traditional CNNs methods of cognitive impairment detection failed to capture long-range spatial dependencies in neuroimaging data. The recurrent models like Gated Recurrent Unit (GRU) or Long Short-Term Memory networks (LSTMs) are capable of modeling sequential data and are computationally intensive and prone to over-fitting on limited medical datasets. Besides, reinforcement learning-based cognitive therapies suffer from sparse rewards and unstable learning policies that limit the adaptive game-based interventions. In addition, lack sensitivity to finer structural changes in the brain and generalization among heterogeneous patient data. To address the challenges, this research integrates the Multiscale Gaussian Filter (MGF) for enhanced preprocessing, Im-ViT to effectively capture spatial dependencies and temporal relations with low computational cost. Furthermore, VWM game therapy with ItHRL for dynamic difficulty adjustment enables continuous and personalized cognitive intervention. The proposed end-to-end framework enhances both detection accuracy and therapeutic adaptability to overcome the key bottlenecks in existing systems. Proposed methodology The proposed game therapy approach for the cognitive impairment patient acquires input data acquisition from neuroimaging dataset Alzheimers Disease Neuroimaging Initiative (ADNI) and detects cognitive impairment as shown in Fig. 1. To enhance the feature quality of the image, MGF is devised in the pre-processing phase. Then, cognitive impairment detection is employed using Im-ViT model, which effectively captures spatial dependencies within imaging patches. To enhance the model, ResNet-SRU based MLP is integrated for capturing the temporal dependencies across sequential image slices for improving detection accuracy. Then, the game therapy using VWM interface is provided to the cognitive impaired patient to enhance the user’s cognitive state. The next level adjustment of the game’s difficulty is dynamically optimized using the proposed ItHRL, which mimics human hiking behavior to navigate complex policy spaces for ensuring personalized and adaptive cognitive stimulation.Fig. 1Proposed workflow Proposed workflow Data acquisition The input neuroimaging data for the detection of cognitive impairment is acquired from the publicly available ADNI [42] dataset. Pre-processing Filtering the input neuroimaging data is employed using the MGF for enhancing the detection mechanism by smoothing noise and capturing multi-resolution structures. The Gaussian Filter is a type of linear filter that smooths an image by averaging pixel values with a Gaussian-weighted kernel.1\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$D\left(l,h;\zeta\right)=\frac{1}{2\pi\zeta^2}\exp\left(-\frac{l^2+h^2}{2\zeta^2}\right)$$\end{document}where, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\left(l,h\right)$$\end{document} signifies the spatial coordinates and ζ notates the standard deviation of the Gaussian for controlling the smoothing strength. Then, apply multiple Gaussian filters with different standard deviations \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\zeta_a$$\end{document} for capturing information from fine to coarse scales. Let \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$B\left(l,h\right)$$\end{document} be the input neuro image, the filtered output at scale \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\zeta_a$$\end{document} is:2\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$B_{\zeta a}\left(l,h\right)=B\left(l,h\right)*D\left(l,h;\zeta_a\right)$$\end{document}where, ∗ denotes convolution. The multi-scale outcome \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$H\left(B\right)$$\end{document} of the Gaussian filtered outcome is formulated through:3\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$H\left(B\right)=\left\{B_{\zeta1},B_{\zeta2},\dots\dots B_{\zeta x}\right\}$$\end{document} The MGF reduces sensitivity to anatomical differences across individuals or scanner types and provides the noise free image. Cognitive impairment detection Cognitive impairment detection is employed using the proposed Im-ViT model. The proposed Im-ViT captures spatial dependencies, wherein the ResNet-SRU based MLP models are temporal and contextual relations across slices. In this, the introduction of residual connections into the Simple Recurrent Unit (SRU), the Im-ViT model retains long-term dependencies and prevents vanishing gradients for tracking the progression from mild to severe impairment. The proposed Im-ViT extract class-specific discriminative features due to the high attention capacity of ViT and the sequential pattern modeling of SRUs for improving accuracy in fine-grained classification tasks. The structure of the proposed Im-ViT model is presented in Fig. 2.Fig. 2Structure of proposed Im-ViT model Structure of proposed Im-ViT model Patch embedding The Patch Embedding Layer is the devised to transform the pre-processed 2D neuro image into a 1D sequence of fixed-size tokens. It is employed by dividing the image into non-overlapping patches of 16 × 16 or 32 × 32 pixels and flattening each patch into a vector and projecting it into a lower-dimensional embedding space using a learnable linear projection. If the image has shape D× L and patch size is K× K, the resulting sequence has \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$Q=\frac{D\times L}{K^2}$$\end{document} tokens. Each token acts as a representative of a small region of the brain and encoding local spatial structure for detecting regional brain atrophy of cognitive decline. It is defined as:4\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$K_r=Fla\left(P_r\right)\cdot G_m+v_m$$\end{document}where, flattening is symbolized as \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$Fla\left(\cdot\right)$$\end{document}, patch embedding weight and bias is signified as \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$G_m$$\end{document} and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$v_m$$\end{document}, Position encoding Positional Encoding is added to the patch embeddings to inject spatial information that encodes the relative or absolute position of each patch in the image grid. In the proposed cognitive impairment detection, position encoding is employed to preserve spatial relationships between brain regions. It is formulated through:5\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$B_0=K+A_{pos}$$\end{document}where, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$A_{pos}$$\end{document} is a fixed or learnable positional encoding matrix and position encoding is symbolized as \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$B_0$$\end{document}. Transformer encoder The Transformer Encoder is composed of stacked blocks and is responsible for learning contextual relationships between the image patches using Multi-Head Self-Attention (MHSA). MHSA allows the model to attend to multiple regions of the brain simultaneously and independently for learning complex spatial dependencies across all patches. The outcome of the self-attention is expressed through:6\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$S\left(H,J,N\right)=soft\max\left(\frac{H,J^T}{\sqrt{u_j}}\right)N$$\end{document} Here,7\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$H=BG^H;J=BG^J;N=BG^N$$\end{document}where, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$G^H;G^J;G^N$$\end{document} signifies the weights and the outcome of the multi-head attention mechanism is formulated through:8\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$E\left(B\right)=Aggr\left(head_1,head_2,\dots head_d\right)L^0$$\end{document}where, the aggregation of feature acquired from the individual attention head is indicated as \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$Aggr\left(\cdot\right)$$\end{document}, the multi-head attention is indicated as \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$E\left(B\right)$$\end{document}, and the weight associated with the multi-head attention is signified as \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$L^0$$\end{document}. ResNet-SRU based MLP To further improve the model’s ability to capture temporal-like dependencies across layers, the architecture integrates the ResNet-SRU inside the MLP block. The ResNet-SRU captures recurrent dependencies within the sequence of patches while maintaining a lightweight structure suitable for medical data. It functions similarly to GRU but with a residual design and fewer gates and allows efficient propagation of both local and global memory. The update gate is modeled as:9\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_a=\varepsilon\left(G_pl_a+e_p\right)$$\end{document}where, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_a$$\end{document} notates the element-wise update gate, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$G_p$$\end{document} signifies the learnable gate weight matrix, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$e_p$$\end{document} indicates the gate bias and \varepsilon symbolizes the sigmoid function. The current hidden state \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_a$$\end{document} is computed by considering previous hidden state \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_{a-1}$$\end{document} and candidate \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\widehat{q}_a$$\end{document}, weighted by the gate \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_a$$\end{document}:10\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_a=\left(1-P_a\right)\Theta q_{a-1}+P_a\Theta\widehat{q}_a$$\end{document}where, Θ notates the element-wise multiplication, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_{a-1}$$\end{document} indicates the hidden state from the previous time step, and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_a$$\end{document} signifies the updated hidden state. To stabilize the gradient and preserve original signal characteristics, a residual shortcut from input \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$l_a$$\end{document} to output \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_a$$\end{document} is added:11\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\widehat{q}_a=q_a+l_a$$\end{document} The features \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\widehat{q}_a$$\end{document}, thus accomplished are fed into the classification head for the detection of cognitive impairment severity level. Classification head The final component of the Im-ViT model is the classification head designed with fully connected (dense) layer applied to the output embedding of a special classification token. It maps the high-dimensional token vector into class probabilities using SoftMax layer:12\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\widehat{c}=soft\max\left(Gn+v\right)$$\end{document}where,G and v are learnable weights and bias, and n is the final representation of the classification token. The predicted class label is the argmax of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\widehat{c}$$\end{document}. Thus, the outcome of the proposed Im-ViT model is the detection of cognitive impairment. The proposed Im-ViT framework maps the predicted severity class obtained to the initial difficulty level in the VWM game. Thus, the mapping enables the model to avoid under-challenging or overwhelming the user at the initial stage. Game therapy For the cognitive impaired patient, game therapy is provided, wherein the next level adjustment is devised using the ItHRL technique. In the proposed game therapy based on VWM is given. The VWM game engages patients through tasks that require memorizing and recalling visual stimuli arranged on a hexagonal grid to enhance memory retention and spatial cognition. To assess and enhance VWM in individuals with cognitive impairment, the interactive game structured into two sequential stages like memorization and recall. In the memorization stage, the player is presented with a 6 × 6 hexagonal grid on the screen for a fixed duration of 2 s. During this interval, a subset of hexagons is highlighted in yellow to indicate the target positions that the user needs to memorize. The remaining hexagons remain white that serve as non-target distractors. After the memorization interval, the grid resets, and all hexagons revert to white. In the recall stage, the player must click on the hexagons that were previously highlighted as targets. Each click is evaluated in real-time, wherein correct selections are marked green, while incorrect ones turn red. The game score (p) is computed as the ratio of correctly recalled targets to the total number of targets:13\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$p=\frac{q_c}{q_n}$$\end{document}where, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_c$$\end{document} symbolizes the number of correctly recalled targets and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_n$$\end{document} notates the total number of targets in that round. A perfect score of p=1 signifies complete success (a win), while any score p<1 is considered a loss for adaptive feedback purposes. Traditionally, the number of items to memorize (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_n$$\end{document}) was considered the sole determinant of task difficulty. However, in VWM tasks, difficulty is more nuanced due to visual complexity. Spatial grouping, distribution, and component segmentation affect the memorability of the model. Hence, continuous difficulty metric d,based on three key visual-spatial features like number of targets \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_n$$\end{document}, number of connected components \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_a$$\end{document} and distribution score b. The continuous difficulty score is calculated using a normalized linear combination:14\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$b=\eta_1q_n+\eta_2q_a+\eta_3b$$\end{document}where, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\eta_1,\eta_2, and\ \eta_3$$\end{document} symbolizes the tunable weights. To calculate the distribution metric b, a distance matrix B of size \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_n\times q_n$$\end{document}, where each element \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$b_{r,s}$$\end{document} represents the shortest-path distance between the \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$r^{th}$$\end{document} and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$s^{th}$$\end{document} targets on the hexagonal grid. Because the hexagons are arranged in a two-dimensional plane, the shortest path is calculated using hexagonal adjacency.15\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$B=[b_{rs}],where\ b_{rs}=0,\forall r$$\end{document} The final distribution score is computed as the average pair-wise distance between targets:16\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$b=\frac{2}{q_n\left(q_n-1\right)}\sum_{r=1}^{q_n}\sum_{s=r+1}^{q_n}b_{rs}$$\end{document} The distribution score value increases when targets are spread farther apart on the grid, signifying higher cognitive load due to a lack of chunking or grouping. To prevent the repetitiveness inherent in fixed-level task databases with 100 predefined tasks, the designed system dynamically generates new memory tasks on the fly. Each generated task is embedded with a difficulty vector \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_n,q_a,b$$\end{document}, and its scalar difficulty score is computed using Eq. (14). The tasks are stored in a Difficulty Lookup Database (DDB) to avoid duplications and help track difficulty progression over time. The computed difficulty score d is used in the ItHRL framework to dynamically adjust task difficulty based on the player's performance history. A Proximal Policy Optimization (PPO) agent continuously updates the task parameters to keep the player's accuracy within a desired range (70%–90%). When the player consistently wins, the agent raises \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$q_n,q_a,b$$\end{document}; when the player struggles, it selects easier configurations from the DDB. The closed-loop system ensures personalized cognitive training, progressively challenging the user while maintaining engagement and therapeutic value. Design of ItHRL for dynamic task adjustment The ItHRL is efficient in real-time adjustment of game difficulty to match individual cognitive capabilities for enhancing engagement and preventing frustration or boredom. The RL with optimal reward functions maintains players in the optimal challenge zone of 85% performance, which is ideal for maximizing flow and motivation. The ItH algorithm enhances action selection in the RL policy by performing efficient local and global search over the continuous difficulty space for improving learning speed and convergence. Unlike coarse rule-based adjustments, ItHRL uses a continuous difficulty metric for finer granularity in tuning for precise skill matching. The use of player simulation agents in training minimizes the need for costly human trials and enables robust policy development under diverse gameplay conditions. The structure of the proposed ItHRL is presented in Fig. 3.Fig. 3Structure of proposed ItHRL model Structure of proposed ItHRL model State The state \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$g_n=[b_n,m_n]$$\end{document} represents a snapshot of the player's interaction with the system at time n. Here, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$b_n$$\end{document} is the difficulty level of the previously assigned task, and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$m_n$$\end{document} is the player’s corresponding performance score, which is a normalized accuracy between 0 and 1. The dual-element state encapsulates both the cognitive challenge presented and the learner’s capability to respond to it. Action The action \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$h_n$$\end{document} is a continuous variable representing the difficulty level of the next task the agent should assign. The continuous nature of space allows for precise tuning of challenge levels. Reward function Three different reward functions were explored to guide the agent’s learning behavior: (i)85% Rule based Reward \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$E_1$$\end{document}: The \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$E_1$$\end{document} rewards the agent if the player's accuracy falls between (70% and 90%) for the ideal learning zone and penalizes scores below 70%.In addition, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$E_1$$\end{document} provides no reward above 90% for encouraging the players neither under- nor over-challenging the player. It is expressed as: 17\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\left\{\begin{array}{lc}-0.5,&if\ 0