Human-Machine Go Playing Method Based on Classification Detection Framework and Move Decision Network

Through the human-computer game method based on the classification detection framework and the chess decision-making network, the problem of unsatisfactory results in the Chinese chess detection task was solved, and high-precision chess piece recognition and chess decision-making were achieved, which improved the game level and real-timeness.

CN115888062BActive Publication Date: 2025-06-27NANJING NORMAL UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211683696.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-27
Publication Date
2025-06-27
Estimated Expiration
2042-12-27

AI Technical Summary

Technical Problem

The prior art has poor results in Chinese chess detection tasks such as high-density, large quantity, small targets, and three-dimensional targets. In addition, the traditional intelligent chess based on branch-cut search or database algorithms are limited, making it difficult to achieve high-level chess and board recognition.

Method used

The human-computer game method based on the classification detection framework and the chess decision-making network is adopted. The chessboard images are collected through the camera, preprocessed and detected, and the chess piece coordinates and category information are obtained, and the chessboard coordinates and category information is mapped to a two-dimensional standard virtual chessboard, and the chessboard is converted into a standard format of fen codes. The strategy value network with multi-scale and residual structure is input, and the chessboard is obtained through the robotic arm.

Benefits of technology

It realizes high-precision chess piece recognition and chess decision-making, improves the game level and real-time performance, and maintains efficient gameplay ability in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115888062B_ABST
    Figure CN115888062B_ABST
Patent Text Reader

Abstract

The present invention discloses a human-computer chess-playing method based on a classification and detection framework and a move decision-making network, including: collecting chessboard image data information through a camera, and sending the chessboard image data information into a detection network to obtain the coordinates and category information of the chess pieces; after the detection is completed, mapping the chess category positions to a two-dimensional standard virtual chessboard to complete the coordinate system conversion and visualization; converting the two-dimensional standard virtual chessboard data into the fen code standard format and sending it into the established decision-making network through an api interface to obtain move instructions; after obtaining the move instructions, generating the coordinate information required by the robotic arm through data processing to control the robotic arm to grab the chess pieces and realize the move. The present invention provides a solution for realizing human-computer chess-playing, and has the advantages of strong human-computer interaction, high detection accuracy, fast move decision-making speed, high level, and strong anti-interference ability in complex environments.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of machine vision and deep learning, and in particular to a human-machine chess game method based on a classification detection framework and a chess move decision network. Background Art

[0002] Chess has a long history in my country. It is a two-player competitive game. Due to its simple equipment and strong fun, it has become a very popular chess activity. Chinese chess is a Chinese chess culture and a cultural treasure of the Chinese nation. The Chinese chess playing robot system is a typical complex application of service robots. The key to its realization lies in the chessboard recognition and positioning and the autonomous chess strategy, which has a high research value.

[0003] At present, in the field of target detection, in addition to the traditional template matching-based algorithms, many algorithms based on convolutional neural networks have emerged, such as YOLO, Faster-RCNN, etc., which have been widely studied and applied in the detection of multi-category targets, multi-scale small targets, and three-dimensional objects. However, its target detection method based on two-dimensional images is not ideal in the detection task of high-density, large number, small targets, and three-dimensional targets such as Chinese chess. At the same time, domestic and foreign institutions have conducted a lot of research on the problem of autonomous decision-making in chess games, and decision-making algorithms based on Monte Carlo tree search and deep neural networks have been studied and applied in various chess games. In terms of Chinese chess chess strategy, there are many algorithms based on Minimax and Alpha-beta pruning search, but there are currently few high-level Chinese chess game agents. Traditional agents based on pruning search or database algorithms are limited in chess strength by the database volume and edge computing resources, and often do not have high-level game ability and the ability to directly recognize the chessboard. A fully functional and reliable Chinese chess robot system needs to have high-precision Chinese chess game recognition capabilities based on machine vision, as well as an agent that can make high-level decisions. Summary of the invention

[0004] Purpose of the invention: In order to overcome the shortcomings of the prior art, a human-computer game method based on a classification detection framework and a chess-playing decision network is proposed, which provides a solution for realizing human-computer game and has the advantages of strong human-computer interactivity, high detection accuracy, fast chess-playing decision-making speed, high level, and strong resistance to interference from complex environments.

[0005] Technical solution: To achieve the above purpose, the present invention provides a human-computer chess method based on a classification detection framework and a chess decision network, comprising the following steps:

[0006] S1: Collect chessboard image data information through the camera, pre-process the image and send it to the trained detection network to obtain chess piece coordinates and category information respectively;

[0007] S2: Map the obtained chess positions and category information to a two-dimensional canonical virtual chessboard, and complete coordinate system conversion and visualization;

[0008] S3: Convert the two-dimensional canonical virtual chessboard data into the fen code standard format and send it through the api interface to the constructed policy value network with multi-scale and residual structures to obtain the move instruction;

[0009] S4: After obtaining the move instruction, generate the coordinate information required by the robotic arm through data processing, plan the movement path of the robotic arm, and control the robotic arm to grab the chess piece to achieve moving the chess.

[0010] Furthermore, the specific steps of step S1 are as follows:

[0011] A1: Start the Loongson, enable TCP communication to obtain the data collected by the camera, and continuously display and refresh to play the role of monitoring the chess game;

[0012] A2: Start the main control, and perform edge processing on the image data obtained by TCP communication through the canny edge detection algorithm;

[0013] A3: Send the edge-processed picture into the Hough circle detection module to obtain the center point coordinates of the chess pieces, and crop out the detected chess pieces and process them into the same size for display through the window;

[0014] A4: The cropped chess piece pictures obtain the image categories through the constructed classification detection framework, and then put the coordinate information and category information of the chess pieces into a list.

[0015] Furthermore, the specific process of edge processing in step A2 is as follows:

[0016] Perform grayscale processing on the image. Considering the image characteristics of Chinese chess, set the formula parameters as follows, where R a , G a , B a represent the pixel values of the red, green, and blue color channels respectively, and Gray represents the pixel value after grayscale conversion:

[0017] Gray = 0.6R a + 0.2G a + 0.2B a

[0018] In order to remove the superimposed high-frequency noise in the image, an improved Gaussian filtering method is used to process the image. The filtering function is as follows, where G is the weight result, (x, y) is the coordinate, and σ is the standard deviation:

[0019]

[0020] After obtaining the gradient magnitude and direction through the Sobel operator template, the double-threshold algorithm is used to detect and connect the edges. A slider and an image window are created. The slider corresponds to the two thresholds of Canny respectively. The callback function is called through the slider to change the image, obtain the optimal parameters of the slider and save the picture.

[0021] Further, the classification detection framework and its model in step A4 are constructed as follows:

[0022] First, the picture is normalized, and the original pixel values between 1 and 255 are converted to between 0 and 1.

[0023] The model uses the Keras deep learning framework and creates a model instance using the Sequential function. The first part is first a convolutional layer with 32 convolutional kernels, the convolutional kernel size is 3*3, the size of the input picture is 60*60, the number of channels of the RGB image is 3, the activation function uses the linear flow function relu, and the picture size is kept unchanged by setting the parameter padding to fill the boundary. Then, 25% of the neurons are inactivated to 0 through the dropout function. Then, a 2*2 max pooling layer is passed through. Then, another convolutional layer is passed through, with 64 convolutional kernels, the convolutional kernel size is 3*3, the activation function uses the linear flow function relu, and the picture size is kept unchanged by setting the parameter padding to fill the boundary. Similarly, 25% of the neurons are inactivated to 0 through the dropout function. Then, a 2*2 max pooling layer is passed through. Then, another convolutional layer is passed through, with 128 convolutional kernels, the convolutional kernel size is 3*3, the activation function uses the linear flow function relu, and the picture size is kept unchanged by setting the parameter padding to fill the boundary. Similarly, 25% of the neurons are inactivated to 0 through the dropout function. Then, a 2*2 max pooling layer is passed through.

[0024] The second part first flattens the data into two dimensions through the flatten function, then passes through a fully connected layer, the activation function uses the linear flow function relu, and finally through the normalized exponential function softmax. The optimizer parameter uses the adam optimization method. The loss function is modified based on the cross-entropy loss function. Among them, L is the output value of the loss function, p is the output value of the activation function, q is the actual label, the positive sample is 1, and the negative sample is 0. In this way, the loss function retains part of the loss for the samples with poor prediction scores and greatly reduces the loss for the samples with good scores. The improvement is as follows:

[0025]

[0026] The training dataset of the model is a self-made dataset of 1000 images with different lighting conditions and changing chess piece positions obtained through a camera. 20% of them are used as the validation set. It is iterated 1000 times, with 64 images in each batch as a training unit, and the output logs are saved.

