Design of smart chess board that can predict the next position based on FPGA

Article history: Received: 29 June, 2018 Accepted: 26 July, 2018 Online: 29 July, 2018 The abilities of human brain to discover solutions for many problems is a great gift that motivate the scientists to develop the revolution of the artificial intelligence and using it in many areas. This paper proposed an intelligent chessboard which works in a way that similar to the human brain that predicts the next positions for any piece of the chess. MATLAB is used in the training of the artificial neural networks of the chessboard and implemented on FPGA as a hardware part; the proposed system has many advantages such as the low cost of production with a high efficiency in the prediction of the position of any piece on the chessboard and the similarities to the human brain.


Introduction
This paper is an extension of work originally presented in 4th IEEE International Conference on Engineering Technologies and Applied Sciences (ICETAS) [1].
In the early centuries, wars among major countries were in the zenith of prosperity, and the countries that have consultants who develop strategic plans for the Wars were prevail these wars; therefore, a game known as "kings game" was appeared. This game helps in developing the strategic plans without any human losses; it was spread rapidly in most countries and enticing many people because of its ability to motivate the human mind to think in a smart way. Furthermore, many schools in the world start to teach this game and considering it as the one of the games that test the intelligence [2]. Currently, and due to the tremendous evolution of the modern technology, many researches tries to make this game plays on the computers [3] [4]. They start to develop many programs that simulate chess game, however, playing this game can take many hours as known and sitting on computers for many hours can leads to serious problem such as headache, blurred vision and back pain etc. a large number of papers proved that the neural networks and intelligent systems have great dependency in many areas [5] [6] [7]. Many attempts in papers to build intelligent chess games have been done with disadvantages of very high costs used for designing the systems and complex electrical circuit.
However, there are a great number of researches in this area; [8] presents chess game in real time by using MATLAB environment without using for any chess engine, the system designed to detecting the chess movements depending on RGB webcam, and that means the complexity in the system designed may obtain incorrect positions during the game, the system have high cost with low accuracy. [9] presents chess board that can play against human depending on robotic arm which is five degree of freedom, the control system designed to control the speed and the position of the robotic arm, the designed system depend on the use of computer and that too expensive with very complex in the design that take long period of time to control the speed and the position. [10] Presents an attempt to design chess play against human and calculate its moves, the system implemented on microcontroller and the computer used to control chess movement, the system gave not perfect results and the use of computer also ASTESJ ISSN: 2415-6698 have disadvantages as mentioned. [11] Presents a robotic system play chines chess with human that can recognize pieces on the designed chessboard, the system designed to move the pieces of chess with the help of mechanical arm of robot, the system designed with expensive components. [12] Presents the chess game designed using MATLAB and electronics circuit for educational reasons, the system implemented on Arduino and the detection process for any piece to his place and type done by using Infrared light-emitting diode and photodiode, extra multiplexers, encoders and shift registers to increase the no. of I/P or O/P pins, this system have complex designed electronics circuit and high cost. [13] [14] present the FPGA in different systems and producing great efficiency in different area of researches and high speed in response. This paper merges two methods; the first one, is the ordinary method which used in the playing of the chess game. And the second method is the newest that used the technology methods to facilitate the playing of the game without using any computer device to decrease the damage that can be caused from playing the game as much as possible. The main contribution of this paper is to design an intelligent chessboard that can present the next positions for each piece and the avoidance of using computer due to different disadvantages that can occurred as a results of using it such as headache and blurred vision etc. The chessboard is designed by using a simple and low cost of electronics components that can compensate the using of computers which are used in many other chess game application.

