Neural-symbolic-based gomoku game method

CN122768669BActive Publication Date: 2026-10-27DALIAN UNIV OF TECH
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202611225780.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-08-13
Publication Date
2026-10-27
Estimated Expiration
2046-08-13

AI Technical Summary

Technical Problem

[0011]针对现有五子棋人机对弈方法中基于规则推理的算法需要对大量候选落子位置进行逐一搜索、评估和回溯,导致推理时间较长、计算开销较高,难以在复杂棋局下兼顾搜索深度与实时响应能力的问题,以及基于神经网络的算法通常依赖大规模棋谱数据或长时间自我博弈训练,存在训练迭代次数多、训练时间长、数据需求量大、规则约束表达不显式和落子决策可解释性不足的问题,提供一种基于神经符号的五子棋人机对弈方法

Benefits of technology

[0020]本发明的有益效果:本发明能够显著提高五子棋人机对弈过程中的推理效率。由于神经符号模型可以直接根据候选落子点的四方向局部特征输出棋型类别和落子重要性评分,系统无需像传统规则算法那样对每个候选点进行复杂的多轮规则匹配和全局穷举计算,从而减少无效搜索和重复评估,使机器方能够在较短时间内完成落子决策。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122768669B_ABST
    Figure CN122768669B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of computer application technology, and discloses a Gomoku man-machine playing method based on neural symbols. A simulated Gomoku playing environment is constructed and a local chess piece sequence is generated; a chess type identification and chess piece placement scoring dataset is constructed by using the local chess piece sequence; a Gomoku chess type knowledge base and a chess piece placement importance constraint rule are established; in the training stage, the chess type identification and chess piece placement scoring dataset is used, the chess type classification binary predicate and the chess type identification network are constrained by the Gomoku chess type knowledge base, so that the chess type identification network satisfies the Gomoku chess type knowledge base to the maximum; the chess piece placement importance constraint rule is used to constrain the chess piece placement scoring network; in the reasoning stage, the chess type identification network and the chess piece placement scoring network are combined to form a neural symbol model, the local features of the candidate chess piece placement positions are extracted according to the current chess game state, the chess piece placement importance scores are output, and the optimal chess piece placement position is selected through Alpha-Beta pruning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer application technology, and in particular to a method for human-computer Gomoku (Five in a Row) based on neural symbols. Background Technology

[0002] Gomoku (Five in a Row) is a typical two-player zero-sum game, characterized by clear rules, a large state space, complex situational changes, and close offensive and defensive relationships. In human-computer interaction scenarios, the computer needs to assess the current board state, identify potential threats, predict subsequent moves, and make optimal moves within a limited time. Therefore, human-computer Gomoku strategies not only require board state analysis capabilities but also strategic reasoning, rule constraint analysis, and situational assessment abilities.

[0003] Existing methods for human-computer Gomoku (Five in a Row) games mainly include rule-based heuristic methods, game tree search-based methods, and machine learning or deep learning-based methods. Rule-based heuristic methods typically involve manually defining board formations such as three-in-a-row, four-in-a-row, four-in-a-row, and five-in-a-row, assigning corresponding scores to each formation to assess the situation and select moves. These methods are simple to implement and highly interpretable, but their performance largely depends on the manually designed rules. Relying solely on static board formation scores can easily lead to local optima, affecting the stability of the game strategy. Game tree search-based methods typically employ minimax search, Alpha-Beta pruning, Monte Carlo tree search, etc., to perform multi-step deductions on candidate moves and combine this with a situation evaluation function to select the optimal action. These methods can improve the foresight of move decisions to some extent, but as the search depth increases, the number of candidate states grows rapidly, significantly increasing computational overhead.

[0004] In recent years, deep learning and reinforcement learning methods have been introduced into board game tasks. These methods can learn the mapping relationship between board state and move strategy through a large amount of game data, reducing reliance on human features and fixed rules, and have certain advantages in shape recognition, strategy prediction, and value assessment. However, pure neural network models usually lack explicit rule constraints and symbolic reasoning capabilities, and their output results may be difficult to interpret. They may also ignore Gomoku rules, forbidden moves, or key offensive and defensive logic in specific situations. In addition, when the training data coverage is insufficient or the game distribution changes, the model is prone to making unstable decisions, making it difficult to guarantee rule consistency and strategy reliability during the game.

[0005] Therefore, existing methods for human-computer Gomoku (Five in a Row) still have the following shortcomings: First, methods based on human rules and heuristic evaluation have limited generalization ability and are difficult to adapt to complex and ever-changing game states; second, search-based methods struggle to balance search depth, computational efficiency, and real-time response; third, while deep learning-based methods have strong pattern learning capabilities, they lack explicit constraints on game rules, board shape logic, and reasoning processes; and fourth, existing methods still have room for improvement in the interpretability and legitimacy verification of move decisions and multi-step threat reasoning. Based on this, it is necessary to provide a Gomoku human-computer Gomoku method that integrates neural network pattern recognition capabilities with symbolic rule reasoning capabilities to improve the overall performance of board state understanding, candidate move evaluation, rule constraint verification, and game decision-making.

[0006] Chinese patent document CN202211547922.5 discloses a deep learning-based method for playing Gomoku (Five in a Row) and a Go-playing robot. This method collects image data of the Go board and the pieces on it, performs preprocessing on the images including filtering, binarization, polygon fitting, convex hull finding, and perspective transformation. It then constructs a labeled dataset based on the piece positions and colors, and trains a convolutional neural network object detection model to recognize the colors and positions of pieces in real-time game images. The recognition results are converted into a matrix-form game state. After obtaining the matrix-formed game information, the method uses a reinforcement learning model based on the AlphaZero concept to make policy judgments on the current game state. It combines Monte Carlo tree search to evaluate and improve the move strategy, thereby determining the robot's next move. The move position is then encoded into control information executable by the robot. Furthermore, the method uses an exhaustive approach to establish a correspondence between the move points on the board and the robot's execution parameters, enabling the Go-playing robot to complete the corresponding move operation based on the move results output by the reinforcement learning model. However, it mainly relies on deep learning models and search strategies to make judgments on the game. Although it can acquire a certain ability to make moves through training, it lacks explicit symbolic representation of knowledge such as the rules of Gomoku, the logic of board patterns, the relationship between offense and defense, and the constraints of forbidden moves. The reasoning process of the model output is not transparent enough, and it is difficult to explain the board pattern basis and offensive and defensive intentions corresponding to a certain move decision. At the same time, reinforcement learning models are highly dependent on the quality of training data and self-play. In complex situations, rare board patterns, or scenarios with conflicting rule constraints, the strategy may be unstable or the rule consistency may be insufficient.

[0007] Chinese patent document CN202310240263.9 discloses an intelligent Gomoku robot based on a SCARA parallel robotic arm. This solution uses a machine vision module to acquire Gomoku images in real time and converts the game image information into Gomoku matrix data that can be processed by the main control circuit board to identify the number, position, and current placement of pieces on the board. Based on this, the system judges the Gomoku situation according to the player's choice of first or second move mode, the difficulty of the game, and the current game matrix. The built-in game program calculates the target position of the robot's next move, realizing automated processing from game perception, state matrixing, situation analysis to move decision-making. At the same time, this solution also integrates a voice recognition module to realize human-computer interaction control, allowing users to wake up, select modes and difficulty through voice, and the main control system generates corresponding motion control commands based on the calculated target position of the move to drive the actuator to complete the picking up and placement of pieces. However, its focus is on machine vision recognition, human-computer interaction, and automatic move execution by robotic arms. The description of the Gomoku game decision-making algorithm itself is relatively general, lacking systematic modeling of move pattern recognition, threat reasoning, rule constraints, and multi-step attack and defense logic. When facing complex game situations, relying solely on the built-in game program to judge the situation makes it difficult to simultaneously take into account the pattern learning ability of neural networks and the interpretable reasoning ability of symbolic rules. Therefore, there is still room for improvement in the interpretability of move decisions, strategy stability, and generalization ability of complex move patterns.

