# Borehole Trajectory Optimization Design Based on the SAC Algorithm with a Self-Attention Mechanism
## 1 Introduction  
The exploration and development of oil and natural gas is an engineering practice that challenges the unknown areas of the deep earth. Although the traditional vertical drilling technology is mature and reliable, it gradually shows its limitations in the face of complex and changeable underground geological conditions, increasingly stringent environmental restrictions, and increasing economic benefits. Many oil and gas reservoirs with exploitation value are not vertically distributed below the surface. They may be located below mountains, lakes, oceans, or sensitive areas such as cities, farmland, and nature reserves. Its shape is often not regularly layered, but is inclined, fractured, lenticular, or located in a complex tectonic zone. In addition, a single vertical well can usually only effectively exploit a limited range of oil and gas resources near its wellbore. This limitation becomes more critical as modern drilling operations increasingly encounter deep, faulted, and lithologically heterogeneous formations, where operational safety and efficiency depend on adaptive and robust trajectory control strategies. In order to overcome these challenges, directional drilling technology came into being. The core of this technology is to accurately control the extension path and final target of the wellbore in the underground three-dimensional space, that is, wellbore trajectory design. This requires engineers to carefully plan a three-dimensional space path that can skillfully avoid geological risks (such as faults, high-pressure layers, and salt-gypsum layers), accurately hit multiple dispersed oil and gas targets (multiple targets), maximize the effective range of contact reservoirs (increase the drainage area), and meet ground environment and engineering constraints (such as platform location or anti-collision requirements). Therefore, wellbore trajectory design is the core technology of oil and gas drilling engineering. Its accuracy and reliability are directly related to the safety, efficiency, cost, and final oil and gas recovery effect of drilling operations [1]. Especially in complex geological environments (such as faults, salt-gypsum layers, high-pressure formations, unstable shale formations, and multi-target targets, etc. ), the design process faces severe challenges. Dynamic geological conditions (such as formation pressure fluctuation, lithology mutation, and drillability difference) and complex space obstacles (such as adjacent wells, drilled wells, and geological risk areas) require high flexibility and intelligent avoidance of trajectory design [2]. However, traditional trajectory design methods (such as methods based on geometry or optimization theory) often rely on preset models and static assumptions [3]. It is difficult to adapt to these complex and changeable real-time environmental information efficiently and dynamically, and its intelligence and ability to deal with complex constraints are obviously limited. Reinforcement learning (RL) has shown considerable promise in trajectory planning under complex drilling conditions [4; 5; 6]. [PERSON] et al. [7] applied a deep Q-network (DQN) to enhance intelligent trajectory control. [PERSON] and [PERSON] [8] further introduced an attention-based improvement (NDQN) to enable online decision-making. [PERSON] [9] proposed a deep deterministic policy gradient (DDPG)-based control algorithm, later enhanced via transfer learning for trajectory tracking. [PERSON] [10] addressed convergence issues by developing a double dueling DQN (D3 QN) with a refined reward function. [PERSON] and [PERSON] [11] utilized artificial intelligence (AI) with logging while drilling (LWD) data to optimize well trajectory in real time. Other researchers [12; 13; 14] explored borehole control using deep chemical models. While these methods demonstrate progress, challenges remain in spatial adaptability and robustness in highly heterogeneous formations.