After reading the post on
the Chess Bot Habré , I wanted to make my own, but since I thought that chess would not work right away, I decided to practice on checkers (so that there was more motivation I took the famous Russian Stripes).
Unlike the above mentioned post, where only a few screenshots and video, I will try to tell you more ...

Probably more pictures would not allow censorship.
Description
The goal is a program that instead of us will play (and preferably win) checkers against the computer (“Girls” mode) or the player (“Duel” mode). In principle, you can even run two programs and let them play.
To begin with, let's look at what functional parts we will have (given associations with a real player, in the spoiler - more specifically):
Eyes - to see the field what kind of figures are on it;At first there was an idea to implement field recognition based on OpenCV.
Refused through demanding of resources, and redundancy. Theoretically, it was possible to check several pixels and get a more or less correct result.
But, we stopped at the fact that we parse the field into separate squares.




and compare the "photographed" with these.
After that, we transfer all information to the brain.
Player (with Brains) - starts the game, looks at what moves are available (according to the rules);
Here, on the basis of the information we have seen, we are looking for all the available moves, perebyry all the checkers of our color and checking whether it is possible to make a move to the next diagonal cells.
If the next one is empty, you can make a move there, if it is occupied by the opponent’s figure, and the next one after it (diagonally) is free, then you can make a punch. After that, the possibility of this move is recorded in the list of available ones, and if you need to “hit”, then this move is marked as a priority one.
Logic - makes decisions on choosing one move from the list of available ones;Now, the logic is implemented only for selecting first priority moves (where it is necessary to hit), and then from all the others. The choice is made arbitrarily. If you want to hit two or more, simply call the method again. In the second part, I implement a more suitable algorithm. For demonstration and in order to play in this version of the game it was enough.
Hands - to actually make a move.Here probably the easiest functionality. After the move has been selected, the cursor moves to the position from which to take the figure, click, move where to put, and click again. If you had to hit two, three or more, just called several times.
Result

It turned out a program that can play checkers in almost any environment: an online game in a browser, a program like in a photo or something else. Just before the start, she will need to be taught how the figures and the field look. A lot more needs to be added, for example:
- The possibility of processing the ladies so that they can walk not only as ordinary checkers.
- Add logic to select the most successful moves.
- It is better to handle the completion of the game.
- Automatically learn where the field is and how it looks.
Afterword
The program was written with a friend (wait soon for Habré), for 3 hours. Please do not throw shoes, as they wrote after the working day and “just4fun”. Comments, comments, suggestions are welcome ...
Tomorrow I will add a video of the game process.
The program is written in Java (the first thing that came to hand and in principle came up).
Result on githubHere is the game, with everyone's Friday!