[0008] Chinese patent document CN202411541339.2 discloses a Gomoku (Five-in-a-Row) device. This solution uses a Siemens PLC control system as its core, acquiring the user's move information during the game via a touchscreen or control system. It maps the distribution of pieces on the board into position information usable for control and decision-making, thus narrowing down the range of candidate moves and improving move search and execution efficiency. During the Gomoku game, the subsequent move position is determined based on the current board state. However, it primarily focuses on piece position mapping, motion control, and automated execution, with less attention paid to the intelligent decision-making capabilities of the Gomoku game algorithm. It lacks deep learning of board state characteristics, symbolic representation of piece combination relationships, and reasoning mechanisms for attack and defense strategies. Therefore, this solution leans more towards an automated game execution device than an intelligent game method for analyzing complex game situations, and struggles to solve problems such as multi-step threat identification, candidate move interpretation, and rule constraint fusion.

[0009] Chinese patent document CN202510655158.0 discloses a method, apparatus, device, and storage medium for generating and extracting steganographic information. This scheme uses the Gomoku game record as the steganographic information carrier. First, the information to be hidden is converted into a binary transmission sequence with control characters. Then, a set of candidate move positions is generated through a Gomoku game model driven by reinforcement learning. The Gomoku game model uses a convolutional neural network to extract the board state features and combines a Monte Carlo tree search algorithm to calculate the win probability distribution of different candidate move positions, so that the generated move actions can meet the rules of Gomoku and the basic game rationality. This scheme further constructs an attraction matrix of the same dimension as the chessboard, calculates spatial influence based on the Manhattan distance between placed pieces and empty positions, and performs weighted optimization on the candidate action set, making the spatial distribution of candidate pieces more closely resemble the clustered placement patterns in real chess games. After optimizing the candidate actions, the scheme encodes the placement positions into binary segments of different lengths according to the different positional relationships of the central area, boundary area, and corner area of ​​the chessboard, and maps the secret information sequence to the actual placement position through longest prefix matching, ultimately generating a Gomoku game record carrying hidden information. However, its core objective is to use Gomoku behavior to achieve steganographic information embedding and extraction, rather than improving the intelligent decision-making ability in the Gomoku human-computer game process; its placement generation serves more the steganographic encoding capacity, spatial distribution rationality, and covert communication security, and does not adequately consider aspects such as board pattern logic, forbidden move rules, attack and defense interpretation, real-time game feedback, and human-computer interaction strategies, making it difficult to directly meet the high-quality decision-making needs of real Gomoku human-computer game scenarios.

[0010] The paper “Liang R , Dong H , Jiang B .Research on the Alpha-Beta SearchAlgorithm of Gobang Based on Zobrist Hash and Custom Evaluation Function[C] / / 2025 Asian Conference on Artificial Intelligence Technology (ACAIT).0[2026-08-04].” discloses an improved Alpha-Beta pruning algorithm for Gobang. This method takes the current board state as input and introduces pattern scoring, position weighting, forbidden move judgment, Zobrist hashing, and a permutation table caching mechanism into the traditional Alpha-Beta search framework. The algorithm identifies patterns such as consecutive fives, open fours, pushing fours, open threes, and sleeping threes by scanning the horizontal, vertical, and diagonal directions of the board. It assigns higher weights to key offensive and defensive combinations such as double open threes, open three plus pushing fours, and double fours to improve the ability to evaluate the situation. Simultaneously, it uses a center position weighting strategy to guide the opening moves and ensures the legitimacy of candidate moves through forbidden move filtering. To reduce redundant searches, this method uses Zobrist hashes to identify board states and reuses evaluation results of calculated positions using permutation tables, thereby improving the search efficiency and move-making quality of the Gomoku AI. However, it mainly relies on manually designed pattern rules, scoring weights, and heuristic search strategies. While it has some interpretability and high search efficiency, its ability to learn about potential pattern evolution, atypical layouts, and dynamic attack-defense transitions in complex games is limited. Pattern scoring and position weights usually require manual parameter tuning and are difficult to adaptively optimize based on different opponent styles and game stages. Compared to Gomoku human-computer interaction methods based on neural symbols, this type of method lacks the ability of neural networks to autonomously learn game patterns and has not formed a collaborative mechanism between neural perception and symbolic reasoning. Therefore, it still has shortcomings in generalization ability, strategy adaptability, and understanding of complex situations. Summary of the Invention

[0011] To address the issues of existing Gomoku (Five-in-a-Row) human-computer game methods, such as the long inference time and high computational cost resulting from rule-based reasoning algorithms requiring the sequential search, evaluation, and backtracking of numerous candidate move positions, which struggle to balance search depth and real-time response capabilities in complex game situations, and the problems of neural network-based algorithms relying on large-scale game records or lengthy self-play training leading to numerous training iterations, long training times, large data requirements, unclear rule constraints, and insufficient interpretability of move decisions, this paper proposes a neural symbolic Gomoku human-computer game method. This method combines the game feature perception capabilities of neural networks with the pattern reasoning, forbidden move judgment, and attack / defense logic constraint capabilities of symbolic rules. This reduces global exhaustive search and data training dependence while improving the efficiency and accuracy of game state understanding, candidate move selection, strategy reasoning, and move decisions. This invention aims to achieve a Gomoku intelligent game process with shorter inference time, fewer training iterations, lower training data requirements, and higher rule consistency, thereby solving the problems of insufficient computational efficiency of existing single rule-driven methods and high training cost, weak interpretability, and insufficient rule constraint capability of single neural network methods.

[0012] The technical solution of this invention is as follows: A method for human-computer Gomoku (Five-in-a-Row) based on neural symbols, which constructs a simulated Gomoku playing environment and generates local piece sequences; uses the local piece sequences to construct a pattern recognition and move scoring dataset; establishes a Gomoku pattern knowledge base and move importance constraint rules; in the training phase, using the pattern recognition and move scoring dataset, constrains the binary pattern recognition predicate and pattern recognition network through the Gomoku pattern knowledge base, so that the pattern recognition network has the maximum satisfaction with the Gomoku pattern knowledge base; constrains the move scoring network using move importance constraint rules; in the inference phase, the pattern recognition network and the move scoring network are combined to form a neural symbol model, extracts local features of candidate move positions according to the current game state, outputs move importance scores, and selects the optimal move position through Alpha-Beta pruning.

