Jump Move Generation in Checkers

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

universecoder
Posts: 53
Joined: Mon Sep 19, 2016 6:51 am

Jump Move Generation in Checkers

Post by universecoder »

Hi,
I am finding it difficult to generate a series of 'jump' moves in checkers, although I have been able to generate the 'simple' moves. Also, how do I give jumps/captures precedence over simple moves?

Another problem is that the pieces are "wrapping around" the board, how do I avoid that?

https://github.com/universecoder/anubis ... r/move.cpp
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Jump Move Generation in Checkers

Post by Evert »

universecoder wrote: I am finding it difficult to generate a series of 'jump' moves in checkers, although I have been able to generate the 'simple' moves.
What exactly is the problem you run into? The way to generate them is to make a normal move to an occupied square, then make a second step in the same direction to an empty square.
Also, how do I give jumps/captures precedence over simple moves?
During move generation, generate captures first. If you generated any, skip the quiet moves. You can also keep track of the longest capture sequence (I don't know if that's a thing in Checkers, in Draughts you must make the longest capture sequence) that way: generate all of them, but clear out the move list if you find a capture sequence that is longer than the ones you found so far.
Another problem is that the pieces are "wrapping around" the board, how do I avoid that?
Use a board that is (at least) one file larger than the actual board and put guards on the off-board squares: these are always treated as occupied by a friendly piece. This has the added benefit of removing the parity of the different ranks, so you can use the same step vector for odd and even ranks.
CheckersGuy
Posts: 273
Joined: Wed Aug 24, 2016 9:49 pm

Re: Jump Move Generation in Checkers

Post by CheckersGuy »

universecoder wrote:Hi,
Another problem is that the pieces are "wrapping around" the board, how do I avoid that?

http://www.3dkingdoms.com/checkers/bitboards.htm

I used the bitboard-layout described on that website. I found bitboards particularly usefull when generating moves
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: Jump Move Generation in Checkers

Post by AlvaroBegue »

universecoder wrote:Hi,
I am finding it difficult to generate a series of 'jump' moves in checkers, although I have been able to generate the 'simple' moves. Also, how do I give jumps/captures precedence over simple moves?
I didn't look at your code, but I have programmed a couple of checkers variants several times. I like to use a move representation that contains a bitboard indicating what pieces are being captured. You can start by generating simple captures and then looping over the captures you have and checking if they can be extended. If they can be extended, remove the partial capture and add the extended captures that result from it. At the end of the procedure, sort the moves and remove duplicates.
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Jump Move Generation in Checkers

Post by hgm »

I guess the chess variant Hug Mate is in a sense very similar to checkers, in that 'capture moves' sometimes can be extended to very long chains. The idea of this variant is that pieces never get truly captured in the sense that they are removed from the board. Instead, when you move to a square occupied by an opponent, both pieces stay on that square, to 'hug' each other. Such a hugging pair is immobile, and neither piece can break the hug to escape.

But when you move to a square that is occupied by a hugging pair, you release your own piece from the hug, and the arriving piece continues hugging. The released piece then moves away in the same turn. It then can potentially move to another hugging pair, release another piece there, etc. So when the density of hugging pairs gets large, you can get very complex moves, jumping from one hugging pair to the next, until you finally end on an empty square or non-hugging opponent. This is rather similar to multi-captures in Draughts.

The player that manages to hug the opponent's King wins the game. (Although it is perfectly safe for a King to engage in a hug on his own initiative.) It seems a very interesting game, although I got the idea it might get to be a bit too complex for humans.