A chess moving path planning method based on a chess display platform

By using the path planning method of the chess display platform, combined with image acquisition and search algorithms to optimize the movement path of chess pieces, the adaptability and accuracy problems of path planning in chess scenarios are solved, and efficient and intuitive chess piece movement display is achieved, which is suitable for chess teaching and online competitions.

CN121640142BActive Publication Date: 2026-07-14GUANGZHOU CITY UNIV OF TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGZHOU CITY UNIV OF TECH
Filing Date
2025-11-21
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing chess path planning algorithms suffer from insufficient adaptability, accuracy, and efficiency in chess scenarios. Traditional algorithms fail to effectively optimize the movement paths of chess pieces, and visual processing is easily affected by lighting and grid lines, resulting in large positioning errors and rigid obstacle handling.

Method used

A path planning method based on a chess display platform is adopted. The movement path of chess pieces is optimized through image acquisition, preprocessing, grid model construction and search algorithm. Visual processing technology is combined to improve positioning accuracy. An evaluation function is incorporated into the chess move logic to generate the optimal path and display it visually.

Benefits of technology

It improves the scenario adaptability and user experience of path planning, reduces inflection points, and improves the positioning accuracy and planning efficiency of chess pieces. It is suitable for chess teaching, online tournament live streaming and intelligent robot interaction, meeting the comprehensive needs of high precision and high efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121640142B_ABST
    Figure CN121640142B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of chess moving path planning, and particularly relates to a chess moving path planning method based on a chess display platform, which comprises the following steps: acquiring a current image containing a complete chessboard and all chessmen; sequentially performing chessboard region positioning, chessmen segmentation, attribute recognition and coordinate mapping on the current image to obtain initial position coordinates and attribute information of each chessman; acquiring starting position coordinates and destination position coordinates of a target chessman through user interaction instructions or system preset rules; constructing a two-dimensional grid model based on the grid point distribution of the chessboard and classifying the node categories of the grid model; calculating the moving path of the target chessman by using a search algorithm to generate an optimal path list; if the optimal path list contains obstacle nodes, an obstacle moving path list is additionally generated; and presenting the optimal path in a visual form. The present application can solve the technical problems of adaptability, accuracy and efficiency of traditional path planning algorithms in the chess scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of chess movement path planning technology, and in particular to a chess movement path planning method based on a chess display platform. Background Technology

[0002] In scenarios such as chess teaching, online tournament live streaming, and intelligent chess robot interaction, chess display platforms often need to achieve automatic planning and visualization of chess piece movement paths to improve user experience or assist in functional implementation. Currently, mainstream path planning largely relies on traditional methods. The algorithm, specifically evaluating the function f(n) = g(n) + h(n), has significant limitations in its suitability for chess scenarios: on the one hand, The algorithm only focuses on "shortest distance" as its core objective and does not optimize for the chess move logic of "moving along straight lines as much as possible." Therefore, the planned path often contains numerous inflection points, such as... Figure 2 As shown in (b), it does not conform to the user's intuitive understanding; on the other hand, the traditional algorithm's mechanism for handling obstacles (non-target pieces) is rigid. When the path is blocked by obstacles, it either cannot output a feasible path or needs to calculate the number of steps the obstacle moves in a complex way, resulting in low planning efficiency and poor scene adaptability.

[0003] Meanwhile, existing visual processing methods mostly employ simple color recognition technology, which is susceptible to interference from lighting, shadows, and chessboard grid lines. The positioning error of chess pieces often exceeds two grid points, and attribute recognition easily confuses similar pieces such as "General / King" and "Advisor / Guard," leading to incorrect obstacle labeling in subsequent grid model construction and further affecting the accuracy of path planning. Furthermore, most solutions lack customized designs for the fixed 9 columns and 10 rows of a chessboard, resulting in insufficient adaptability of general road network models to the chessboard scenario. This makes it difficult to meet the platform's comprehensive requirements for path planning accuracy, efficiency, and visualization. Therefore, a dedicated method integrating high-precision visual processing and scenario-based path planning is urgently needed. Summary of the Invention

[0004] The purpose of this invention is to propose a chess movement path planning method based on a chess display platform, which can realize the automatic planning and visualization of chess piece movement paths. It is applicable to chess teaching systems, online tournament live streaming platforms, intelligent chess robot interaction systems and other scenarios, and solves the technical problems of adaptability, accuracy and efficiency of traditional path planning algorithms in chess scenarios.

[0005] To achieve this objective, the present invention adopts the following technical solution:

[0006] A chess move path planning method based on a chess display platform includes the following steps:

[0007] S1: Image acquisition, obtain the current image containing the complete chessboard and all chess pieces;

[0008] S2: Image preprocessing and information extraction, the current image is sequentially processed by chessboard area localization, chess piece segmentation, attribute recognition and coordinate mapping to obtain the initial position coordinates and attribute information of each chess piece;

[0009] S3: Target parameters are determined by obtaining the starting and destination coordinates of the target piece through user interaction commands or system preset rules.

[0010] S4: Mesh model construction. A two-dimensional mesh model is constructed based on the grid distribution of the chessboard. The mesh model has 9 columns and 10 rows, with column numbers ranging from 1 to 9 and row numbers ranging from 1 to 10. The nodes of the mesh model are classified as follows: the starting position coordinates of the target piece are assigned to the starting node in the mesh model, the destination position coordinates of the target piece are assigned to the ending node in the mesh model, the coordinates of other pieces besides the target piece are labeled as obstacle nodes in the mesh model, and the coordinates of pieces without pieces are labeled as blank nodes in the mesh model.