[0013] The specific steps for constructing a simulated Gomoku (Five in a Row) game environment and generating local piece sequences are as follows: Construct a simulation environment for the Gomoku (Five in a Row) board and pieces; the board state is represented as a two-dimensional matrix: Where M represents the size of the chessboard. This indicates that the chessboard position is empty. This indicates that the position on the chessboard belongs to the black piece. This indicates that the position on the chessboard belongs to the white piece; The process of placing pieces is recorded based on a simulation environment, and the state of the game is updated in real time to a two-dimensional matrix. For each valid piece, a local sequence of pieces with a length of nine is recorded in four directions: horizontal, vertical, main diagonal, and secondary diagonal, with the piece position coordinates as the center. Let the four directions be horizontal, vertical, main diagonal, and secondary diagonal. Then, in the i-th direction, the candidate placement position is... chess piece state sequence for: Wherein, the coordinates of the candidate placement position p are , For the position transformation corresponding to the i-th direction, This represents the state of the first piece in the i-th direction, and the states of the pieces in the nine positions are recorded sequentially. This indicates the state of the piece at the candidate placement position p; This represents the state of the second piece in the i-th direction; This represents the state of the ninth piece in the i-th direction; This yields the local chess piece sequence for the candidate move position p. It is used to describe the continuous piece relationships, empty space distribution, and blocking status of candidate moves in four directions. It is expressed as follows: in, It is a horizontal sequence of chess piece states. It is a vertical sequence of chess piece states. The sequence of chess piece states along the main diagonal. This is the sequence of chess piece states on the secondary diagonal.

[0014] The construction of the chess pattern recognition and move scoring dataset is specifically as follows: For each candidate move position's local piece sequence, identify the corresponding move type according to the rules of Gomoku; the set of move type categories is defined as: in, These correspond to seven types of chess patterns: five-in-a-row, four-in-a-row, four-in-a-row, three ... two-in-a-row, and two-in-a-row. This indicates that there is no valid chess pattern; Candidate move positions Four-directional chess pattern category label sequence Defined as: in, It is a horizontal chess pattern category. The vertical chess pattern category. The main diagonal chess pattern category This is a chess pattern category for the secondary diagonal; Let the candidate move positions be set The chess pattern counting vector is These correspond to the number of occurrences of seven types of chess patterns—five-in-a-row, four-in-a-row, four-in-a-row, three ... two-in-a-row, and two-in-a-row—in the four directions, respectively. Based on the principles of Gomoku (Five in a Row), we perform an equivalent transformation of two four-in-a-row combinations, equating two four-in-a-row combinations to a single live four-in-a-row. The pattern counting vector is then preprocessed as follows: in, This is an indicator function that takes the value when the condition is true. The quotient of dividing by 2 is 0 if it is not true. The number of times the equivalent four-in-a-row pattern appears in the four directions; Candidate move positions Target Importance Score The calculation formula is: in, For the remaining cases, the segmented scoring items for the three-in-a-row pattern are defined as follows: The local piece sequence for each candidate move position p. The corresponding chess pattern category label sequence And the target importance score of the candidate move position. By binding and combining individual candidate moves as independent sample units, a chess pattern recognition and move scoring dataset S is constructed: S .

[0015] The Gomoku (Five in a Row) pattern knowledge base contains 8 axioms, covering 8 types of patterns: consecutive five, live four, rush four, live three, sleeping three, live two, sleeping two, and no valid pattern. During the training process, the pattern recognition network is constrained to learn the pattern recognition rules. Suppose a binary chess pattern recognition predicate Represents a local chess piece sequence Belongs to the chess type category The output truth value range is Let variables be defined. The domains of discourse are all local chess piece sequences labeled with the corresponding categories in the chess pattern recognition and move scoring datasets, respectively. The eight axioms are: This indicates that all local piece sequences marked as a five-in-a-row satisfy the recognition predicate for the five-in-a-row pattern; This indicates that all local piece sequences labeled as "live four" satisfy the recognition predicate for the live four pattern; This indicates that all local piece sequences marked as "Four-in-a-Row" satisfy the recognition predicate of the Four-in-a-Row pattern; This indicates that all local piece sequences labeled as "live three" satisfy the predicate for recognizing live three patterns; This indicates that all local piece sequences labeled as Sleeping Three satisfy the recognition predicate of Sleeping Three pattern; This indicates that all local piece sequences marked as "live two" satisfy the predicate for recognizing "live two" patterns. This indicates that all local piece sequences labeled as Sleeping Two satisfy the recognition predicate of Sleeping Two pattern; This indicates that all local piece sequences marked as having no valid pattern satisfy the identification predicate of having no valid pattern; The above axioms hold simultaneously through logical conjunction, forming a Gomoku (Five in a Row) pattern knowledge base. This knowledge base supervises and constrains the pattern recognition network, driving iterative optimization of the neural network parameters at the predicate level, thereby enabling the recognition of various patterns. The importance constraint rule for the move is: for candidate move positions Target Importance Score Establish scoring consistency constraints: in, This is a smooth equality predicate used to measure the closeness between the predicted importance score and the target importance score. For the scoring function of the importance of the move, This is the sensitivity coefficient for scoring errors. To prevent numerical instability of constants, exp is an exponential function.

[0016] The neural symbol model includes a chess pattern recognition network and a move scoring network. During the training process of the neural symbol model, a three-layer architecture of multilayer perceptron, log-probability-predicate conversion adaptation module, and satisfaction aggregation is adopted. In the chess pattern recognition network, a multilayer perceptron (MLP) is constructed as the bottom-level computational module to perform sequence feature extraction and classification score calculation. The MLP consists of multiple linear layers connected in series, with layer dimensions of 9, 16, 16, 64, 16, and 8 respectively. The input is a one-dimensional local chess piece sequence of length 9. The output is an 8-dimensional unnormalized classification log odds vector. ; in Trainable parameters for a multilayer perceptron for chess pattern recognition; Except for the last output layer, all linear layers are followed by the ELU activation function; in training mode, a random deactivation mechanism is enabled for regularization with a dropout rate of 0.2, while in inference mode it is disabled; The 8-dimensional unnormalized classification log odds vector is input to the log odds-predicate conversion adapter module to generate the true probability values ​​in the [0,1] interval; For the eight types of chess moves, an 8-dimensional one-hot floating-point vector encoding is used to define the chess move category constant. , These correspond to eight categories: five consecutive moves, four live moves, four rush moves, three live moves, three sleeping moves, two live moves, two sleeping moves, and no effective moves. The float32 data type is used as the label input for the binary moves recognition predicate, which is used to extract the membership truth value of the corresponding category from the 8-dimensional unnormalized classification log probability vector. The 8-dimensional unnormalized classification log odds vector is normalized using the Softmax function to obtain the probability distribution vectors of the 8 chess patterns. The calculation formula is: in, This represents the probability value of the local piece sequence in this direction belonging to the e-type chess pattern. This represents the log-probability of class e chess patterns corresponding to the local piece sequence in that direction. This represents the j-th class log odds in the class log odds vector; The obtained probability distribution vector is compared with the chess pattern category constant. Perform element-wise multiplication and summation along the feature dimension: in, The fuzzy truth value corresponding to the binary chess pattern recognition predicate is constrained to the interval [0,1] and is used to represent the local chess piece sequence. Belongs to the corresponding chess type category The degree of membership; Let be the probability distribution vector of the 8 types of chess patterns. Category constants for each chess type ; Define a universal quantifier for chess pattern recognition, and use a power-mean error operator with an aggregation order of 2 as the fuzzy aggregation operator; the formula for calculating the truth value of a single axiom after universal quantification is as follows: in, Representing the Local chess piece sequences in each direction; In the chess pattern recognition network, universal quantifiers are applied to the sample sets of 8 chess patterns in the chess pattern recognition and move scoring datasets respectively. The axiom satisfaction degree of each sample being correctly identified as the corresponding chess pattern is calculated one by one, and 8 independent single axiom truth values ​​are output. Define the chess pattern recognition satisfaction aggregation operator The truth values ​​of multiple independent logical axioms are aggregated into a global scalar, which serves as the result of the satisfaction aggregation of the chess pattern recognition network. The calculation formula is as follows: in For the total number of axioms, Let g be the truth value of the g-th chess pattern recognition axiom.