[0027] Further, the step S2 specifically includes the following steps:

[0028] B1: Use the cv2.inRange() function in Opencv to filter out the background around the chessboard by setting the RGB threshold, leaving only the chessboard image.

[0029] B2: Set the lower left corner of the picture as the coordinate origin, the horizontal coordinate as the first coordinate, and the vertical coordinate as the second coordinate. Preset the red interval, and scan from top to bottom, from bottom to top, from left to right, and from right to left respectively to detect the red border and extract the four corner coordinates of the chessboard.

[0030] B3: Divide the X-axis into 9 equal parts and the Y-axis into 8 equal parts. According to the existing four corner coordinates, obtain the coordinate positions of each grid point on the chessboard.

[0031] B4: Match the central point coordinate information of the chess piece with the coordinate of the grid point closest to it, and finally output the coordinates of each grid point occupied by the chess piece and the information of the chess piece type to the virtual chessboard.

[0032] Further, the step S3 specifically includes the following steps:

[0033] C1: After obtaining the virtual chessboard information, first judge whether the chess piece has changed. If the opponent makes a move, convert it into the corresponding fen code according to the generation rule.

[0034] C2: Send the fen code to the policy-value network with multi-scale and residual structures built by calling the api interface.

[0035] C3: Receive the optimal policy action output by the policy-value network, and convert the obtained optimal policy action instruction into two-dimensional chessboard move data.

[0036] Further, the composition of the policy-value network with multi-scale and residual structures in the step C2 is as follows:

[0037] The input of the policy-value network is a 9*10 4-bit chessboard state diagram, from which value and policy features are extracted. The output is divided into two parts. The first part is the value output, representing the neural network's prediction of the outcome of the current chess game. The second part is the policy output, which is a 1*115 normalized probability vector, representing the probability of taking each possible action. The greater the predicted probability of a certain action, the more likely this action is to become the optimal policy action of the current moving side.

[0038] The policy value network consists of an initial convolutional layer, 7 residual convolutional modules, an FPN, and 2 fully connected layers, where the output weight parameters are shared; the initial convolutional layer consists of 256 3*3 convolutional kernels, followed by normalization, and the activation function uses the linear flow function relu; the residual convolutional module includes a convolutional layer consisting of 256 3*3 convolutional kernels, followed by normalization, and the activation function uses the linear flow function relu, and then continues with a convolutional layer consisting of 256 3*3 convolutional kernels, followed by normalization.

[0039] Further, the step S4 specifically includes the following steps:

[0040] D1: To use the robotic arm, first, it is necessary to establish its own coordinate system. The Cartesian coordinate system is selected. Place the position points of the robotic arm at the origin, any point on the positive x-axis, and any point in the first quadrant of the xy plane in sequence. Obtain the position and attitude parameters of the coordinate system through the three-point setting.

[0041] D2: The robotic arm moves in a straight-line trajectory using the linear trajectory interpolation method. To move from the starting point a1(x1, y1, z1) to the target point a2(x2, y2, z2), assuming the operating speed of the robotic arm end is V, the interpolation time period is Δt, and the length of the space straight line is M, then the interpolation step size ΔM and the number of interpolation points n can be deduced as follows:

[0042] ΔM = V·Δt

[0043] n = M / ΔM

[0044] Then the position coordinates (a kx , a ky , a kz ) of the k-th interpolation point of the straight-line trajectory can be expressed as:

[0045]

[0046] Performing linear trajectory interpolation between points a1 and a2 can ensure that the trajectory is a straight line;

[0047] D3: After obtaining the two-dimensional chessboard move data, convert it into coordinate data of two points. Confirm whether there is a piece-eating behavior by judging whether there is a piece at the target coordinate point. If there is a piece-eating behavior, first remove the eaten piece from the chessboard and then move the target piece to the new position. If there is no piece-eating behavior, directly move the piece;

[0048] D4: When the robotic arm receives the instruction to move the chess piece, it adopts the designed motion control process. First, it moves above the initial position and then moves down to enable the suction cup. After sucking the chess piece, it moves up to the same height, moves horizontally in a straight line to above the target position, moves down to release the chess piece, and then returns to the initial position. It waits to judge the opponent's move and then obtains the move instruction to repeat the above actions.