[0011] S5: Path planning and display, using... The search algorithm calculates the movement path of the target piece and generates a list of optimal paths. If there are obstacle nodes in the optimal path list, an additional list of obstacle movement paths is generated. The optimal paths are then presented in a visual format.

[0012] Preferably, step S2 includes the following sub-steps:

[0013] S21: Chessboard area localization. The Canny edge detection algorithm is used to extract the edge contours in the image. Small-sized interference contours are filtered out by the contour perimeter threshold. Polygon approximation is performed on the remaining contours. The chessboard contour is selected based on three features: the number of vertices is 4, the area of ​​the region conforms to the standard chessboard size range, and the angle between adjacent sides is close to 90°. The coordinates of the four corner vertices of the chessboard are accurately located. The tilted chessboard is corrected into an orthophoto image through perspective transformation.

[0014] S22: Chess piece segmentation and attribute recognition. A dual-convolutional kernel morphological filter is used to process the corrected chessboard image. The dual convolutional kernel includes a horizontal convolutional kernel and a vertical convolutional kernel. The horizontal convolutional kernel size is set to 1×7, and the vertical convolutional kernel size is set to 7×1. Horizontal and vertical grid lines are filtered out. Chess pieces are separated from the background based on grayscale threshold segmentation. The grayscale threshold is adaptively determined using the Otsu algorithm to extract the bounding rectangle region of each chess piece. The chess piece region image is input into a pre-trained CNN model. The CNN model structure is an improved version of LeNet-5, with an input size of 128×128 and an output of 14 categories of chess piece attributes, completing the chess piece attribute classification.

[0015] S23: Coordinate mapping. Establish an image coordinate system with the bottom left corner of the corrected chessboard image as the origin. The positive x-axis points horizontally to the right, and the positive y-axis points vertically upwards. The x-axis corresponds to the chessboard column number, and the y-axis corresponds to the chessboard row number. Calculate the center coordinates of the bounding rectangle of each piece. Based on the number of chessboard grid points, convert the image coordinate system to a grid coordinate system to obtain the corresponding node coordinates (x, y, ...) of the piece in the grid model. grid y grid ), the node coordinates x grid For column number, y grid The line number.

[0016] Preferably, in step S5 The evaluation function for the search algorithm is:

[0017] f(n)=g(n)+h(n)+αt(n)+βb(n);

[0018] Where g(n) is the actual movement cost from the starting node to the current node n, and the movement cost between adjacent nodes is fixed at 1;

[0019] h(n) is the estimated cost from the current node n to the terminal node, calculated using Manhattan distance, and the formula is h(n) = |x grid -x target |+|y grid -y target |,x grid y is the column number of the grid coordinates of the current node. grid x is the grid coordinate row number of the current node. target y is the column number of the grid coordinates of the terminating node. target The grid coordinate row number of the terminating node;

[0020] t(n) is the turning cost. When the movement direction of the neighboring node and the current node is different from the movement direction of the current node and its parent node, t(n) is 1, otherwise it is 0.

[0021] b(n) is the cost of moving obstacles; it is 0 when there are no obstacles to move and 1 when obstacles need to be moved.

[0022] α is the turning cost weight, and β is the moving obstacle cost weight.

[0023] Preferably, in step S5 The turning cost weight α and the moving obstacle cost weight β in the search algorithm evaluation function can be dynamically adjusted according to path planning requirements:

[0024] If the shortest path is prioritized and moving obstacles are allowed, set β to a smaller value and α to a relatively larger value.

[0025] If prioritizing avoiding moving obstacles and accepting path turns, set β to a larger value and α to a relatively smaller value.

[0026] Preferably, in step S5 The execution process of the search algorithm includes the following sub-steps:

[0027] S51: Algorithm initialization, creating an open list and a closed list. The open list stores nodes to be explored, and the closed list stores nodes whose optimal paths have been determined. Add the starting node to the closed list. Traverse the four neighboring nodes of the starting node. The neighboring nodes are in the directions of up, down, left, and right. The row number of the up neighboring node is incremented by 1, the row number of the down neighboring node is decremented by 1, the column number of the left neighboring node is decremented by 1, and the column number of the right neighboring node is incremented by 1.

[0028] If a neighboring node exceeds the boundary of the mesh model, skip it directly;

[0029] Add neighboring nodes to the open list and set the starting node as its parent node. Calculate the f(n) of neighboring nodes based on the evaluation function f(n)=g(n)+h(n)+αt(n)+βb(n).

[0030] S52: Node selection and target determination. Extract the node with the smallest f(n) value from the open list as the current node. If the coordinates of the current node are the same as the coordinates of the termination node, perform path backtracking. Trace back to the starting node through the parent node pointer of the node. Organize the nodes in the tracing process in the order of "starting node → node → termination node" to generate the optimal path list. If there are nodes of the obstacle type in the optimal path list, generate an additional obstacle movement path list and the algorithm terminates.

[0031] S53: Neighbor node processing: Move the current node from the open list to the closed list, and traverse the four neighboring nodes of the current node. The direction of the neighboring nodes is up, down, left, and right. The row number of the upper neighboring node is +1, the row number of the lower neighboring node is -1, the column number of the left neighboring node is -1, and the column number of the right neighboring node is +1.

[0032] If a neighboring node exceeds the boundary of the mesh model, skip it directly;