[0017] In the aforementioned move scoring network, a multilayer perceptron is constructed to establish a nonlinear mapping relationship between the four-directional move pattern features and the target importance score. The input is a classification log probability vector with shape [batch, 4, 8] output from the move pattern recognition network. During forward computation, the classification log probability vector is flattened along the feature dimension to a one-dimensional feature vector of shape [batch, 32]. Feature transformation is performed through multiple linear layers, with layer dimensions set to 32, 64, 32, 16, and 1 respectively. Except for the last output layer, all linear layers are followed by an ELU activation function to introduce nonlinearity. The final output is a move importance score with shape [B, 1]. The overall mapping relationship is expressed as follows: in, For the nonlinear mapping function corresponding to the multilayer perceptron for move scoring, [the function is missing here]. The predicted score for the candidate position output by the move scoring network; Define universal quantifiers for scoring tasks, and use a penalized error mean operator with an order parameter of 2 as a fuzzy aggregation operator to aggregate the truth values ​​of smoothed equal predicates for all samples in a batch, obtaining the overall satisfaction of a single universal axiom; define a piece-by-piece scoring satisfaction aggregation operator. As the result of the satisfaction aggregation of the move-based rating network, the calculation formula is as follows: in, The total number of samples within the batch. For the first The truth value of the smooth equality predicate for each sample. For the first The importance score of each sample's move. For the first The true value of each sample.

[0018] A neural symbolic model is constructed by combining a chess pattern recognition network and a move scoring network; during training, the training objective is to maximize the chess pattern recognition satisfaction aggregation operator. Aggregation operator for move score satisfaction The joint loss function is defined as follows: in, These are the weighting coefficients for the scoring constraints; During training, the satisfaction scores of the pattern recognition network and the move scoring network, the pattern recognition accuracy, the root mean square error of the score, and the mean absolute error of the score are periodically calculated, and a comprehensive evaluation index is constructed: in, Indicates the accuracy rate of chess pattern recognition. This represents the root mean square error of the score. This represents the mean absolute error of the scores. The weighting coefficients are used; when the comprehensive evaluation index Q is higher than the historical best value, the current model weights are saved as the optimal neural symbolic model.

[0019] During the reasoning phase, a set of candidate moves is generated based on the current board state, prioritizing empty positions within the neighborhood of existing pieces as candidate moves: in, Represents the neighborhood radius. Indicates the candidate placement position Positions of existing pieces The distance between them; for each candidate placement position Extract its local chess piece sequence Input the trained neural symbolic model to obtain the importance score of each move: By embedding the neural symbolic model into the Alpha-Beta pruning search process to obtain the importance score of each candidate move, the recursive search function is defined as follows: Where α and β represent the lower and upper bounds of the search interval, respectively, the search depth is d, and the current player is t; in the non-terminating state, a recursive search is performed based on the candidate move set, and pruning is performed according to the Alpha-Beta condition: in, This indicates the position of the new candidate piece after executing the candidate piece move. Indicates the opposing party; Used to update the lower bound of the search. When satisfied When this happens, stop the subsequent search on the current branch; The candidate move with the highest search score is selected as the machine's actual move: in, Let w be the w-th candidate move, and N be the number of candidate moves generated. To find the candidate position that maximizes the Alpha-Beta search score from the entire set of candidate moves. .

[0020] The beneficial effects of this invention are as follows: This invention can significantly improve the reasoning efficiency in the human-computer Gomoku game. Because the neural symbolic model can directly output the game pattern category and the importance score of the move based on the four-directional local features of the candidate move, the system does not need to perform complex multi-round rule matching and global exhaustive calculations for each candidate move as in traditional rule-based algorithms. This reduces invalid searches and redundant evaluations, enabling the machine to complete the move decision in a shorter time.

[0021] This invention reduces the amount of data, training time, and number of iterations required for model training. By introducing Gomoku (Five in a Row) pattern knowledge, scoring rules, and logical constraints into the neural network training process, model learning no longer relies entirely on a large amount of game data. Instead, it can converge quickly under the guidance of symbolic knowledge, improving the training efficiency of pattern recognition and move scoring. This invention is suitable for application scenarios with limited training resources or small-scale game record data.

[0022] This invention improves the accuracy, stability, and interpretability of intelligent decision-making in Gomoku (Five-in-a-Row). The board pattern labels and importance scores output by the neural symbolic model reflect the offensive and defensive implications of candidate moves. Alpha-Beta pruning further ensures the search and verification of key move paths, making the final move result both data-driven situational awareness and in accordance with the rules of Gomoku board patterns and offensive and defensive logic, thereby enhancing the reliability of decision-making in complex game situations. Attached Figure Description

[0023] Figure 1 This is an overall flowchart of the human-computer Gomoku (Five in a Row) human-computer game method based on neural symbols of the present invention.

[0024] Figure 2 This is a flowchart illustrating the training process of the neural symbolic model of this invention.

[0025] Figure 3 This is a flowchart of the move-making process based on the combination of neural symbolic scoring and Alpha-Beta pruning in this invention. Detailed Implementation

[0026] This invention provides a neurosymmetric method for human-computer Gomoku (Five in a Row). The method generates game samples by constructing a simulated Gomoku game environment, forms a dataset for pattern recognition and move scoring based on four-directional local line segment scanning, and further establishes a Gomoku pattern knowledge base and move importance constraint rules. During the model training phase, this invention employs a neurosymmetric learning approach, combining the pattern recognition capability of neural networks with the logical constraint capability of symbolic rules, enabling the model to simultaneously complete pattern category recognition and candidate move importance scoring. During the inference phase, the system extracts four-directional local features of candidate move positions based on the current game state. The trained neurosymmetric model outputs pattern probabilities, pattern labels, and move importance scores, which are then embedded into an Alpha-Beta pruning search process, thereby reducing the invalid search space while improving the accuracy and real-time performance of move decisions.

[0027] The complete technical solution of this invention includes the following steps, and the overall method flowchart is as follows: Figure 1 As shown.

[0028] S1: Construct a simulated Gomoku (Five in a Row) game environment and generate game samples; Construct a simulation environment for the Gomoku (Five in a Row) board and pieces; the board state is represented as a two-dimensional matrix: Where M represents the size of the chessboard. This indicates that the chessboard position is empty. This indicates that the position on the chessboard belongs to the black piece. This indicates that the position on the chessboard belongs to the white piece; through relative encoding, the chess pattern recognition network can use the same set of parameters to process the local chess patterns of both black and white.