[0049] The present invention lacks a chess dataset, so a chess dataset under different lighting conditions is made for training. For the existing detection frameworks with unsatisfactory detection effects on such small targets, high density, and large quantity of objects, an image preprocessing method and a shallow classification detection framework are proposed, and the average detection accuracy reaches 92%. Aiming at the problems of slow response of the move strategy and low playing level, a strategy value network with multi-scale and residual structures is proposed to improve the decision-making network to guide the simulated move.

[0050] Beneficial effects: Compared with the prior art, the present invention has the following advantages:

[0051] 1. The present invention proposes a classification network for chess recognition based on machine vision. This network is a lightweight, small-sized, and fast-operating single-stage object detection model. This network makes the model more inclined to detect small objects with high density, and obtains better real-time performance while achieving higher detection accuracy.

[0052] 2. The present invention proposes a method for chessboard recognition and positioning based on machine vision fusion to solve the problems of chessboard recognition and positioning. This method uses a grid recognition network for chess pieces, converts the image into a chessboard grid, and then fuses the coordinates of the chess pieces and the chessboard grid information, which can effectively improve the recognition and positioning accuracy of the chess pieces and the chessboard.

[0053] 3. The present invention proposes a strategy value network with multi-scale and residual structures. Training data is obtained through self-play, and the network model parameters are verified and updated through agent confrontation to realize Chinese chess recognition and play.

[0054] 4. The present invention proposes a method for linear trajectory planning of a robotic arm based on linear trajectory interpolation, and designs a linear motion process applied to the move process. Description of the Drawings

[0055] Figure 1 It is the overall flowchart of the present invention;

[0056] Figure 2 It is the structure diagram of the classification detection network of the present invention;

[0057] Figure 3 It is the edge detection effect diagram of the present invention;

[0058] Figure 4Effect diagram of Hough circle positioning of the present invention;

[0059] Figure 5 Result diagram of the detection information of the present invention;

[0060] Figure 6 Result diagram of the virtual chessboard mapping of the present invention;

[0061] Figure 7 Structure diagram of the policy value network of the present invention;

[0062] Figure 8 Overview diagram of the human-machine chess playing system of the present invention;

[0063] Figure 9 Trajectory movement diagram of the robotic arm of the present invention. Specific implementation manners

[0064] The present invention will be further clarified below in conjunction with the accompanying drawings and specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and not to limit the scope of the present invention. After reading the present invention, various equivalent forms of modification of the present invention fall within the scope defined by the appended claims of this application.

[0065] The present invention provides a human-machine chess playing method based on a classification detection framework and a move decision-making network, as Figure 1 shown, which includes the following steps:

[0066] Step 1: Collect chessboard image data information through a camera, preprocess the image, and then send the image into a trained detection network to obtain the coordinates and category information of the chess pieces respectively;

[0067] Step 2: Map the obtained chess positions and category information to a two-dimensional standard virtual chessboard, and complete coordinate system conversion and visualization;

[0068] Step 3: Convert the two-dimensional standard virtual chessboard data into the fen code standard format, and send it into the constructed policy value network with a multi-scale and residual structure through an api interface to obtain move instructions;

[0069] Step 4: After obtaining the move instructions, generate the coordinate information required by the robotic arm through data processing, plan the movement path of the robotic arm, and control the robotic arm to grab the chess piece to achieve a move.

[0070] The classification detection network structure in Step 1 is as Figure 2 shown, and the detection information result is as Figure 5 shown. The specific process of Step 1 is as follows:

[0071] Step 1.1: Start the Loongson to enable TCP communication to obtain the data collected by the camera, and continuously display and refresh to play the role of monitoring the chess game;

[0072] Step 1.2: The image data obtained by the master control through TCP communication is processed by the canny edge detection algorithm:

[0073] First, the image is grayscale processed. Considering the image characteristics of the chessboard, the formula parameters are set as follows. Here, R a , G a , B a represent the pixel values of the red, green, and blue color channels respectively, and Gray represents the pixel value after grayscale conversion:

[0074] Gray = 0.6R a + 0.2G a + 0.2B a

[0075] Next, in order to remove the superimposed high-frequency noise in the image, an improved Gaussian filtering method is used to process the image. The filtering function is as follows, where G is the weight result, (x, y) is the coordinate, and σ is the standard deviation:

[0076]