[0033] If the neighboring node is already in the closed list, skip it directly;

[0034] If the neighboring node is not in the open list, calculate f(n) based on the evaluation function f(n)=g(n)+h(n)+αt(n)+βb(n), add the neighboring node to the open list and set the current node as its parent node;

[0035] If the neighboring node is already in the open list, calculate the f(n) value of reaching the neighboring node through the current node. If this value is less than the current f(n) value of the neighboring node, update the f(n) parameter of the neighboring node and the parent node.

[0036] S55: Path Output and Display. The optimal path list and obstacle movement path list obtained from the planning are transmitted to the chess display platform. The movement trajectory of the target piece is displayed in the form of "highlighted nodes + arrow lines", and the movement process of the obstacles is displayed simultaneously.

[0037] Preferably, in step S54, the process of generating the obstacle movement path list is as follows: the target node for obstacle movement among the obstacle nodes is selected as a blank node in the mesh model. If there is no blank node, the obstacle node is used as the current node and step S53 is repeated. The node with the smallest f(n) value is selected as the target node for obstacle movement among the obstacle nodes.

[0038] Preferably, the optimal path visualization in step S5 is as follows: the optimal path is marked with a first color, the starting node in the optimal path is marked with a first color and the character "start", the ending node is marked with a second color and the character "end", the inflection point node is marked with a third color, the obstacle node that needs to be moved is marked with a fourth color, and the movement trajectory of the obstacle is displayed as a dashed arrow of a fifth color.

[0039] One of the above technical solutions has the following beneficial effects:

[0040] (1) Path planning is more in line with the chess scenario, improving the user's intuitive experience compared to traditional methods. The algorithm outputs a multi-inflection path. After incorporating chess move logic into the search algorithm, the planned path is closer to the straight-line movement habits of human chess players, with fewer turning points and clearer logic. Whether it is a step demonstration in chess teaching or a path preview in online tournament live broadcast, it can help users quickly understand the move intention, significantly improving scenario adaptability and user experience.

[0041] (2) Improved visual processing accuracy ensures accurate path planning. Through layered image preprocessing and attribute recognition technology, interference from lighting, shadows and grid lines is effectively avoided. The positioning error of chess pieces is controlled within a single grid point, and the accuracy of similar chess piece recognition is greatly improved. This solves the path planning deviation problem caused by "error in obstacle labeling" from the source. Combined with the chess-specific grid model, the accurate correspondence between physical location and digital model is further ensured, providing a reliable data foundation for path planning.

[0042] (3) More flexible obstacle handling, improving scene adaptability and planning efficiency. For scenarios where the path is blocked, the optimal path of the target piece and the list of obstacle movement paths can be generated simultaneously without complex calculations. This not only solves the dilemma of "no solution" in traditional algorithms, but also reduces the computational complexity of obstacle handling through "minimum number of moves", greatly improving planning efficiency. It is suitable for multiple scenarios such as chess teaching (obstacle movement assistance in explaining rules), intelligent robot interaction (automatic avoidance of pieces), and online competitions (path prediction and display), with stronger scene coverage.

[0043] (4) Customized design enhances the specialization of the solution and meets comprehensive needs. A grid model with a fixed specification of 9 columns and 10 rows for chess is customized to avoid the redundancy of the general road network model and make the path planning more focused on the core needs of the chess scene. At the same time, it realizes the integrated design of "high-precision visual extraction - efficient path planning - visualization display", which not only meets the platform's technical requirements for the accuracy and efficiency of path planning, but also enhances the user interaction experience through visualization, fully meeting the comprehensive needs of the chess display platform. Attached Figure Description

[0044] Figure 1 This is a flowchart illustrating a chess movement path planning method based on a chess display platform according to the present invention.

[0045] Figure 2 In this invention Search algorithm path planning and traditional Comparison of path planning algorithms in obstacle-free scenarios;

[0046] Figure 3 In this invention Search algorithm path planning and traditional Comparison of path planning algorithms in scenarios with obstacles; Detailed Implementation

[0047] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0048] A chess move path planning method based on a chess display platform includes the following steps:

[0049] S1: Image acquisition, obtain the current image containing the complete chessboard and all chess pieces;

[0050] S2: Image preprocessing and information extraction, the current image is sequentially processed by chessboard area localization, chess piece segmentation, attribute recognition and coordinate mapping to obtain the initial position coordinates and attribute information of each chess piece;

[0051] S3: Target parameters are determined by obtaining the starting and destination coordinates of the target piece through user interaction commands or system preset rules.

[0052] S4: Mesh model construction. A two-dimensional mesh model is constructed based on the grid distribution of the chessboard. The mesh model has 9 columns and 10 rows, with column numbers ranging from 1 to 9 and row numbers ranging from 1 to 10. The nodes of the mesh model are classified as follows: the starting position coordinates of the target piece are assigned to the starting node in the mesh model, the destination position coordinates of the target piece are assigned to the ending node in the mesh model, the coordinates of other pieces besides the target piece are labeled as obstacle nodes in the mesh model, and the coordinates of pieces without pieces are labeled as blank nodes in the mesh model.

[0053] S5: Path planning and display, using... The search algorithm calculates the movement path of the target piece and generates a list of optimal paths. If there are obstacle nodes in the optimal path list, an additional list of obstacle movement paths is generated. The optimal paths are then presented in a visual format.

[0054] like Figure 1 As shown, the technical solution of this invention constructs a complete technical framework for chess move path planning through five core steps: image acquisition, image preprocessing and information extraction, target parameter determination, grid model construction, and path planning and display. The logical connection between each step is as follows:

[0055] Image Acquisition (S1): Capture an image containing the complete chessboard and all pieces using an image acquisition device (such as a USB high-definition camera or industrial camera) to provide raw data for subsequent visual processing. The core is to ensure that the image does not lack key information (such as chessboard boundaries and piece outlines) to avoid subsequent positioning failures due to image incompleteness.

[0056] Image preprocessing and information extraction (S2): This addresses the problem of traditional color recognition being easily affected by lighting and shadows. Through layered processing of "chessboard area positioning → chess piece segmentation → attribute recognition", it accurately distinguishes the chessboard boundary and chess piece outlines, overcoming the attribute recognition problem of similar chess pieces such as "general / king" and "advisor / guard". Furthermore, through a coordinate mapping mechanism, the positions of chess pieces on the physical chessboard are converted into digital coordinates, providing high-precision data support for subsequent mesh modeling and ensuring that the error between the initial position and attribute information of the chess pieces is controlled within a single grid point.

[0057] Target parameter determination (S3): The "starting node-ending node" coordinates of the target piece are clearly defined through user interaction or system presets, defining the core objective of path planning, and simultaneously verifying the validity of the parameters: The obtained starting position coordinates (x...) are... start y start ) and target location coordinates (x end y end ) Perform validity verification. If the coordinates exceed the range of the mesh model (x grid <1 or x grid >9, y grid <1 or ygrid If the value is greater than 10, the system will prompt "Invalid parameter, please re-enter"; after successful verification, record the grid node (starting node) corresponding to the starting position coordinates and the grid node (ending node) corresponding to the destination position coordinates to avoid invalid planning.

[0058] Mesh Model Construction (S4): The physical chessboard is abstracted into a two-dimensional mesh with 9 columns and 10 rows. The mesh nodes are classified into "starting nodes, ending nodes, obstacle nodes, and blank nodes". Essentially, the chess scene is transformed into a "road network model" that can be recognized by the path planning algorithm. The obstacle nodes correspond to non-target pieces, and the blank nodes are passable areas. This not only adapts to the fixed structure of the chessboard, but also clearly defines the movable area and the blocking area, solving the problem of insufficient adaptability of the general road network model to the chess scene.

[0059] Path planning and visualization (S5): using the optimized version Search algorithms that break through traditional... Overcoming the limitation of algorithms that "only pursue the shortest distance," the algorithm incorporates the chess move logic of "moving along a straight line as much as possible" into the path evaluation function, prioritizing the search for straight lines or paths with low inflection points to make the planning results consistent with the user's intuitive understanding. At the same time, for scenarios with obstacles, a two-layer planning mechanism of "main path + obstacle auxiliary path" is constructed: if there are obstacle nodes in the optimal path, the algorithm will simultaneously calculate the minimum number of moves for the obstacle and a reasonable movement path (such as moving to the nearest empty node), generating a list of obstacle movement paths, avoiding the defects of traditional algorithms that are "unsolvable or computationally complex". Finally, the optimal path (including obstacle movement guidance) is presented intuitively through visualization technology, completing the "planning-display" closed loop.

[0060] To further explain, step S2 includes the following sub-steps:

[0061] S21: Chessboard area localization. The Canny edge detection algorithm is used to extract the edge contours in the image. Small-sized interference contours are filtered out by the contour perimeter threshold. Polygon approximation is performed on the remaining contours. The chessboard contour is selected based on three features: the number of vertices is 4, the area of ​​the region conforms to the standard chessboard size range, and the angle between adjacent sides is close to 90°. The coordinates of the four corner vertices of the chessboard are accurately located. The tilted chessboard is corrected into an orthophoto image through perspective transformation.

[0062] S22: Chess piece segmentation and attribute recognition. A dual-convolutional kernel morphological filter is used to process the corrected chessboard image. The dual convolutional kernel includes a horizontal convolutional kernel and a vertical convolutional kernel. The horizontal convolutional kernel size is set to 1×7, and the vertical convolutional kernel size is set to 7×1. Horizontal and vertical grid lines are filtered out. Chess pieces are separated from the background based on grayscale threshold segmentation. The grayscale threshold is adaptively determined using the Otsu algorithm to extract the bounding rectangle region of each chess piece. The chess piece region image is input into a pre-trained CNN model. The CNN model structure is an improved version of LeNet-5, with an input size of 128×128 and an output of 14 categories of chess piece attributes, completing the chess piece attribute classification.

[0063] S23: Coordinate mapping. Establish an image coordinate system with the bottom left corner of the corrected chessboard image as the origin. The positive x-axis points horizontally to the right, and the positive y-axis points vertically upwards. The x-axis corresponds to the chessboard column number, and the y-axis corresponds to the chessboard row number. Calculate the center coordinates of the bounding rectangle of each piece. Based on the number of chessboard grid points, convert the image coordinate system to a grid coordinate system to obtain the corresponding node coordinates (x, y, ...) of the piece in the grid model. grid y grid ), the node coordinates x grid For column number, y grid The line number.

[0064] Steps S21-S23 refine step S2: image preprocessing and information extraction, achieving high-precision information extraction through step-by-step techniques.