[0029] The system records the move-making process based on a simulation environment, updating the game state in real time to a two-dimensional matrix for each move. For each valid move, it records a local sequence of pieces of length nine in four directions: horizontal, vertical, main diagonal, and secondary diagonal, centered on the move's coordinates. Let the four directions be horizontal, vertical, main diagonal, and secondary diagonal. Then, in the i-th direction, the candidate placement position is... chess piece state sequence for: Wherein, the coordinates of the candidate placement position p are , For the position transformation corresponding to the i-th direction, This represents the state of the first piece in the i-th direction, and the states of the pieces in the nine positions are recorded sequentially. This indicates the state of the piece at the candidate placement position p; This represents the state of the second piece in the i-th direction; This represents the state of the ninth piece in the i-th direction. Using a local piece sequence of length 9 completely covers the main patterns related to candidate moves, while avoiding the increased input dimensionality and computational overhead caused by directly inputting the entire chessboard. When a position in the local piece sequence exceeds the chessboard boundary, it is treated as a blocking position that cannot be further extended. In the specific implementation, a boundary marker can be set, and during the pattern determination process, this boundary marker is treated as having the same blocking effect as the opponent's piece. This setting ensures that patterns located at the edges or corners of the chessboard are judged according to their actual extendable direction, avoiding the misidentification of areas outside the chessboard boundary as empty positions.

[0030] This yields the local chess piece sequence for the candidate move position p. It is used to describe the continuous piece relationships, empty space distribution, and blocking status of candidate moves in four directions. It is expressed as follows: in, It is a horizontal sequence of chess piece states. It is a vertical sequence of chess piece states. The sequence of chess piece states along the main diagonal. This is the sequence of piece states along the secondary diagonal. This state can describe the continuous piece relationships, empty space distribution, and blocking states of candidate placement positions in four directions.

[0031] When generating training samples, the board state can be generated through three methods: random play, rule-guided play, and expansion of existing board states. Random play increases the diversity of board states; rule-guided play increases the occurrence rate of key board patterns such as three-in-a-row, four-in-a-row, and five-in-a-row; and expansion of existing board states generates candidate move samples based on the generated board state. For the same board state, horizontal flipping, vertical flipping, diagonal flipping, and rotation operations can also be performed to generate expanded samples with invariant board pattern semantics, thereby reducing the model's dependence on specific board orientations.

[0032] S2: Create a chess pattern recognition and move scoring dataset; For each candidate move position's local piece sequence, identify the corresponding move type according to the rules of Gomoku; the set of move type categories is defined as: in, These correspond to seven types of chess patterns: five-in-a-row, four-in-a-row, four-in-a-row, three ... two-in-a-row, and two-in-a-row. This indicates that there is no valid chess pattern; Candidate move positions Four-directional chess pattern category label sequence Defined as: in, It is a horizontal chess pattern category. The vertical chess pattern category. The main diagonal chess pattern category This is a chess pattern category for the secondary diagonal; Let the candidate move positions be set The chess pattern counting vector is These correspond to the number of occurrences of seven types of chess patterns—five-in-a-row, four-in-a-row, four-in-a-row, three ... two-in-a-row, and two-in-a-row—in the four directions, respectively. Based on the principles of Gomoku (Five in a Row), we perform an equivalent transformation of two four-in-a-row combinations, equating two four-in-a-row combinations to a single live four-in-a-row. The pattern counting vector is then preprocessed as follows: in, This is an indicator function that takes the value when the condition is true. The quotient of dividing by 2 is 0 if it is not true. The number of times the equivalent four-in-a-row pattern appears in the four directions; Candidate move positions Target Importance Score The calculation formula is: in, For the remaining cases, the segmented scoring items for the three-in-a-row pattern are defined as follows: To improve the numerical stability of the training process, the target importance score is divided by the highest score of 10000 to obtain a normalized target score with a value range of [0,1]. The move scoring network uses the normalized score as the training objective; during the inference phase, the network output can be multiplied by 10000 to restore the original score scale, or the normalized score can be used directly to rank the candidate moves. Score normalization does not change the importance order between different candidate moves, but it can avoid excessive gradient changes caused by large score differences.

[0033] The local piece sequence for each candidate move position p. The corresponding chess pattern category label sequence And the target importance score of the candidate move position. By binding and combining individual candidate moves as independent sample units, a chess pattern recognition and move scoring dataset S is constructed: S .

[0034] S3: Establish a Gomoku (Five in a Row) board pattern knowledge base and rules for the importance of moves; The Gomoku (Five in a Row) board pattern knowledge base contains 8 axioms, covering 8 types of board patterns, including five consecutive pieces, four live pieces, four rushing pieces, three live pieces, three sleeping pieces, two live pieces, two sleeping pieces, and no valid board patterns. During the training process, the board pattern recognition network is constrained to learn the board pattern recognition rules. Suppose a binary chess pattern recognition predicate Represents a local chess piece sequence Belongs to the chess type category The output truth value range is Let variables be defined. The domains of discourse are all local chess piece sequences labeled with the corresponding categories in the chess pattern recognition and move scoring datasets, respectively. The eight axioms are: This indicates that all local piece sequences marked as a five-in-a-row satisfy the recognition predicate for the five-in-a-row pattern; This indicates that all local piece sequences labeled as "live four" satisfy the recognition predicate for the live four pattern; This indicates that all local piece sequences marked as "Four-in-a-Row" satisfy the recognition predicate of the Four-in-a-Row pattern; This indicates that all local piece sequences labeled as "live three" satisfy the predicate for recognizing live three patterns; This indicates that all local piece sequences labeled as Sleeping Three satisfy the recognition predicate of Sleeping Three pattern; This indicates that all local piece sequences marked as "live two" satisfy the predicate for recognizing "live two" patterns. This indicates that all local piece sequences labeled as Sleeping Two satisfy the recognition predicate of Sleeping Two pattern; This indicates that all local piece sequences marked as having no valid pattern satisfy the identification predicate of having no valid pattern; The above axioms hold simultaneously through logical conjunction, forming a Gomoku (Five in a Row) pattern knowledge base. This knowledge base supervises and constrains the pattern recognition network, driving iterative optimization of the neural network parameters at the predicate level, thereby enabling the recognition of various patterns. The importance constraint rule for the move is: for candidate move positions Target Importance Score Establish scoring consistency constraints: in, This is a smooth equality predicate used to measure the closeness between the predicted importance score and the target importance score. For the scoring function of the importance of the move, This is the sensitivity coefficient for scoring errors, which can be set from 1 to 10. To prevent numerical instability, the constant can be set to 10.-8 exp is an exponential function.