[0077] Then, after obtaining the gradient magnitude and direction through the sobel operator template [Zheng Huanhuan, Bai Yuxiu, Zhang Yaqiong. An Edge Detection Algorithm Based on Sobel Operator [J]. Microcomputer Applications, 2020], the double-threshold algorithm is used to detect and connect the edges. A slider and an image window are created. The slider corresponds to the two thresholds of canny respectively. The callback function is called through the slider to change the image and obtain the optimal parameters of the slider and save the picture.

[0078] In this embodiment, the edge detection effect of the image is specifically as Figure 3 shown.

[0079] Step 1.3: The edge-processed picture is sent to the Hough circle detection module to obtain the center point coordinates of the chess pieces, and the detected chess pieces are cropped and processed into the same size and displayed through the window; in this embodiment, the Hough circle positioning effect of the picture is specifically as Figure 4 shown.

[0080] Step 1.4: The cropped chess piece picture passes through the self-built classification and detection framework to obtain the image category, and then the coordinate information and category information of the chess pieces are put into a list.

[0081] The classification and detection framework and its model composition are as follows:

[0082] First, the picture is normalized, and the original pixel values between 1 and 255 are converted to between 0 and 1.

[0083] The model uses the Keras deep learning framework and creates a model instance using the Sequential function. In the first part, there is first a convolutional layer with 32 convolutional kernels, a kernel size of 3*3, an input image size of 60*60, 3 channels for RGB images, and the activation function uses the linear flow function relu. By setting the parameter padding to fill the boundary, the image size is kept unchanged. Then, 25% of the neurons are inactivated to 0 through the dropout function, and then a 2*2 max pooling layer is passed through. After that, there is another convolutional layer with 64 convolutional kernels, a kernel size of 3*3, the activation function uses the linear flow function relu, by setting the parameter padding to fill the boundary, the image size is kept unchanged, and again 25% of the neurons are inactivated to 0 through the dropout function, and then a 2*2 max pooling layer is passed through. After that, there is another convolutional layer with 128 convolutional kernels, a kernel size of 3*3, the activation function uses the linear flow function relu, by setting the parameter padding to fill the boundary, the image size is kept unchanged, and again 25% of the neurons are inactivated to 0 through the dropout function, and then a 2*2 max pooling layer is passed through.

[0084] In the second part, the data is first flattened into two dimensions through the flatten function, then passed through a fully connected layer, and the activation function uses the linear flow function relu. Finally, the softmax function is used for normalization. The optimizer parameter uses the adam optimization method [Diederik P. Kingma, Jimmy Ba. Adam: A Method for Stochastic Optimization. [J]. CoRR, 2014], and the loss function is a modification based on the cross-entropy loss function. Here, L is the output value of the loss function, p is the output value of the activation function, q is the actual label, the positive sample is 1, and the negative sample is 0. This makes the loss function retain part of the loss for samples with poor prediction scores and significantly reduce the loss for samples with good scores. The improvement is as follows:

[0085]

[0086] The training dataset of the model is a self-made dataset of 1000 images with different lighting conditions and changed chess piece positions obtained through a camera. 20% of them are used as the validation set, iterated 1000 times, 64 images per batch are used as a training unit, and the output logs are saved.

[0087] In step 2, the virtual chessboard mapping result diagram is as Figure 6 shown, and the specific process of step 2 is as follows:

[0088] Step 2.1: Use the cv2.inrange() function in Opencv to filter out the background around the chessboard by setting the RGB threshold, leaving only the chessboard image.

[0089] Step 2.2: Set the lower left corner of the image as the coordinate origin, with the abscissa as the first coordinate and the ordinate as the second coordinate. Preset the red interval, and scan from top to bottom, from bottom to top, from left to right, and from right to left respectively to detect the red border and extract the four corner coordinates of the chessboard.

[0090] Step 2.3: Divide the X-axis into 9 equal parts and the Y-axis into 8 equal parts. Based on the existing four corner coordinates, obtain the coordinate positions of each grid point on the chessboard.

[0091] Step 2.4: Match the coordinate information of the center point of the chess piece with the coordinate of the grid point closest to it, and finally output the coordinates of each grid point occupied by the chess piece and the information of the chess piece type to the virtual chessboard.

[0092] The structure of the policy value network in Step 3 is as Figure 7 shown, and the specific process of Step 3 is as follows:

[0093] Step 3.1: After obtaining the virtual chessboard information, first determine whether the chess pieces have changed. If the opponent makes a move, convert it into the corresponding fen code according to the generation rule [Li Yong. Design and Implementation of an Online Chess Game System Based on Mobile Internet [D]. Huazhong University of Science and Technology, 2011].

[0094] Step 3.2: Send the fen code into the constructed policy value network with multi-scale and residual structures by calling the api interface [Wu Qiyu, Xie Fei, Huang Lei, Liu Zongxi, Zhao Jing, Liu Xixiang. Robot Localization Chess Game and Move Strategy Based on Depth / Monocular Fusion Vision and Reinforcement Learning [J / OL]. Control and Decision: 1-10 [2021-10-14]].

[0095] Step 3.3: Receive the optimal policy action output by the policy value network, and convert the obtained optimal policy action instruction into two-dimensional chessboard move data.

[0096] The policy value network is composed as follows:

[0097] The input of the policy value network is a 9*10 4-bit chessboard state diagram, from which value and policy features are extracted. The output is divided into two parts. The first part is the value output, representing the neural network's prediction of the outcome of the current chess game. The second part is the policy output, which is a 1*115 normalized probability vector, representing the probability of taking each possible action. The greater the predicted probability of a certain action, the more likely this action is to be the optimal policy action of the current moving player.

[0098] The policy value network consists of 1 initial convolutional layer, 7 residual convolutional modules, FPN, and 2 fully connected layers, where the output weight parameters are shared. The initial convolutional layer consists of 256 3*3 convolutional kernels, followed by normalization, and the activation function uses the linear flow function relu. The residual convolutional module includes a convolutional layer consisting of 256 3*3 convolutional kernels, followed by normalization, and the activation function uses the linear flow function relu. Then, there is another convolutional layer consisting of 256 3*3 convolutional kernels, followed by normalization.

[0099] An overview of the human-machine chess game system in step 4 is as Figure 8 shown, and the movement of the robotic arm trajectory is as Figure 9 shown. The specific process of step 4 is as follows:

[0100] Step 4.1: To use the robotic arm, it is first necessary to establish its own coordinate system. The Cartesian coordinate system is selected. Place the robotic arm position points at the origin, any point on the positive x-axis, and any point in the first quadrant of the xy plane in sequence. Obtain the position and attitude parameters of the coordinate system through the three-point setting.

[0101] Step 4.2: The robotic arm moves in a straight-line trajectory using the linear trajectory interpolation method. To move from the starting point a1(x1, y1, z1) to the target point a2(x2, y2, z2), assuming the running speed of the robotic arm end is V, the interpolation time period is Δt, and the length of the space straight line is M, then the interpolation step size ΔM and the number of interpolation points n can be deduced as follows:

[0102] ΔM = V·Δt

[0103] n = M / ΔM

[0104] Then the position coordinates (a kx , a ky , a kz ) of the k-th interpolation point on the straight-line trajectory can be expressed as:

[0105]

[0106] Performing linear trajectory interpolation between points a1 and a2 can ensure that the trajectory is a straight line;

[0107] Step 4.3: After obtaining the two-dimensional chessboard move data, convert it into coordinate data of two points. Confirm whether there is a piece-taking behavior by judging whether there is a piece at the target coordinate point. If there is a piece-taking behavior, first remove the captured piece from the chessboard and then move the target piece to the new position. If there is no piece-taking behavior, directly move the piece;

[0108] Step 4.4: When the robotic arm receives the instruction to move the chess piece, it adopts the designed motion control process. First, it moves above the initial position and then moves down to enable the suction cup. After sucking the chess piece, it moves up to the same height, moves horizontally in a straight line to above the target position, moves down to close the suction cup and drop the chess piece, and then returns to the initial position, waiting to judge the opponent's move and obtain the move instruction to repeat the above actions.

[0109] This embodiment also provides a human-machine chess-playing system based on a classification detection framework and a move decision-making network. The system includes a network interface, a memory, and a processor. Among them, the network interface is used to receive and send signals during the process of receiving and sending information with other external network elements. The memory is used to store computer program instructions that can run on the processor. The processor is used to execute the steps of the above consensus method when running the computer program instructions.