[0065] Chessboard region localization (S21): First, image edges are extracted using Canny edge detection, and Gaussian filtering is used for noise reduction to reduce background interference (such as desktop texture, lighting and shadows). Then, small-sized interference (such as dust, chess piece reflections) is filtered out using the "contour perimeter threshold". The remaining contours are approximated by polygons to retain contours that are close to rectangles. Finally, the chessboard contour is locked based on three features: "4 vertices, area conforms to a standard chessboard, and the included angle between adjacent sides is close to 90°". The tilted chessboard is corrected to an orthophoto image through perspective transformation to ensure the coordinate accuracy of subsequent chess piece localization.

[0066] Piece Segmentation and Attribute Recognition (S22): A dual-kernel morphological filter with a 1×7 horizontal convolutional kernel and a 7×1 vertical convolutional kernel is used to specifically remove the horizontal and vertical grid lines of the chessboard, avoiding interference from the grid lines in piece contour extraction. The Otsu algorithm is used to adaptively determine the grayscale threshold to achieve binarization segmentation of the pieces (dark) and the background (light), and the bounding rectangle of each piece is extracted. The 128×128 pixel piece image is input into the LeNet-5 improved CNN model. The model extracts the texture features of the pieces through convolutional layers and classifies them through fully connected layers, outputting 14 categories of chess attributes (covering the "General", "Advisor", "Minister", "Horse", "Chariot", "Cannon", "Pawn" in Chinese chess and the corresponding black pieces), thus completing attribute recognition.

[0067] Coordinate Mapping (S23): Establish an image coordinate system with the lower left corner of the corrected chessboard as the origin, with the x-axis corresponding to the chessboard column number and the y-axis corresponding to the row number; calculate the center coordinates of the bounding rectangle of the chess piece, and map the image coordinates to grid coordinates according to the chessboard grid number of "9 columns and 10 rows" (x, y, y). grid For column number, y grid (For row numbers), to achieve the conversion of "image pixel coordinates → path planning grid coordinates".

[0068] To further explain, in step S5 The evaluation function for the search algorithm is:

[0069] f(n)=g(n)+h(n)+αt(n)+βb(n);

[0070] Where g(n) is the actual movement cost from the starting node to the current node n, and the movement cost between adjacent nodes is fixed at 1;

[0071] h(n) is the estimated cost from the current node n to the terminal node, calculated using Manhattan distance, and the formula is h(n) = |x grid -x target |+|y grid -y target |,x grid y is the column number of the grid coordinates of the current node. grid x is the grid coordinate row number of the current node. target y is the column number of the grid coordinates of the terminating node. target The grid coordinate row number of the terminating node;

[0072] t(n) is the turning cost. When the movement direction of the neighboring node and the current node is different from the movement direction of the current node and its parent node, t(n) is 1, otherwise it is 0.

[0073] b(n) is the cost of moving obstacles; it is 0 when there are no obstacles to move and 1 when obstacles need to be moved.

[0074] α is the turning cost weight, and β is the moving obstacle cost weight.

[0075] The evaluation function f(n) = g(n) + h(n) + αt(n) + βb(n) quantifies the comprehensive priority of each node by weighted summation of "actual cost + estimated cost + turning cost + obstacle movement cost". The algorithm prioritizes exploring the node with the smallest f(n) value to ensure the optimal path.

[0076] The calculation logic for each parameter of the evaluation function is as follows:

[0077] g(n): The actual movement cost from the starting node to the current node n. The cost of moving one step to an adjacent node is fixed at 1. This objectively reflects the cost consumed by the path and ensures that the path length is controllable.

