Indeed. In Joker I first detect pins, ad then for each pinned piece I encounter I generate the moves along the pin ray. (Note this includes a pawn capturing its pinner, something I discovered only late...grant wrote:Maybe this is stating the obvious but it has only just dawned on me.
If I know that my bishop or rook is pinned and I know the pinner, I need to find out if my piece can move along the pin ray
GrantCode: Select all
rankDiff = (pinner >> 3) ^ (pinned >> 3); fileDiff = (pinner & 7) ^ (pinned & 7); if (rankDiff == 0 || fileDiff == 0) //bishop cannot move //rook can move else //bishop can move //rook cannot move

This was where I went wrong when I converted Joker to play Knightmate, where the Knights move as Kings: A pinned Knight never has any moves, but a pinned King always has two moves along the pin ray. (One ca be blocked by its monarch.) So some moves were never generated...

In Chinese Chess you can even be pinned by a Knight!