Research on the Opening Book of the computer game of draughts

: Opening Book is a kind of assistive technologies to enhance the performance of computer games. The opening stages of the game method generally used to query the database generated. This method improving search efficiency and avoids the missing strategic of traditional evaluation systems. This paper studies the technical problems of using the Opening Book of draughts, and introduces the generation and usage of the Opening Book. The authors also discussed the detail of statistics in Opening Book. Besides, this paper presents a new idea of introducing the information of the Opening Book into the traditional Alpha-Beta valuation system. The experiment proved that the method proposed in this paper can effectively solve the issues of the start of the draughts and improve the game level of the draughts.


Introduction
The current computer game [1][2][3][4] is an important research direction in the field of artificial intelligence. Its complexity and challenge attract many scholars to study. The study of the game of chess is an important branch of computer game research. Draughts [5,6] are evolved from national draughts from all over the world. They can be traced back to the pharaohs of ancient Egypt. From ancient times to the present, draughts such as America draughts, Italian draughts, Spanish checkers,and other representative checkers appeared. Board of draughts [7][8][9] is a kind of square board, made up of 10 × 10 dark and light squares. Usually, those squares are called 'Black and White square'. The place where chessmen can move are black squares. As shown in Fig. 1, Black squares are numbered from 1 to 50, which are called chess areas.
Draughts is played by two players. Each player has 20 chessmen and draughts require both players to move along the bevel, and the chessmen can jump the opponent's chessmen then eat those chessmen which are jumped until all the chessmen on one are eaten by the other player or all chessmen cannot continue moving on the board. In the draughts process, 'draw' as a final is allowed [10].
Because of the rules like chessmen must be captured by jumping over the opponent's chessmen, Jump over as many chessmen as possible etc. Therefore, it is necessary to force the opponent to lose chessmen by using the opposing positions or holding opponent's chessmen, or to change Men to King in advance to change the strategy of comparing the two sides.
A draughts game process is divided into three stages: the startstage, the mid-stage, and the end-stage. The beginning of a match is called the start-stage, which means the first 10-15 moves after the start of the match.
The common beginning of draughts [11], including the Laerfa start system, the centrally symmetry start system, the Rosenborg start system, the Sprint start system, the Polish start system, and the French start system. Although these opening systems have their own different characteristics, they all jointly follow the following principles: the centre of competition, the mutual coordination among chessmen, and strong support. In addition, it is significant to pay attention to the connection between chessmen. Moving of chessmen in the position that can make the opponent's pieces become the king need to be considered clearly. The start-stage is the foundation of the overall situation [12][13][14][15], which has a great effect on the whole process and result. The first step in the start-stage is to define the strategic objectives, organise and plan the troops, and seize the initiative of the game.
Therefore, the position of the start-stage is very crucial in draughts computer game system [16][17][18][19][20]. The traditional checkers game system adopts much blindness and lacks of strategy in the start-stage to adopt the same method of selecting the moves of relying on the value assessment of chess pieces as in the mid-stage and the end-stage. This is obviously inconsistent with the principle of start-stage. It is extremely unfavourable to the development of the situation in the mid-stage and end-stage. To solve this problem, it is necessary to draw lessons from various classic and mature starting methods of draughts, to develop a start-stage database of draughts game system to apply the initial tactics.

Importance of Opening Book
The so-called Opening Book [21][22][23][24][25] is a special form of database in which the draughts classic and mature moves' information are organised. In the start-stage, the system selects the more favourable move by calling the information in the Opening Book and cooperating with the traditional search and valuation system. Compared with the traditional search and evaluation system, the draughts game system with the Opening database on the traditional basis shortens the search time in the start-stage. At the same time, pieces move more strategically, and avoid the simple use of the game system of the Opening Book cannot deal with some unpopular situation. The use of opening database can form a more secure, favourable situation. Table 1 is statistical information of 1561 draughts games about moves of the first step and the results. There is no significant difference of winning percentage between 'the first hand' and 'the second hand'. With different moves for the first step, there is a clear difference between the first hand and the second hand in winning percentage. The most commonly used move is 32-28 (Laerfa start system), accounting for 59.58% of the total number of games, excluding the use of a smaller number of initial moves of interference. The winning percentage of this move has no obvious advantages compared with other moves but has a higher rate of draw. There was 21.08% of the games started with the move of 33-29 (Rosenberg start system). The winning percentage was significantly higher than that of other moves. Thus, the choice of 33-29 moves can help the first hand to produce a stable, favourable situation in the process of game. If moves with higher winning percentage for first hand were taken, it still can be draw or even win at last unless pieces moved by mistakes. These statistics above

