Using Java and its library java.net that provides the classes for implementing networking applications, the game was developed in four steps. The first step was to create the classes that establish the connection between server and client and make them communicating by passing messages through the network. The second step was to develop the logic of the Checkers game and to create an algorithm that follows the rules of the game. The third step was creating the graphic interface using the graphic resources provided by Java. The final step was to put everything together and run the application. These steps will be better explained in the next paragraphs.
The connection between two different computers is made through a type of chat between the machines. The computer one sends a message to the computer two. The computer two receives this message and read it, then sends a message back to the computer one that receives the message and read it, and so on. The content of the message is the movement that a player does in the board and is by using this chat between two machines that the program works.
The logic of the game was developed by following the standard rules for Checkers gamers, such as moves are allowed just on the dark squares, so pieces move diagonally, pieces are always limited to forward moves (toward the opponent), a piece making a non-capturing move (not involving a jump) may move one square, a piece making a capturing move (a jump) leaps over one of the opponent’s pieces, landing in a straight diagonal line on the other side, only one piece may be captured in a single jump, but multiple jumps are allowed on a single turn, and so on.
The graphic interface was created with a JFrame to organize all the elements such as board and the history of the game status and other messages exchanged with the server. In Figure 1, it is possible to see the client’s Checkers game, where the player has to enter with the IP address of the server and the port to connect with. The pawns were chosen to be grey and yellow and the moves are made by clicking in a pawn and then clicking in the square the player wants to move it. It is important to say that there is a graphic interface for each server and client, and each GUI has its own properties related to the connection and the use of sockets.