[0035] S4: Construct a neural symbolic model; The neural symbolic model constructed in this invention comprises two main functional modules: a chess pattern recognition network and a move scoring network. During the training process of the neural symbolic model, a three-layer architecture is employed, consisting of a multilayer perceptron, a log-probability-predicate transition adaptation module, and a satisfaction aggregation layer. In the chess pattern recognition network, a multilayer perceptron (MLP) is constructed as the bottom-level computational module to perform sequence feature extraction and classification score calculation. The MLP consists of multiple linear layers connected in series, with layer dimensions of 9, 16, 16, 64, 16, and 8 respectively. The input is a one-dimensional local chess piece sequence of length 9. The output is an 8-dimensional unnormalized classification log odds vector. ; in Trainable parameters for a multilayer perceptron for chess pattern recognition; Except for the last output layer, all linear layers are followed by the ELU activation function to reduce the probability of neuron inactivation during multilayer perceptron training; in training mode, a random inactivation mechanism is enabled for regularization with a dropout rate of 0.2, while in inference mode it is disabled. The 8-dimensional unnormalized classification log odds vector is input to the log odds-predicate conversion adapter module to generate the true probability values ​​in the [0,1] interval; For the eight types of chess moves, an 8-dimensional one-hot floating-point vector encoding is used to define the chess move category constant. , These correspond to eight categories: five consecutive moves, four live moves, four rush moves, three live moves, three sleeping moves, two live moves, two sleeping moves, and no effective moves. The float32 data type is used as the label input for the binary moves recognition predicate, which is used to extract the membership truth value of the corresponding category from the 8-dimensional unnormalized classification log probability vector. The 8-dimensional unnormalized classification log odds vector is normalized using the Softmax function to obtain the probability distribution vectors of the 8 chess patterns. The calculation formula is: in, This represents the probability value of the local piece sequence in this direction belonging to the e-type chess pattern. This represents the log-probability of class e of the local piece sequence in that direction. This represents the j-th class log odds in the class log odds vector; The obtained probability distribution vector is compared with the chess pattern category constant. Perform element-wise multiplication and summation along the feature dimension: in, The fuzzy truth value corresponding to the binary chess pattern recognition predicate is constrained to the interval [0,1] and is used to represent the local chess piece sequence. Belongs to the corresponding chess type category The degree of membership; Let be the probability distribution vector of the 8 types of chess patterns. Category constants for each chess type ; Define a universal quantifier for chess pattern recognition, and use a power-mean error operator with an aggregation order of 2 as the fuzzy aggregation operator; the formula for calculating the truth value of a single axiom after universal quantification is as follows: in, Representing the Local chess piece sequences in each direction; In the chess pattern recognition network, universal quantifiers are applied to the sample sets of 8 chess patterns in the chess pattern recognition and move scoring datasets respectively. The axiom satisfaction degree of each sample being correctly identified as the corresponding chess pattern is calculated one by one, and 8 independent single axiom truth values ​​are output. Define the chess pattern recognition satisfaction aggregation operator The truth values ​​of multiple independent logical axioms are aggregated into a global scalar, which serves as the result of the satisfaction aggregation of the chess pattern recognition network. The calculation formula is as follows: in For the total number of axioms, Let g be the truth value of the g-th chess pattern recognition axiom.

[0036] In the aforementioned move scoring network, a multilayer perceptron is constructed to establish a nonlinear mapping relationship between the four-directional move pattern features and the target importance score. The input is a classification log probability vector with shape [batch, 4, 8] output from the move pattern recognition network. During forward computation, the classification log probability vector is flattened along the feature dimension to a one-dimensional feature vector of shape [batch, 32]. Feature transformation is performed through multiple linear layers, with layer dimensions set to 32, 64, 32, 16, and 1 respectively. Except for the last output layer, all linear layers are followed by an ELU activation function to introduce nonlinearity. The final output is a move importance score with shape [B, 1]. The overall mapping relationship is expressed as follows: in, For the nonlinear mapping function corresponding to the multilayer perceptron for move scoring, [the function is missing here]. The predicted score for the candidate position output by the move scoring network; Define universal quantifiers for scoring tasks, and use a penalized error mean operator with an order parameter of 2 as a fuzzy aggregation operator to aggregate the truth values ​​of smoothed equal predicates for all samples in a batch, obtaining the overall satisfaction of a single universal axiom; define a piece-by-piece scoring satisfaction aggregation operator. As the result of the satisfaction aggregation of the move-based rating network, the calculation formula is as follows: in, The total number of samples within the batch. For the first The truth value of the smooth equality predicate for each sample. For the first The importance score of each sample's move. For the first The true value of each sample.

[0037] During initialization, the weights of the linear layers in both the pattern recognition network and the move scoring network can be initialized using the Xavier uniform initialization method, and the bias parameters are initialized to 0. The pattern recognition network and the move scoring network are jointly trained end-to-end, and the gradients generated by the pattern recognition network can be further propagated to the move scoring network.

[0038] S5: Joint training based on neural symbol constraints; During training, this invention simultaneously optimizes the chess pattern recognition network and the move scoring network. The training process is as follows: Figure 2 As shown.

[0039] The model training objective is to maximize the satisfaction of the above logical constraints. Equivalently, the loss function can be defined as: in, The scoring constraint weight coefficient is used to adjust the importance between the chess pattern recognition task and the move scoring task.

[0040] During training, the Adam optimizer was used for parameter updates, with an initial learning rate of 0.001, a batch size of 128, a maximum number of training epochs of 200, and a weight decay factor of 10. -5 During training, the learning rate is adjusted based on the comprehensive evaluation index of the validation set; if the comprehensive evaluation index fails to improve for 20 consecutive training rounds, training is terminated early, and the model parameters at the highest historical comprehensive evaluation index are used as the final model parameters.

[0041] To select the model with the best overall performance, this invention periodically calculates the satisfaction of chess pattern constraints, the accuracy of chess pattern recognition, the satisfaction of scoring constraints, the root mean square error of scoring, and the mean absolute error of scoring during the training process, and constructs a comprehensive evaluation index: in, This indicates the accuracy rate of chess pattern recognition. This represents the root mean square error of the score. This represents the mean absolute error of the scores. The weighting coefficients are non-negative, and their sum is preferably 1. When the overall evaluation index of the model is higher than the historical best value, the current model weights are saved as the optimal neural symbolic model.

[0042] S6: Inference of the importance of candidate moves based on a neural symbolic model; In the actual human-computer chess game reasoning phase, the system first generates a set of candidate moves based on the current board state. To avoid traversing the entire board, the system prioritizes selecting empty positions within the neighborhood of existing pieces as candidate moves: in, Represents the neighborhood radius. Indicates candidate position Positions of existing pieces The distance between them.

[0043] For each candidate move position Extract its local line segment features in four directions. Input the trained neural symbolic model to obtain the probability of the move pattern, the pattern label, and the importance score of the move: in, This represents the neural symbolic model after training. Indicates the predicted chess pattern combination. This represents the importance score of candidate moves. After obtaining the importance scores of candidate moves, this invention embeds a neural symbolic model into the Alpha-Beta pruning search process, such as... Figure 3 The diagram shown is a flowchart of the move-making process based on a combination of neural symbolic scoring and Alpha-Beta pruning.

[0044] Unlike the traditional Alpha-Beta algorithm, which requires frequent calls to manual rule scoring, this invention uses a neural symbolic model to quickly evaluate the local state after a simulated move, thereby reducing the time required for position evaluation and improving the sensitivity of the search process to key patterns.

[0045] During the reasoning phase, a set of candidate moves is generated based on the current board state, prioritizing empty positions within the neighborhood of existing pieces as candidate moves: in, Represents the neighborhood radius. Indicates the candidate placement position Positions of existing pieces The distance between them; for each candidate placement position Extract its local chess piece sequence Input the trained neural symbolic model to obtain the importance score of each move: By embedding the neural symbolic model into the Alpha-Beta pruning search process to obtain the importance score of each candidate move, the recursive search function is defined as follows: Where α and β represent the lower and upper bounds of the search interval, respectively, the search depth is d, and the current player is t; in the non-terminating state, a recursive search is performed based on the candidate move set, and pruning is performed according to the Alpha-Beta condition: in, This indicates the position of the new candidate piece after executing the candidate piece move. Indicates the opposing party; Used to update the lower bound of the search. When satisfied When this happens, stop the subsequent search on the current branch; The candidate move with the highest search score is selected as the machine's actual move: in, Let w be the w-th candidate move, and N be the number of candidate moves generated. To find the candidate position that maximizes the Alpha-Beta search score from the entire set of candidate moves. .

[0046] The above S1 to S6 describe the tightly coupled implementation of the present invention based on the neural symbolic model.