Design and innovation of Opening Book
The Opening Book used in this research was compiled from the records of 1561 draughts games in a pre-defined manner.
According to the records, we reply to the games. When each step is finished, we determined the situation of the on the board. There would be a definite situation after each move is completed, and there was one or more move in a situation. If a move in a situation was realised more than once in the actual game and produces favourable results, the move was more favourable under the situation. Conversely, if the situation produced by a certain move was beneficial to the opponent, the move should be avoided. Select masters tournament recorded as samples of Opening Book data, considered in the choice of masters' moves ass certainly better than ordinary players on tactics and strategy. If we used draughts game system through the 'self-game' to get the required information for Opening Book, 'first hand' and 'second hand' used the same set of valuation, search systems under unavoidable conditions. In this way, conducting multiple experiments could only repeat for a specific game of the game, and the information derived by these repeated game processes was the same. If the statistical information of such chessboard was used in the Opening Book, it would only increase the blindness generated by the moves.

Record and process of board information
Draughts' board consists of 100 squares of 10 × 10, but not all squares allow chessmen to be placed, and a total of 50 chess areas where pieces can be placed. If a checkers board is represented by a 10 × 10 array, the non-"position" area occupies the same memory resources as the "position" area. At the same time, it will also be in the board traversal, the assessment of the situation to increase the useless cycle, the number of calculations. This kind of redundancy has little influence on the single calculation and evaluation, but in the process of game, it needs to evaluate thousands of nodes and calculate more nodes in a limited time. This can make the game system more stable and mature in the moves choice. So, this needs to be appropriate improvements and adjustments.
Taking other factors into consideration, the chessboard was still represented by a 10 × 10 two-dimensional integer arrays. In order to reduce unnecessary computation in the calculation process, we used structure to access chessboard information when we evaluated and calculated. This could reduce the miscellaneous computation and facilitated the entry of chess content. The structure contained two integer variables x and y. The variable x in the structure was used to represent the abscissa in the board, and the variable y was used to indicate the ordinate in the board. The structure of the initialisation phase in the program to generate a capacity of 50 arrays represented 50 chess areas. Access to the pieces of information in 50 chess areas was achieved through access to member x and member y of each array element. This improved the efficiency and laid a good foundation for the establishment of the Opening Book.

Generation and use of hash
The system used Zobrist hash [26][27][28] technology to initialise a two-dimensional array Zobrist [50] [5] at program starting up and filling the array with random numbers. The random number was 64-bit integer data and stored in a pre-set file. Each time the system started, simply read the data in the file to complete the data initialisation.
Hash calculated by all the chess areas on the information in the array Zobrist each element corresponding bitwise exclusive or calculation. The system needed to be calculated the hash of the new situation generated by the current situation. After the hash of the current situation and the random number of the chess areas pair that had been changed before the move are exclusive, the information corresponding to the chess areas after the change was subjected to the exclusive-OR operation.
For Ψ i = 0 n P i had the following definition: For If the hash value of a certain situation (A situation) was H 1 , then the following relationship: Situation B was crate after a move being taken in situation A, and the chess areas which changed were represented by a 1 , a 2 , a 3 … Then the following relationship: Q a n = Zobrist a n type Therefore, the hash value H 2 of B situation could be obtained from the following formula.

Structural design of Opening Book
In the draughts, different moved may produce the same situation, and the same moves may also correspond to different situations. Therefore, these factors should be considered when designing the Opening Book. Fig. 2 shows a demonstration of two different situations. Figs. 2a and b were two different situations in the draughts. At this point, the blue could move the pieces. There were 11 legal moves of the situation shown in Fig. 2a and 2 legal moves of the situation shown in Fig. 2b. It would generate the same situation, the situation was generated as shown in Fig. 3, after the situation in From this, we could know that different moves in different situations may produce the same situation. Therefore, the situation generator of the game system to select records in the first 20 steps for each game could be generated the situation information to create the database.  Design of structure was shown in Fig. 4, the long integer variable HashKey used to quickly determine whether the content of the game is matched. Integer array board was used to further compare information about the situation. Result was an integer array that records the result. Result [0] was the statistics of the 'first hand' position, and result [1] was the statistics of the 'back hand' position. Among them, the value of win was 2, the value of draw was 1, and the lose value was 0.