[0078] h(n): The estimated cost from the current node n to the terminal node, calculated using Manhattan distance (h(n) = |x grid- x target |+|y grid -y target The Manhattan distance satisfies the admissibility requirement of "not overestimating the actual cost," guiding the algorithm toward the terminal node and avoiding blind exploration.

[0079] t(n): Turning cost, taking only 0 or 1: When the movement direction from the current node to the neighboring node (e.g., up → down) is different from the movement direction from the current node to its parent node (e.g., left → up), t(n) = 1 (marking a turn), otherwise t(n) = 0. This parameter is used to penalize multi-turning paths and guide the algorithm to choose a smooth path.

[0080] b(n): Cost of moving obstacles, taking only 0 or 1: if the current path does not require moving obstacles, b(n) = 0; if obstacles need to be moved, b(n) = 1. This parameter marks the obstacle movement status, providing a basis for subsequent weight adjustments.

[0081] α and β: These are the weights of the turning cost and the obstacle movement cost, respectively, used to balance the priorities of "path smoothing" and "obstacle avoidance".

[0082] To further explain, in step S5 The turning cost weight α and the moving obstacle cost weight β in the search algorithm evaluation function can be dynamically adjusted according to path planning requirements:

[0083] If the shortest path is prioritized and moving obstacles are allowed, set β to a smaller value and α to a relatively larger value.

[0084] If prioritizing avoiding moving obstacles and accepting path turns, set β to a larger value and α to a relatively smaller value.

[0085] Furthermore, The cost weight α and the cost weight β for moving obstacles in the search algorithm's evaluation function can be dynamically adjusted according to path planning requirements, adapting to different scenario needs (such as prioritizing the shortest path in teaching scenarios and prioritizing not moving obstacles in competition scenarios), thus solving the problem of fixed priorities in traditional algorithms.

[0086] Prioritize the shortest path scenario: If you need to display the shortest path (such as explaining the "shortest checkmate path" in chess teaching), set β to a smaller value (such as 5) and α to a larger value (such as 3). In this case, the algorithm pays more attention to g(n)+h(n) (path length) and t(n) (number of turns), and allows moving obstacles to shorten the path.

[0087] In scenarios prioritizing obstacle avoidance: If moving obstacles is the priority and path turns are acceptable (consistent with the logic of regular chess games), β should be set to a value much greater than α. In chess scenarios, extensive experiments have verified that when α is 1 and β is 20, optimal control efficiency can be achieved. Since the maximum Manhattan distance in the chess grid coordinates is 19 (e.g., from (1,1) to (9,10), Manhattan distance = |1-9|+|1-10|=19), β=20 can ensure that the overall cost of "the path involving obstacle movement (b(n)=1, with an additional cost of 20)" is higher than "the longest path without moving obstacles (h(n)=19)", thus forcing the algorithm to prioritize paths without moving obstacles. At the same time, α=1 can effectively filter out the smooth path with the fewest inflection points through the turning cost of t(n)=1.

[0088] To further explain, in step S5 The execution process of the search algorithm includes the following sub-steps:

[0089] S51: Algorithm initialization, creating an open list and a closed list. The open list stores nodes to be explored, and the closed list stores nodes whose optimal paths have been determined. Add the starting node to the closed list. Traverse the four neighboring nodes of the starting node. The neighboring nodes are in the directions of up, down, left, and right. The row number of the up neighboring node is incremented by 1, the row number of the down neighboring node is decremented by 1, the column number of the left neighboring node is decremented by 1, and the column number of the right neighboring node is incremented by 1.

[0090] If a neighboring node exceeds the boundary of the mesh model, skip it directly;

[0091] Add neighboring nodes to the open list and set the starting node as its parent node. Calculate the f(n) of neighboring nodes based on the evaluation function f(n)=g(n)+h(n)+αt(n)+βb(n).

[0092] S52: Node selection and target determination. Extract the node with the smallest f(n) value from the open list as the current node. If the coordinates of the current node are the same as the coordinates of the termination node, perform path backtracking. Trace back to the starting node through the parent node pointer of the node. Organize the nodes in the tracing process in the order of "starting node → node → termination node" to generate the optimal path list. If there are nodes of the obstacle type in the optimal path list, generate an additional obstacle movement path list and the algorithm terminates.

[0093] S53: Neighbor node processing: Move the current node from the open list to the closed list, and traverse the four neighboring nodes of the current node. The direction of the neighboring nodes is up, down, left, and right. The row number of the upper neighboring node is +1, the row number of the lower neighboring node is -1, the column number of the left neighboring node is -1, and the column number of the right neighboring node is +1.

[0094] If a neighboring node exceeds the boundary of the mesh model, skip it directly;

[0095] If the neighboring node is already in the closed list, skip it directly;

[0096] If the neighboring node is not in the open list, calculate f(n) based on the evaluation function f(n)=g(n)+h(n)+αt(n)+βb(n), add the neighboring node to the open list and set the current node as its parent node;

[0097] If the neighboring node is already in the open list, calculate the f(n) value of reaching the neighboring node through the current node. If this value is less than the current f(n) value of the neighboring node, update the f(n) parameter of the neighboring node and the parent node.

[0098] S55: Path Output and Display. The optimal path list and obstacle movement path list obtained from the planning are transmitted to the chess display platform. The movement trajectory of the target piece is displayed in the form of "highlighted nodes + arrow lines", and the movement process of the obstacles is displayed simultaneously.

[0099] Steps S51-S55 refine the algorithm execution flow of step S5, path planning, and clarify it. The specific steps of the search algorithm:

[0100] Algorithm initialization (S51): Create an open list (stores nodes to be explored, implemented using a priority queue, sorted by f(n)) and a closed list (stores nodes with determined optimal paths, implemented using a hash table for fast lookup); add the starting node to the closed list, traverse its four neighboring nodes (up / down / left / right, corresponding to row number ±1, column number ±1), and skip outbound nodes; add valid neighboring nodes to the open list, set the starting node as the parent node, and calculate f(n): g(n)=1 (1 step from the starting node to the neighboring node), h(n) uses Manhattan distance to calculate the estimated cost from the current node n to the terminal node, t(n)=0 (both the starting node and neighboring nodes are without turning), i.e., αt(n)=0, b(n) is sorted by neighboring node category (obstacle = 1, otherwise = 0), βb(n) is the actual calculated value, and the initialization is completed.

[0101] Node selection and target determination (S52): Extract the node with the smallest f(n) from the open list as the current node. If the current node is the termination node, backtrack to the starting node through the parent node pointer and organize the node sequence into an optimal path list. If there are obstacle nodes in the path, trigger obstacle movement path generation, and the algorithm terminates; otherwise, continue exploring. The backtracking mechanism from the starting node to the termination node ensures the generation of a complete path, and obstacle node detection triggers movement path generation, avoiding the traditional... The algorithm overcomes the problem of "failure when the path is blocked" by still being able to output feasible paths in complex, obstructed scenarios, such as... Figure 3 As shown in (b).

[0102] Neighbor node processing (S53): Move the current node from the open list to the closed list, traverse its 4 neighbor nodes, skipping nodes that are out of bounds and nodes in the closed list; if the neighbor node is not in the open list: calculate g(n) (current node g(n) + 1), h(n) (Manhattan distance), t(n) (direction comparison, 1 if different), b(n) (category determination), f(n), add it to the open list and set the current node as the parent node; if the neighbor node is already in the open list: calculate f(n) that can be reached through the current node, if it is smaller, update f(n) and the parent node to ensure that the optimal path is preserved, solve the problems of "path redundancy" and "repeated exploration" in traditional algorithms, and have high planning efficiency.

[0103] Path Output and Display (S55): Display the optimal path list (e.g.) Figure 3 (a), [(1,9),(1,8),(1,7),(1,6),(1,5),(2,5),(3,5),(4,5),(4,4),(4,3)]) and the list of obstacle movement paths (e.g. Figure 3The data (a), [(1,7)→(2,7)]) is transmitted to the platform and then displayed through "highlighted nodes + arrow connections". The movement process of the obstacles is displayed synchronously, and users can intuitively observe the movement trajectory of the pieces and the adjustment process of the obstacles. This solves the problem of the traditional static path display being unintuitive, and is especially suitable for chess teaching and live competition broadcasts.