[0047] To address the problem that traditional rule-based Gomoku algorithms require traversing a large number of candidate move positions and judging and scoring the moves one by one, resulting in long reasoning time and high computational cost, this invention constructs a neural symbolic model to transform the move pattern recognition rules and move importance judgment rules into trainable logical constraints. It then uses the neural symbolic network to quickly reason about the four-directional local features of candidate move points, thereby avoiding the need to rely entirely on manual rules to repeatedly calculate all possible positions, shortening the position evaluation time, and improving the efficiency of move decision-making.

[0048] To address the issues of long training time, numerous training iterations, reliance on large-scale game records, and insufficient rule consistency in single neural network methods, this invention introduces a Gomoku (Five-in-a-Row) pattern knowledge base and symbolic axiom constraints during the training process. This allows the model to learn the correspondence between patterns such as "live two," "sleeping two," "live three," "sleeping three," "rushing four," "live four," and "connected five" and the importance of moves, based on a limited number of simulated game samples. Through neural symbolic constraint training, the model not only learns the data distribution but is also constrained by pattern logic and scoring rules, thereby reducing data requirements and training costs.

[0049] To address the issues of insufficient candidate move selection and inaccurate identification of key offensive and defensive positions in complex Gomoku (Five-in-a-Row) games, this invention first utilizes a neural symbolic model to identify the patterns and importance of candidate moves during the inference phase. Then, this scoring result is embedded into an Alpha-Beta pruning search process for candidate move ranking, rapid position evaluation, and pruning decisions. As a result, the system prioritizes searching for high-value moves, reduces the expansion of low-value branches, and enables the search process to simultaneously possess the pattern-aware capabilities of neural networks and the logical constraints of symbolic rules.

Claims

1. A method for human-computer Gomoku (Five in a Row) based on neural symbols, characterized in that, A simulated Gomoku (Five-in-a-Row) game environment is constructed and local piece sequences are generated. A pattern recognition and move scoring dataset is built using these local piece sequences. A Gomoku pattern knowledge base and move importance constraint rules are established. During the training phase, the pattern recognition and move scoring datasets are used to constrain the binary pattern recognition predicate and the pattern recognition network through the Gomoku pattern knowledge base, maximizing the satisfaction of the pattern recognition network with the Gomoku pattern knowledge base. The move scoring network is constrained using move importance constraint rules. During the inference phase, the pattern recognition network and the move scoring network are combined to form a neural symbolic model. Based on the current game state, local features of candidate move positions are extracted, and the move importance score is output. The optimal move position is then selected through Alpha-Beta pruning.

2. The method for human-computer Gomoku based on neural symbols according to claim 1, characterized in that, The specific steps for constructing a simulated Gomoku (Five in a Row) game environment and generating local piece sequences are as follows: Construct a simulation environment for the Gomoku (Five in a Row) board and pieces; the board state is represented as a two-dimensional matrix: Where M represents the size of the chessboard. This indicates that the chessboard position is empty. This indicates that the position on the chessboard belongs to the black piece. This indicates that the position on the chessboard belongs to the white piece; The process of placing pieces is recorded based on a simulation environment, and the state of the game is updated in real time to a two-dimensional matrix. For each valid piece, a local sequence of pieces with a length of nine is recorded in four directions: horizontal, vertical, main diagonal, and secondary diagonal, with the piece's position coordinates as the center. Let the four directions be horizontal, vertical, main diagonal, and secondary diagonal. Then, in the i-th direction, the candidate placement position is... chess piece state sequence for: Wherein, the coordinates of the candidate placement position p are , For the position transformation corresponding to the i-th direction, This represents the state of the first piece in the i-th direction, and the states of the pieces in the nine positions are recorded sequentially. This indicates the state of the piece at the candidate placement position p; This represents the state of the second piece in the i-th direction; This represents the state of the ninth piece in the i-th direction; This yields the local chess piece sequence for the candidate move position p. It is used to describe the continuous piece relationships, empty space distribution, and blocking status of candidate moves in four directions. It is expressed as follows: in, It is a horizontal sequence of chess piece states. It is a vertical sequence of chess piece states. The sequence of chess piece states along the main diagonal. This is the sequence of chess piece states on the secondary diagonal.

3. The method for human-computer Gomoku based on neural symbols according to claim 1, characterized in that, The construction of the chess pattern recognition and move scoring dataset is specifically as follows: For each candidate move position's local piece sequence, identify the corresponding move type according to the rules of Gomoku; the set of move type categories is defined as: in, These correspond to seven types of chess patterns: five-in-a-row, four-in-a-row, four-in-a-row, three ... two-in-a-row, and two-in-a-row. This indicates that there is no valid chess pattern; Candidate move positions Four-directional chess pattern category label sequence Defined as: in, It is a horizontal chess pattern category. The vertical chess pattern category. The main diagonal chess pattern category This is a chess pattern category for the secondary diagonal; Let the candidate move positions be set The chess pattern counting vector is These correspond to the number of occurrences of seven types of chess patterns—five-in-a-row, four-in-a-row, four-in-a-row, three ... two-in-a-row, and two-in-a-row—in the four directions, respectively. Based on the principles of Gomoku (Five in a Row), we perform an equivalent transformation of two four-in-a-row combinations, equating two four-in-a-row combinations to a single live four-in-a-row. The pattern counting vector is then preprocessed as follows: in, This is an indicator function that takes the value when the condition is true. The quotient of dividing by 2 is 0 if it is not true. The number of times the equivalent four-in-a-row pattern appears in the four directions; Candidate move positions Target Importance Score The calculation formula is: in, For the remaining cases, the segmented scoring items for the three-in-a-row pattern are defined as follows: The local piece sequence for each candidate move position p. The corresponding chess pattern category label sequence And the target importance score of the candidate move position. By binding and combining individual candidate moves as independent sample units, a chess pattern recognition and move scoring dataset S is constructed: S 。 4. The method for human-computer Gomoku based on neural symbols according to claim 1, characterized in that, The Gomoku (Five in a Row) pattern knowledge base contains 8 axioms, covering 8 types of patterns: consecutive five, live four, rush four, live three, sleeping three, live two, sleeping two, and no valid pattern. During the training process, the pattern recognition network is constrained to learn the pattern recognition rules. Suppose a binary chess pattern recognition predicate Represents a local chess piece sequence Belongs to the chess type category The output truth value range is ; Let variables The domains of discourse are all local chess piece sequences labeled with the corresponding categories in the chess pattern recognition and move scoring datasets, respectively. The eight axioms are: This indicates that all local piece sequences marked as a five-in-a-row satisfy the recognition predicate for the five-in-a-row pattern; This indicates that all local piece sequences labeled as "live four" satisfy the recognition predicate for the live four pattern; This indicates that all local piece sequences marked as "Four-in-a-Row" satisfy the recognition predicate of the Four-in-a-Row pattern; This indicates that all local piece sequences labeled as "live three" satisfy the predicate for recognizing live three patterns; This indicates that all local piece sequences labeled as Sleeping Three satisfy the recognition predicate of Sleeping Three pattern; This indicates that all local piece sequences marked as "live two" satisfy the predicate for recognizing "live two" patterns. This indicates that all local piece sequences labeled as Sleeping Two satisfy the recognition predicate of Sleeping Two pattern; This indicates that all local piece sequences marked as having no valid pattern satisfy the identification predicate of having no valid pattern; The above axioms hold simultaneously through logical conjunction, forming a Gomoku (Five in a Row) pattern knowledge base. This knowledge base supervises and constrains the pattern recognition network, driving iterative optimization of the neural network parameters at the predicate level, thereby enabling the recognition of various patterns. The importance constraint rule for the move is: for candidate move positions Target Importance Score Establish scoring consistency constraints: in, This is a smooth equality predicate used to measure the closeness between the predicted importance score and the target importance score. For the scoring function of the importance of a move, This is the sensitivity coefficient for scoring errors. To prevent numerical instability of constants, exp is an exponential function.