Generation of the Opening Book
Different moves in draughts may produce the same situation, and the same moves may also correspond to different situations. Therefore, these factors should be considered when designing the Opening Book. Before generating Opening Book, a structured array of BookInfo named 'Open Library' with a certain number of elements should be called.
To ensure the corresponding information of the first 20 steps of the 1561 matching was used as much as possible in the Opening Book. We counted the information, and in the results, we found that in the case of the same hash, no different situation was found, there was no hash conflict. The information in the Opening Book was stored in an array constructed by the structure BookInfo. However, the generated hash was a 64-bit long data, and that would make some difficulties in the using of hashes to access the database. Therefore, there was a necessary to make proper calculation for hash to shorten the length of the hash, and to determine the capacity of the constructed structure.
First, we removed the duplicate 64-bit long hash to make each hash unique. The hashes were then bitwise ANDed with 255 (0xFF), 4095 (0xFFF), 65535 (0xFFFF), 1048575 (0xFFFFF), and 16777215 (0xFFFFFF), respectively. The resulting value was called a 'short hash,' and the value that was used to shorten the hash could be used as the size of the structure array. The generated short hash was used as the index of the array. Table 2 was generated for different short hash statistics.
According to the data in Table 2, if 1048576 (0∼0xFFFFF) was used as the array capacity, we could make the best use of the information of all the situations in the Opening Book, but such an excessive array was unfavourable to the running of the program. If 65536 (0∼0xFFFF) was used as the array size, some situation information cannot be used because of some short hash conflicts. It could maximise the use of the structure of the efficiency and reduce the use of redundant memory, and lay a good foundation for the latter part of the optimisation. Therefore, in the current case, the number of array BookInfo elements was 65536 the most reasonable.

Use of Opening Book
In the Opening Book, we first needed the program needs to read data file of the Opening Book, and then filled in the relevant data information after initialising the array. HashKey default value was −1, Opening Book may encounter uncounted situations in actual use, the hash generated by these situations to find the array information was obviously meaningless. So, we defaulted value of −1 for the HashKey to determine whether the structure of the array makes sense, to avoid one by one each of the chess area caused by the waste of computing resources. The relevant pseudo-code was as follows (Fig. 5): The use of Opening Book first needed to determine the number of legal moves. If there was no legal move or only one, the relevant information should be returned. If there were multiple legitimate moves, these moves needed to be selected.
For these moves to be selected, the system generated the situation information after completing the moves one by one and generates a hash and finishes searching the array of structures. The information in each of the Chess areas was then compared one by one to see if the situation was the same, and then the moves and results of the same situations were stored in the list of candidates. After all the moves traversal was completed, the preferred method was to score high. If all results stored for pending moves were negative, there was still situation information that was successfully match Opening Book. Use traditional evaluation, search methods in moves that had not been matched with the database. If there was absolutely no matching situation information, the best moves should be selected according to the traditional evaluation and search techniques.

Improvement of traditional search method
In order to improve the utilisation efficiency of Opening Book, the game system start-stage was used the Alpha-bate to select the most  optimal moves, and added a database weight when the evaluation function was called to evaluate the cotyledon nodes. If the current situation did not match the Opening Book, but the cotyledon node could match the Opening Book and the situation was more favourable (with greater probability of winning or draw), the moves may be preferred. At the same time, it should be considered that the introduction of such a valuation system into the initial stock market would undoubtedly be useless for the game system to spend time matching the data in the mid-stage and the end-stage. Therefore, in the valuation of the database, we find that we would use only for the start-stage according to the search depth of the corresponding adjustments.

Experimental platform
In order to get better game data, we build a distributed system platform. As shown in Fig. 6, the platform is composed of two parts, the host computer and slave computer. The host is responsible for completing the task assignment and data statistics function, and the slave is responsible for completing the game execution. First, the host releases the game commands and parameters to each slave. After receiving the command, the game is executed according to the received parameters; then the host asks the slave to complete the game, and the player will return the game chess and the result to the player. The whole process continues until all the games are completed. The host automatically calculates and counts the results based on the results received.

Analysis of game results
The program with the Opening Book and the program without the Opening Book conducted multiple game experiments, and the statistical results were shown in Fig. 7. A total of 40,000 games were tested, of which won 30,071 times, 14,582 times was the first hand and 15,489 times was the second hand. It could be seen from the use of opening book played a good role. However, the analysis also found that using the Opening Book, the probability of eating the first five steps significantly reduced, completed the layout process, and no obvious offensive process. Also during the obvious offensive in the first 10 steps, it was clear that the early stages of the game play an important role in the overall opening. From the mid-stage, the two sides adjusted the layout so as to use more favourable situation to enter the end. This shows that Opening Book played a crucial role in mid-stage and end-stage.
In the future, we should consider optimising data structure to improve computational efficiency and data utilisation efficiency. Then we also need to improve the opening database data through the advanced international checkers program (such as Dragon and Dam).

Conclusion
In this paper, we discussed the design method of Opening Book of draughts game system. Through statistical analysis of information and sorting, Opening Book can be used in the draughts system. We put the Opening Book in the middle and early stages of the game to the introduction of the traditional Alpha-Beta search, which laid a good foundation for the post office. Finally, the optimisation method is put forward, and the design idea of 'learning' with advanced program was put forward. the optimisation method is put forward, and the design idea of 'learning' with advanced programs is put forward. We proved the effectiveness of the method through experiments and contributed to the design and research of the beginning of checkers. The method proposed in this paper is universal and can also be used for the opening research of other chess species. Next, we hope to add deep learning in the Opening Book, so as to further improve the level of draughts.