[0104] To further explain, in step S54, the process of generating the obstacle movement path list is as follows: the target node for obstacle movement among the obstacle nodes is selected first as a blank node in the mesh model. If there is no blank node, the obstacle node is used as the current node and step S53 is repeated. The node with the smallest f(n) value is selected first as the target node for obstacle movement among the obstacle nodes.

[0105] The above definition of the logic for generating the obstacle movement path list is a supplement to the "obstacle handling" step S54:

[0106] Target node priority selection: When generating obstacle movement paths, empty nodes in the mesh model are prioritized as obstacle movement targets because empty nodes have no other pieces and will not generate new obstacles after being moved.

[0107] Handling when there are no blank nodes: If there are no blank nodes in the current scene (such as when the chessboard is densely packed with chess pieces), the obstacle node is used as the current node and step S53 is repeated. The node with the smallest f(n) value is selected from the open list of neighboring nodes as the obstacle movement target to ensure that the overall cost of the new path generated after the obstacle is moved is the lowest.

[0108] To further explain, the specific method of visualizing the optimal path in step S5 is as follows: the optimal path is marked with a first color, the starting node in the optimal path is marked with a first color and the character "start", the ending node is marked with a second color and the character "end", the inflection point node is marked with a third color, the obstacle node that needs to be moved is marked with a fourth color, and the movement trajectory of the obstacle is displayed as a dashed arrow of the fifth color.

[0109] The above defines a visual representation of the optimal path, using multi-color differentiation to improve path identification:

[0110] Path and node annotation:

[0111] The optimal path is marked with the first color (such as green) to clearly indicate the path's direction;

[0112] The starting node is marked with the first color (such as blue) + the "start" character, and the ending node is marked with the second color (such as red) + the "end" character, so as to quickly distinguish the starting and ending nodes of the path;

[0113] Inflection points (nodes where t(n)=1) are marked with a third color (such as pink) to highlight the turning points in the path;

[0114] Obstacle nodes that need to be moved are marked with the fourth color (such as indigo), and the obstacle movement trajectory is marked with a dashed arrow of the fifth color (such as cyan) to indicate the direction of obstacle movement.

[0115] Display Logic: By using color contrast (e.g., green path vs. pink inflection points vs. indigo obstacles) and text labeling, the abstract list of paths is transformed into intuitive visual images. This can be combined with dynamic playback (e.g., flowing arrows) to improve the user's understanding of the path. Figure 2 (a) and Figure 3 As shown in (a).