Proposed System
Intelligent chessboard that can predict the next positions for all pieces of chess game is designed in this paper. Figure (1) shows the block diagram of the proposed system. It consists of 64 push buttons which are equally distributed, one button for each square on the chessboard; a simple press on any push button of the intelligent chessboard would send a notification to the proposed system with the exact position and the needing to predict the next positions. There are also 64 LASER diodes which are equally distributed as the push buttons, one LED for each square of the chessboard. In the chess game, there are 32 pieces which are divided equally into 16 pieces, (king, queen, rooks, Bishop, knights and pawns), for each player. Therefore, 32 LDR sensors were used and equally distributed as one sensor for each piece. Furthermore, the pressing of any piece would make the LEDs of chessboard glowed in order to notify the user with the next positions were the pressed piece can move on. The LDR sensors were used to distinct among the 32 pieces; they are connected serially with a constant resistance for each piece as that shown in Figure ( The light falling on the LDR sensor will produces a fixed range of voltage for each piece; because for each piece there is a different constant resistance; table (1) shows chess's piece types with corresponding voltages in the proposed system. In the chess game, there are 8 pawns for each player which can move in different paths and opposite direction; therefore, the range of voltages differ and divided into two team white pawns and black pawns as shown in table (1).

Simulation Results of Training
The human brain handles the processes in an amazing and smart way that distinct it from any other machines. Therefore, the neural networks of the proposed system trained in such a way that is similar to the human brain in order to notify the players with the next positions of the movement for every piece in a smart way. Super vised Feed forward neural networks were used to train all the pieces of chess game depending on back propagation algorithm [15]; and each piece types in chess was trained individually. The determination of the No. of neurons in the input layers, No .of neurons in the hidden layers, the No. of layers and also the activation functions in each network all done using Try and error method.

Rook
Finally, the rook piece in the chess game moves in different paths as compared with the other pieces, it has specific paths of movements on chessboard which can moves horizontally or vertically. Four no. of rook pieces in chess game which are divided equally into two teams, all rooks piece have the same paths of movements on the chessboard; therefore, the training of the rook was done individually for the first piece and repeated to the other pieces. In order to train the neural networks with the path of movements of the rook piece to act such as human brain, every square of the chessboard has sequential number begins with 1 and ends with 64. Any square which carry the rook piece will predict a different probability of the movements for the next positions of rook. Therefore, the networks of the chessboard trained with all possibility of movements for the rook piece on the chessboard. They are trained with six neurons in the hidden layer and fifteen neurons in the output layer as shown in Figure (  In the proposed chessboard a simple press over the rook piece, will lead to press the push button at the square with number one at the chessboard which will activate the laser diode to fall its light on the LDR sensor and depending on the voltage which produced from the LDR sensor and according to the range of voltage specified previously in table (1), the rook piece will be recognized. In more details, the reorganization process will lead to change the state of the LEDs to ON state over the designed chessboard and the exact squares (2,3,4,5,6,7,8,9,17,25,33,41,49, and 57) will be glowed to notify the player with the next available positions that the rook can move on.
The trained networks of rook piece converted into Simulink in order to test it and connect it with other networks in the next steps. The simulation results of rook piece movement for next positions shown in figure (6) The trained networks of the rook pieces converted into VHDL code by using MATLAB that have HDL coder in order to implement it on FPGA, figure (7) shows the RTL of rook pieces used in proposed system and figure (8) shows the simulation results of intelligent networks of rook by using Xilinx ISE Design Suite 13.3.

Bishop
The Bishop piece in the chess game moves in different paths as compared with the other pieces, it has specific paths of movements on chessboard which can moves diagonally. The chess game has four pieces of bishop which are divided equally into two teams, all bishops piece have the same paths of movements on the chessboard; therefore, the training of the bishop was done individually for the first piece and repeated to the other pieces. In order to train the neural networks with the path of movements of the bishop piece to act such as human brain, every square of the chessboard has sequential number begins with 1 and ends with 64. Any square which carry the bishop piece will predict a different probability of the movements for the next positions of bishop. Therefore, the networks of the chessboard trained with the all possible movements of the bishop piece on the chessboard. They are trained with eight neurons in the hidden layer and twenty neurons in the output layer as shown in Figure (   In the proposed chessboard a simple press over the bishop piece at square twenty two, will lead the same processes mentioned in the rook piece and the bishop piece will be recognized. In more details, the reorganization process will lead to change the state of the LEDs to ON state over the designed chessboard and the exact squares (4,8,13,15,22, 29, 31, 36, 40, 43, 50, and 57) will be glowed to notify the player with the next available positions that the bishop can move on.
The trained networks of bishop piece converted into Simulink in order to test it and connect it with other networks in the next steps. Figure (12) show the simulation results of bishop piece movement for next positions.  The trained networks of the bishop pieces converted into VHDL code by using MATLAB that have HDL coder in order to implement it on FPGA, figure (13) shows the RTL of bishop pieces used in proposed system and figure (14) shows the simulation results of intelligent networks of bishop by using Xilinx ISE Design Suite 13.3.

Knights
The knight piece in the chess game moves in different paths as compared with the other pieces, it has specific paths of movements on chessboard which can moves in the shape of L for two square and can jumps on other pieces on the chessboard. The chess game has four pieces of knights which are divided equally into two teams, all knights piece have the same paths of movements on the chessboard; therefore, the training of the knight was done individually for the first piece and repeated to the other pieces. In order to train the neural networks with the path of movements of the knight piece to act such as human brain, every square of the chessboard has sequential number begins with 1 and ends with 64. Any square which carry the knight piece will predict a different probability of the movements for the next positions of knight. Therefore, the networks of the chessboard trained with the all possible movements of the knight piece on the chessboard. They are trained with twelve neurons in the hidden layer and eleven neurons in the output layer as shown in Fig (15). In the proposed chessboard a simple press over the knight piece at square thirty seven, will lead the same processes mentioned in the rook piece and the knight piece will be recognized. In more details, the reorganization process will lead to change the state of the LEDs to ON state over the designed chessboard and the exact squares (20, 22, 27, 31, 37, 43, 47, 52, and 54) will be glowed to notify the player with the next available positions that the knight can move on.

Queens
The queen piece in the chess game moves in different paths as compared with the other pieces, it is the strongest piece and has specific paths of movements on the chessboard, it can moves at paths that collect the both paths of the rook and bishop pieces at the chessboard. The chess game has two pieces of queen which are divided equally into two teams, all queen pieces have the same paths of movements on the chessboard; therefore, the training of the queen was done individually for the first piece and repeated to the other piece. In order to train the neural networks with the path of movements of the queen piece to act such as human brain, every square of the chessboard has sequential number begins with 1 and ends with 64. Any square which carry the queen piece will predict a different probability of the movements for the next positions of queen. Therefore, the networks of the chessboard trained with the all possible movements of the queen piece on the chessboard. They are trained with four neurons in the hidden layer and twenty neurons in the output layer as shown in Figure (   In the proposed chessboard a simple press over the queen piece at square thirty one, will lead the same processes mentioned in the rook piece and the queen piece will be recognized. In more details, the reorganization process will lead to change the state of the LEDs to ON state over the designed chessboard and the exact squares (4,7,13,15,22,23,24,25,26,27,28,29,30,31,32,38,39,40,45,47,52,55,59,63) will be glowed to notify the player with the next available positions that the queen can move on.

Kings
The king piece in the chess game moves in different paths as compared with the other pieces, it has specific paths of movements on the chessboard, it moves such as the queen piece with only one square. The chess game has two pieces of king which are divided equally into two teams, all king pieces have the same paths of movements on the chessboard; therefore, the training of the king was done individually for the first piece and repeated to the other piece.
In order to train the neural networks with the path of movements of the king piece to act such as human brain, every square of the chessboard has sequential number begins with 1 and ends with 64. Any square which carry the king piece will predict a different probability of the movements for the next positions of king. Therefore, the networks of the chessboard trained with the all possible movements of the king piece on the chessboard. They are trained with nine neurons in the hidden layer and twenty neurons in the output layer as shown in Figure (   In the proposed chessboard a simple press over the king piece at square forty three, will lead the same processes mentioned in the rook piece and the king piece will be recognized. In more details, the reorganization process will lead to change the state of the LEDs to ON state over the designed chessboard and the exact squares (34, 35, 36, 42, 43, 44, 50, 51 and 52) will be glowed to notify the player with the next available positions that the king can move on.
The trained networks of king piece converted into Simulink in order to test it and connect it with other networks in the next steps. The trained networks of the king pieces converted into VHDL code by using MATLAB that have HDL coder in order to implement it on FPGA, figure (31) show the RTL of king pieces used in proposed system and figure (32) shows the simulation results of intelligent networks of king by using Xilinx ISE Design Suite 13.3.

Pawns
The movement of pawn piece was the simplest and the easiest to know as compared with the other pieces as well as to reduce the cost of the internal design, whereas knowing the movement of the pawn piece was just single step either to the straight ahead or diagonally one step in the case of attack. Therefore, it was not mentioned with the other scenarios.

Conclusion
In this paper an intelligent chessboard designed to handle the processes such as human brain through predict the next positions of any piece at the chessboard. Different algorithms used in the training of the chessboard and the best one were used in the proposed system. Each piece of chess game trained individually by using MATLAB and the results tested with different states, all networks of pieces trained was combined together in one system that produce the intelligent chessboard. It converted into VHDL code by using HDL coder in MATLAB, the VHDL code of the proposed system tested with different states by using ISE Design Suite 13.3.