[0110] This embodiment also provides a computer storage medium. The computer storage medium stores a computer program, and the above-described method can be implemented when the processor executes the computer program. The computer-readable medium can be considered tangible and non-transitory. Non-limiting examples of non-transitory tangible computer-readable media include non-volatile memory circuits (such as flash memory circuits, erasable programmable read-only memory circuits, or mask read-only memory circuits), volatile memory circuits (such as static random access memory circuits or dynamic random access memory circuits), magnetic storage media (such as analog or digital magnetic tapes or hard disk drives), and optical storage media (such as CDs, DVDs, or Blu-ray discs), etc. The computer program includes processor-executable instructions stored on at least one non-transitory tangible computer-readable medium. The computer program may also include or rely on stored data. The computer program may include a basic input / output system (BIOS) that interacts with the hardware of a dedicated computer, device drivers that interact with specific devices of a dedicated computer, one or more operating systems, user applications, background services, background applications, etc.

[0111] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) that contain computer-usable program code.

[0112] This application is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and combinations of flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device generate means for implementing the specified functions in the flow Figure 1 one or more flows and / or blocks Figure 1 or means for implementing the specified functions in a block or multiple blocks.

[0113] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer-readable memory produce a manufacture including instruction means that implement the specified functions in the flow Figure 1 one or more flows and / or blocks Figure 1 or a block or multiple blocks.

[0114] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the specified functions in the flow Figure 1 one or more flows and / or blocks Figure 1 or a block or multiple blocks.

Claims

1. A human-machine chess-playing method based on a classification and detection framework and a move decision-making network, characterized in that, It includes the following steps: S1: Collect the chessboard image data information through a camera. After preprocessing the image, send the image into the trained detection network to obtain the coordinates and category information of the chess pieces respectively; S2: Map the obtained chess positions and category information to a two-dimensional standard virtual chessboard, and complete the coordinate system conversion and visualization; S3: Convert the two-dimensional standard virtual chessboard data into the fen code standard format and send it into the constructed policy value network with multi-scale and residual structures through the api interface to obtain the chess moving instruction; S4: After obtaining the chess moving instruction, generate the coordinate information required by the robotic arm through data processing, plan the movement path of the robotic arm, and control the robotic arm to grab the chess piece to realize the chess move; Step S1 specifically includes the following steps: A1: Start the Loongson, enable TCP communication to obtain the data collected by the camera, and keep displaying and refreshing all the time to play the role of monitoring the chess game; A2: Start the main control, and perform edge processing on the image data obtained by TCP communication through the canny edge detection algorithm; A3: Send the edge-processed picture into the Hough circle detection module to obtain the center point coordinates of the chess pieces, and crop out the detected chess pieces and process them into the same size and display them through the window; A4: The cropped chess piece pictures pass through the constructed classification detection framework to obtain the image categories, and then put the coordinate information and category information of the chess pieces into a list; The classification detection framework and its model in step A4 are composed as follows: The model uses the keras deep learning framework, and uses the Sequential function to create a model instance. The first part is first a convolutional layer. By setting the parameter padding to fill the boundary to keep the picture size unchanged, then the neurons are inactivated to 0 through the dropout function. Then pass through another convolutional layer. By setting the parameter padding to fill the boundary to keep the picture size unchanged, and similarly inactivate the neurons to 0 through the dropout function. Then pass through another convolutional layer. By setting the parameter padding to fill the boundary to keep the picture size unchanged, and similarly inactivate the neurons to 0 through the dropout function; The second part first flattens the data into two dimensions through the flatten function, then passes through a fully connected layer, and finally passes through the softmax function of the normalized exponential function. The optimizer parameter uses the adam optimization method, and the loss function is modified based on the cross-entropy loss function.

2. The human-computer chess-playing method based on the classification detection framework and the move decision-making network according to claim 1, wherein The specific process of the edge processing in step A2 is as follows: Grayscale the image. Considering the characteristics of the chess image, set the formula parameters as follows, where R a , G a , B a represent the pixel values of the red, green, and blue color channels respectively, and Gray represents the pixel value after grayscale conversion: Gray = 0.6R a + 0.2G a + 0.2B a In order to remove the superimposed high-frequency noise in the image, an improved Gaussian filtering method is used to process the image. The filtering function is as follows, where G is the weight result, (x, y) is the coordinate, and σ is the standard deviation: After obtaining the gradient amplitude and direction through the sobel operator template, use the double-threshold algorithm to detect and connect the edges. Create a slider and an image window. The slider corresponds to the two thresholds of canny respectively. Call the callback function through the slider to change the image and obtain the optimal parameters of the slider and save the picture.