[0116] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0117] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A chess move path planning method based on a chess display platform, characterized in that, Includes the following steps: S1: Image acquisition, obtain the current image containing the complete chessboard and all chess pieces; S2: Image preprocessing and information extraction, the current image is sequentially processed by chessboard area localization, chess piece segmentation, attribute recognition and coordinate mapping to obtain the initial position coordinates and attribute information of each chess piece; S3: Target parameters are determined by obtaining the starting and destination coordinates of the target piece through user interaction commands or system preset rules. S4: Mesh model construction. A two-dimensional mesh model is constructed based on the grid distribution of the chessboard. The mesh model has 9 columns and 10 rows, with column numbers ranging from 1 to 9 and row numbers ranging from 1 to 10. The nodes of the mesh model are classified as follows: the starting position coordinates of the target piece are assigned to the starting node in the mesh model, the destination position coordinates of the target piece are assigned to the ending node in the mesh model, the coordinates of other pieces besides the target piece are labeled as obstacle nodes in the mesh model, and the coordinates of pieces without pieces are labeled as blank nodes in the mesh model. S5: Path planning and display, using... The search algorithm calculates the movement path of the target piece and generates a list of optimal paths; if there are obstacle nodes in the list of optimal paths, an additional list of obstacle movement paths is generated; the optimal paths are then presented in a visual format. In step S5 The evaluation function for the search algorithm is: f(n)=g(n)+h(n)+αt(n)+βb(n); Where g(n) is the actual movement cost from the starting node to the current node n, and the movement cost between adjacent nodes is fixed at 1; h(n) is the estimated cost from the current node n to the terminal node, calculated using Manhattan distance, and the formula is h(n) = |x grid -x target |+|y grid -y target |,x grid y is the column number of the grid coordinates of the current node. grid x is the grid coordinate row number of the current node. target y is the column number of the grid coordinates of the terminating node. target The grid coordinate row number of the terminating node; t(n) is the turning cost. When the movement direction of the neighboring node and the current node is different from the movement direction of the current node and its parent node, t(n) is 1, otherwise it is 0. b(n) is the cost of moving obstacles; it is 0 when there are no obstacles to move and 1 when obstacles need to be moved. α is the turning cost weight, and β is the moving obstacle cost weight; In step S5 The turning cost weight α and the moving obstacle cost weight β in the search algorithm evaluation function can be dynamically adjusted according to path planning requirements: If the shortest path is prioritized and moving obstacles are allowed, set β to a smaller value and α to a relatively larger value. If moving obstacles is the priority and turning along the path is acceptable, set β to a larger value and α to a relatively smaller value. In step S5 The execution process of the search algorithm includes the following sub-steps: S51: Algorithm initialization, creating an open list and a closed list. The open list stores nodes to be explored, and the closed list stores nodes whose optimal paths have been determined. Add the starting node to the closed list. Traverse the four neighboring nodes of the starting node. The neighboring nodes are in the directions of up, down, left, and right. The row number of the up neighboring node is incremented by 1, the row number of the down neighboring node is decremented by 1, the column number of the left neighboring node is decremented by 1, and the column number of the right neighboring node is incremented by 1. If a neighboring node exceeds the boundary of the mesh model, skip it directly; Add neighboring nodes to the open list and set the starting node as its parent node. Calculate the f(n) of neighboring nodes based on the evaluation function f(n)=g(n)+h(n)+αt(n)+βb(n). S52: Node selection and target determination. Extract the node with the smallest f(n) value from the open list as the current node. If the coordinates of the current node are the same as the coordinates of the termination node, perform path backtracking. Trace back to the starting node through the parent node pointer of the node. Organize the nodes in the tracing process in the order of "starting node → node → termination node" to generate the optimal path list. If there are nodes of the obstacle type in the optimal path list, generate an additional obstacle movement path list and the algorithm terminates. S53: Neighbor node processing: Move the current node from the open list to the closed list, and traverse the four neighboring nodes of the current node. The direction of the neighboring nodes is up, down, left, and right. The row number of the upper neighboring node is +1, the row number of the lower neighboring node is -1, the column number of the left neighboring node is -1, and the column number of the right neighboring node is +1. If a neighboring node exceeds the boundary of the mesh model, skip it directly; If the neighboring node is already in the closed list, skip it directly; If the neighboring node is not in the open list, calculate f(n) based on the evaluation function f(n)=g(n)+h(n)+αt(n)+βb(n), add the neighboring node to the open list and set the current node as its parent node; If the neighboring node is already in the open list, calculate the f(n) value of reaching the neighboring node through the current node. If this value is less than the current f(n) value of the neighboring node, update the f(n) parameter of the neighboring node and the parent node. S54: Path Output and Display. The optimal path list and obstacle movement path list obtained from the planning are transmitted to the chess display platform. The movement trajectory of the target piece is displayed in the form of "highlighted nodes + arrow lines", and the movement process of the obstacles is displayed simultaneously.

2. The chess move path planning method based on a chess display platform according to claim 1, characterized in that, Step S2 includes the following sub-steps: S21: Chessboard area localization. The Canny edge detection algorithm is used to extract the edge contours in the image. Small-sized interference contours are filtered out by the contour perimeter threshold. Polygon approximation is performed on the remaining contours. The chessboard contour is selected based on three features: the number of vertices is 4, the area of ​​the region conforms to the standard chessboard size range, and the angle between adjacent sides is close to 90°. The coordinates of the four corner vertices of the chessboard are accurately located. The tilted chessboard is corrected into an orthophoto image through perspective transformation. S22: Chess piece segmentation and attribute recognition. A dual-convolutional kernel morphological filter is used to process the corrected chessboard image. The dual convolutional kernel includes a horizontal convolutional kernel and a vertical convolutional kernel. The horizontal convolutional kernel size is set to 1×7, and the vertical convolutional kernel size is set to 7×1. Horizontal and vertical grid lines are filtered out. Chess pieces are separated from the background based on grayscale threshold segmentation. The grayscale threshold is adaptively determined using the Otsu algorithm to extract the bounding rectangle region of each chess piece. The chess piece region image is input into a pre-trained CNN model. The CNN model structure is an improved version of LeNet-5, with an input size of 128×128 and an output of 14 categories of chess piece attributes, completing the chess piece attribute classification. S23: Coordinate mapping. Establish an image coordinate system with the bottom left corner of the corrected chessboard image as the origin. The positive x-axis points horizontally to the right, and the positive y-axis points vertically upwards. The x-axis corresponds to the chessboard column number, and the y-axis corresponds to the chessboard row number. Calculate the center coordinates of the bounding rectangle of each piece. Based on the number of chessboard grid points, convert the image coordinate system to a grid coordinate system to obtain the corresponding node coordinates (x, y, ...) of the piece in the grid model. grid y grid ), the node coordinates x grid For column number, y grid The line number.

3. The chess move path planning method based on a chess display platform according to claim 2, characterized in that, In step S54, the process of generating the obstacle movement path list is as follows: the target node for obstacle movement among the obstacle nodes is selected as a blank node in the mesh model. If there is no blank node, the obstacle node is used as the current node and step S53 is repeated. The node with the smallest f(n) value is selected as the target node for obstacle movement among the obstacle nodes.

4. The chess move path planning method based on a chess display platform according to claim 3, characterized in that, The specific method for visualizing the optimal path in step S5 is as follows: the optimal path is marked with a first color, the starting node in the optimal path is marked with a first color and the character "start", the ending node is marked with a second color and the character "end", the inflection point node is marked with a third color, the obstacle node that needs to be moved is marked with a fourth color, and the movement trajectory of the obstacle is displayed as a dashed arrow of the fifth color.