5. The method for human-computer Gomoku based on neural symbols according to claim 1, characterized in that, The neural symbol model includes a chess pattern recognition network and a move scoring network. During the training process of the neural symbol model, a three-layer architecture of multilayer perceptron, log-probability-predicate conversion adaptation module, and satisfaction aggregation is adopted. In the chess pattern recognition network, a multilayer perceptron (MLP) is constructed as the bottom-level computational module to perform sequence feature extraction and classification score calculation. The MLP consists of multiple linear layers connected in series, with layer dimensions of 9, 16, 16, 64, 16, and 8 respectively. The input is a one-dimensional local chess piece sequence of length 9. The output is an 8-dimensional unnormalized classification log odds vector. ; in Trainable parameters for a multilayer perceptron for chess pattern recognition; Except for the last output layer, all linear layers are followed by the ELU activation function; in training mode, a random deactivation mechanism is enabled for regularization with a dropout rate of 0.2, while in inference mode it is disabled; The 8-dimensional unnormalized classification log odds vector is input to the log odds-predicate conversion adapter module to generate the true probability values ​​in the [0,1] interval; For the eight types of chess moves, an 8-dimensional one-hot floating-point vector encoding is used to define the chess move category constant. , These correspond to eight categories: five consecutive moves, four live moves, four rush moves, three live moves, three sleeping moves, two live moves, two sleeping moves, and no effective moves. The float32 data type is used as the label input for the binary moves recognition predicate, which is used to extract the membership truth value of the corresponding category from the 8-dimensional unnormalized classification log probability vector. The 8-dimensional unnormalized classification log odds vector is normalized using the Softmax function to obtain the probability distribution vectors of the 8 chess patterns. The calculation formula is: in, This represents the probability value of the local piece sequence in this direction belonging to the e-type chess pattern. This represents the log-probability of class e chess patterns corresponding to the local piece sequence in that direction. This represents the j-th class log odds in the class log odds vector; The obtained probability distribution vector is compared with the chess pattern category constant. Perform element-wise multiplication and summation along the feature dimension: in, The fuzzy truth value corresponding to the binary chess pattern recognition predicate is constrained to the interval [0,1] and is used to represent the local chess piece sequence. Belongs to the corresponding chess type category The degree of membership; Let be the probability distribution vector of the 8 types of chess patterns. Category constants for each chess type ; Define a universal quantifier for chess pattern recognition, and use a power-mean error operator with an aggregation order of 2 as the fuzzy aggregation operator; the formula for calculating the truth value of a single axiom after universal quantification is as follows: in, Representing the Local chess piece sequences in each direction; In the chess pattern recognition network, universal quantifiers are applied to the sample sets of 8 chess patterns in the chess pattern recognition and move scoring datasets respectively. The axiom satisfaction degree of each sample being correctly identified as the corresponding chess pattern is calculated one by one, and 8 independent single axiom truth values ​​are output. Define the chess pattern recognition satisfaction aggregation operator The truth values ​​of multiple independent logical axioms are aggregated into a global scalar, which serves as the result of the satisfaction aggregation of the chess pattern recognition network. The calculation formula is as follows: in For the total number of axioms, Let g be the truth value of the g-th chess pattern recognition axiom.

6. The method for human-computer Gomoku based on neural symbols according to claim 5, characterized in that, In the aforementioned move scoring network, a multilayer perceptron is constructed to establish a nonlinear mapping relationship between the four-directional move pattern features and the target importance score. The input is a classification log probability vector with shape [batch, 4, 8] output from the move pattern recognition network. During forward computation, the classification log probability vector is flattened along the feature dimension to a one-dimensional feature vector of shape [batch, 32]. Feature transformation is performed through multiple linear layers, with layer dimensions set to 32, 64, 32, 16, and 1 respectively. Except for the last output layer, all linear layers are followed by an ELU activation function to introduce nonlinearity. The final output is a move importance score with shape [B, 1]. The overall mapping relationship is expressed as follows: in, For the nonlinear mapping function corresponding to the multilayer perceptron for move scoring, [the function is missing here]. The predicted score for the candidate position output by the move scoring network; Define universal quantifiers for scoring tasks, and use a penalized error mean operator with an order parameter of 2 as a fuzzy aggregation operator to aggregate the truth values ​​of smooth and equal predicates for all samples in a batch, thereby obtaining the overall satisfaction of a single universal axiom; define a satisfaction aggregation operator for the scoring of moves. As the result of the satisfaction aggregation of the move-based rating network, the calculation formula is as follows: in, The total number of samples within the batch. For the first The truth value of the smooth equality predicate for each sample. For the first The importance score of each sample's move. For the first The true value of each sample.

7. The method for human-computer Gomoku based on neural symbols according to claim 1, characterized in that, A neural symbolic model is constructed by combining a chess pattern recognition network and a move scoring network; during training, the training objective is to maximize the chess pattern recognition satisfaction aggregation operator. Aggregation operator for satisfaction with move ranking The joint loss function is defined as follows: in, These are the weighting coefficients for the scoring constraints; During training, the satisfaction aggregation results, pattern recognition accuracy, root mean square error of scoring, and mean absolute error of scoring of the pattern recognition network and the move scoring network are periodically calculated, and a comprehensive evaluation index is constructed: in, This indicates the accuracy rate of chess pattern recognition. This represents the root mean square error of the score. This represents the mean absolute error of the scores. The weighting coefficients are used; when the comprehensive evaluation index Q is higher than the historical best value, the current model weights are saved as the optimal neural symbolic model.

8. The method for human-computer Gomoku based on neural symbols according to claim 1, characterized in that, During the reasoning phase, a set of candidate moves is generated based on the current board state, prioritizing empty positions within the neighborhood of existing pieces as candidate moves: in, Represents the neighborhood radius. Indicates the candidate placement position Positions of existing pieces The distance between them; for each candidate placement position Extract its local chess piece sequence Input the trained neural symbolic model to obtain the importance score of each move: By embedding the neural symbolic model into the Alpha-Beta pruning search process to obtain the importance score of each candidate move, the recursive search function is defined as follows: Where α and β represent the lower and upper bounds of the search interval, respectively, the search depth is d, and the current player is t; in the non-terminating state, a recursive search is performed based on the candidate move set, and pruning is performed according to the Alpha-Beta condition: in, This indicates the position of the new candidate piece after executing the candidate piece move. Indicates the opposing party; Used to update the lower bound of the search. When satisfied When this happens, stop the subsequent search on the current branch; The candidate move with the highest search score is selected as the machine's actual move: in, Let w be the w-th candidate move, and N be the number of candidate moves generated. To find the candidate position that maximizes the Alpha-Beta search score from the entire set of candidate moves. .

Citation Information

Patent Citations

  • Intelligent gobang robot based on SCARA parallel mechanical arm

    CN116117776A

  • Gobang man-machine playing equipment based on machine vision

    CN119139682A

  • A method and device for generating and extracting steganographic information, equipment and storage medium

    CN120180479B

  • Method for judging balance breakers and chess shape attributes of gobang within constant time

    CN110275739A

  • Gobang playing method and robot based on deep learning

    CN115958594A