3. The human-computer chess-playing method based on the classification detection framework and the move decision-making network according to claim 1, wherein Step S2 specifically includes the following steps: B1: Use the cv2.inRange() function in Opencv to filter out the background around the chessboard by setting the RGB threshold, leaving only the chessboard image. B2: Set the lower left corner of the image as the coordinate origin, with the abscissa as the first coordinate and the ordinate as the second coordinate. Preset the red interval and scan from top to bottom, from bottom to top, from left to right, and from right to left respectively to detect the red border and extract the four corner coordinates of the chessboard. B3: Divide the X-axis into 9 equal parts and the Y-axis into 8 equal parts. Based on the existing four corner coordinates, obtain the coordinate positions of each grid point on the chessboard. B4: Match the coordinate information of the center point of the chess piece with the coordinate of the grid point closest to it, and finally output the coordinates of each grid point occupied by the chess piece and the information of the chess piece type to the virtual chessboard.

4. The human-computer chess-playing method based on the classification detection framework and the move decision-making network according to claim 1, characterized in that, The specific steps of step S3 are as follows: C1: After obtaining the virtual chessboard information, first determine whether the chess pieces have changed. If the opponent makes a move, convert it into the corresponding fen code according to the generation rule. C2: Send the fen code into the policy-value network with multi-scale and residual structures built by calling the api interface. C3: Receive the optimal policy action output by the policy-value network and convert the obtained optimal policy action instruction into two-dimensional chessboard move data.

5. The human-computer chess-playing method based on the classification detection framework and the move decision-making network according to claim 4, characterized in that, The composition of the policy-value network with multi-scale and residual structures in step C2 is as follows: The input of the policy-value network is a 9*10 4-bit chessboard state diagram. Extract the value and policy features from it, and the output is divided into two parts. The first part is the value output, representing the neural network's prediction of the outcome of the current chess game. The second part is the policy output, which is a 1*115 normalized probability vector representing the probability of taking each possible action. The policy-value network consists of 1 initial convolutional layer, 7 residual convolutional modules, FPN, and 2 fully connected layers, where the output weight parameters are shared. The initial convolutional layer consists of 256 3*3 convolutional kernels, followed by normalization, and the activation function uses the linear flow function relu. The residual convolutional module includes a convolutional layer consisting of 256 3*3 convolutional kernels, followed by normalization, and the activation function uses the linear flow function relu. Then there is another convolutional layer consisting of 256 3*3 convolutional kernels, followed by normalization.

6. The human-computer chess-playing method based on the classification detection framework and the move decision-making network according to claim 1, characterized in that, The specific steps of step S4 are as follows: D1: To use the robotic arm, first establish its own coordinate system. The coordinate system is selected as the Cartesian coordinate system. Place the robotic arm position points at the origin, any point on the positive x-axis, and any point in the first quadrant of the xy plane successively, and obtain the position and attitude parameters of the coordinate system through the three-point setting. D2: The robotic arm moves in a straight-line trajectory by using the method of linear trajectory interpolation. To move from the starting point a1(x1, y1, z1) to the target point a2(x2, y2, z2), assume the running speed of the robotic arm end is V, the interpolation time period is Δt, and the length of the space straight line is M. Then the interpolation step size ΔM and the number of interpolation points n can be deduced as follows: ΔM = V·Δt n = M / ΔM Then the position coordinates (a kx , a ky , a kz ) of the k-th interpolation point on the straight-line trajectory can be expressed as: Performing linear trajectory interpolation between points a1 and a2 can ensure that the trajectory is a straight line. D3: After obtaining the two-dimensional chessboard move data, convert it into the coordinate data of two points. Determine whether there is a piece-taking behavior by checking whether there is a piece at the target coordinate point. If there is a piece-taking behavior, first remove the captured piece from the chessboard and then move the target piece to the new position. If there is no piece-taking behavior, directly move the piece; D4: When the robotic arm receives the instruction to move a piece, adopt the designed motion control process. First, move above the initial position and then move down to enable the suction cup. After sucking the piece, move up to the same height and move horizontally in a straight line above the target position, then move down to close the suction cup and drop the piece, and then return to the initial position, waiting to judge the opponent's move and obtain the move instruction to repeat the above actions.

Citation Information

Patent Citations

  • Chess piece falling strategy and situation evaluation method suitable for various chess games

    CN110717591A

  • Multi-target small object identification method based on category loss and difference detection

    CN114429584A