Comments/Ratings for a Single Item
I don't understand the null move usage here either. The way I have made the rules, the joker has a null move only at the beginning of the game!

"null move" is not no moves. A null move is a player passing a turn without moving. This is not legal in Chess, but chess programs do it anyway as a way to cut out part of the search tree.
Oh, ok!

The FIDE "laws of Chess" define check in terms of being attacked, and 'attack' in terms of pseudo-legal moves of the pieces. This does not allow for the pseudo-legal moves to change over time, and tacitly assigns the same pseudo-legal moves to a piece whether it is its turn to move or not. So it involves the fiction that the checking side can move, even if it is not his turn. To move out of turn you would either have to do two moves in the same turn, or let the opponent pass his turn between the two moves. This is how the null move enters the discussion.
Legality of moves in FIDE in general is completely covered by the rule "it is not legal to expose your King to capture, except for capturing the opponent King". Only castling is special, in that it is additionally declared illegal when the King starts or moves over an attacked square.
'Exposing to capture"is completely unambiguous. And it definitely does not indicate the interpretation you sketch above, where the Joker would "forbid a lot of King moves". The ambiguity is what moving out of check or through check means. Note that Fergus avoided any ambiguity by stating that the Royal Queen in Caïssa Britannia can not pass through a square that it could not legally move to". This also seems the logical way to treat passing through check in the context of castling. (Except perhaps for 3-step castling, where the second step in itself would be illegal because it is not even pseudo-legal, and the phrase would have to replaced by "where it cannot legally teleport to if teleporting was a pseudo-legal King move.) The spirit of the rule is all about the King being shot down during the attempt, like e.p. capture. Like I said, this is not a Joker-specific problem; many other pieces whose pseudo-legal moves depend on context (lame leapers, hoppers) require more precise definition of when castling is allowed.
Being in check at the beginning of your turn (and moving out of it) is yet another matter. Which affects both castling legality, and the stalemate definition.
To apply these definitions to a Joker, it becomes essential to define when exactly the pseudo-legal moves of the Joker change. It cannot be at the start of a turn, as at that point it is not yet decided which piece is going to move, so you cannot know what the new moves are. Declaring it has no moves at that point comes "out of nowhere"; no other piece loses all its moves (for determing whether the opponent would castle out of check) after it finishes is move. It seems much less arbitrary to let it keep its moves until another piece actually starts moving. That would affect whether you consider the side to move to be in check or not. And thereby whether castling is legal, or whether a terminal position is checkmate or stalemate. But nothing else.

This is not legal in Chess, but chess programs do it anyway as a way to cut out part of the search tree.
Or to test for check: when passing the turn would get your King captured.

Most of this makes sense. I'm not entirely sure -- the thread on talkchess was so long ago I don't really remember, but people much smarter than I argued the point -- but I don't really care either. I consider the Joker itself a bad idea, so I don't care exactly how it acts so long as I can implement it without making any significant changes to the architecture of the program itself. And I think that is doable... It makes the implemention of the ImmitatorRule a bit more complicated because it needs to track how each side's Jokers move individually, but that shouldn't be a big deal. I think attack detection should also be ok.
Aurelian, are you in agreement that this is how it should work? To be clear, let's make sure I understand... White moves a Queen. Then black moves a Knight. It is now white's turn again. At this instant, for purposes of determining if the white King is in check, black's Joker still moves as a Queen. White decides to move a Bishop. At this moment, for purposes of deciding if white's King is in check, black's Joker moves as a Bishop. If white's King is not in check, it is black's move again. At this instant, for purposes of determining if black's King is in check, white's Joker moves as a Knight.
with a lame Dababba (nD) on d1, could you play O-O? I would say 'no', because after the King steps to f1, the nD could capture it. But with the King still on e1 the nD cannot capture to f1.
Now this is an interesting question. I'm inclined to agree ... castling should not be allowed because the lame Dababba could theoretically capture the King as it moves through. That said, that is probably not how ChessV works at present. I guess the truly correct way to do it is to move the King to each square in sequence and ask "am I in check" at each step. But that's expensive. It would probably be adequate just to lift the King off the board before doing the attack detection on the squares.

White moves a Queen. Then black moves a Knight. It is now white's turn again. At this instant, for purposes of determining if the white King is in check, black's Joker still moves as a Queen.
That seems consistent. If black would have moved his Joker (as a Queen) instead of the Knight, and this Joker would then have delivered a Queen-like check at the end of this move, it seems logical that you could also use it to deliver a discovered check, by unblocking it with the Knight.
It can still be freely chosen whether the Joker would mimic the last-moved piece of the opponent, or the last-moved piece period. The rules could have been such that the black Knight move switches both Jokers to Knights, instead of just the black one. This is just a different kind of imitator.
All this would only be relevant if you aim a Joker at an uncastled King, which would want to castle on that move. It seems unusua that someone would expose his King this way, so the practical difference might be awfully small.

It can still be freely chosen whether the Joker would mimic the last-moved piece of the opponent, or the last-moved piece period. The rules could have been such that the black Knight move switches both Jokers to Knights, instead of just the black one. This is just a different kind of imitator.
Hmmm... The second option would be slightly easier to implement because it's closer to how it is currently written. It also might be easier to understand -- maybe. But I have no strong opinion either way.

Ooo... Something else I didn't consider. Games with Jokers need to amend the FEN format. The FEN will need to store what type(s) are currently being imitated.

Use the e.p. square to indicate the last-moved piece. For true e.p. rights it would be empty, implying a Pawn must be imitated.
This is also simpler when differently colored Jokers always have the same move. Which I think is conceptually simpler anyway. So it would probably the best choice.
The Joker has to imitate the last piece moved by the opponent so if white has moved a queen then it's black's turn and the black joker has queen powers for the purpose of checking. So in KJK the joker should unambiguously move as a king. I'm not sure why the rest isn't just an implementation problem.
Thanks a lot guys for taking the time to do this for me, as I am the main beneficiary of this code!

That might technically work, but I do not see any positive in hijacking the e.p. square in this way. The ep square is used by the code handling en passant - it won't and shouldn't know anything about imitators. Sure, I could program the en passant rule to just ignore values that don't seem appropriate, but that is just a hack and hacks don't lead to long term code understandably or maintainability. And, as you note, this wouldn't even work with the scenario where different colored Jokers move differently.
Some games just need additional state information to be stored - there's no way around it. For example, Carlos Cetina's Symmetric Chess needs to store the Bishop Conversion Rule properties. I don't think you will come up with a clever way to sneak that information into existing FEN structure. (This reminds me, I need to post on that page exactly how I've extended FEN to accommodate this. Been meaning to do that for a long time now.)
But I do agree that both Jokers having the same move is conceptually simpler and therefore preferable.
Well, I don't see any trouble with both joker having the same movement powers both players don't have their turns at the same time, but honestly I don't understand the details of what you two guys are talking about. It is just that I'm very grateful that you are basically helping me design my own games!

in KJK the joker should unambiguously move as a king
Sure - there is nothing else so this is a pretty easy case.
so if white has moved a queen then it's black's turn and the black joker has queen powers for the purpose of checking
This is not the question. The question is, after white moves a Queen, how does white's Joker move for the purposes of determing if black's King is in check (or moves through check while castling). Does it also move as a Queen, or does it move as whatever piece black last moved?
I'm not sure why the rest isn't just an implementation problem.
There is obviously an implementation issue, but there may also be conceptual issues. We have run into lots of questions, have we not? And, years later, we are still not sure. H.G. seems to think we can eliminate all ambiguity with careful definition. And he might be right; I'm not so sure.
Thanks a lot guys for taking the time to do this for me
You're welcome. But this is the kind of thing that we like thinking about, which is probably why we have both been working on universal chess programs for decades now :)
Oh, now I understand. After white has moved the white joker has no move as it is it's default. Check should be checked only immediately after the enemy moved. I think I had this discussion with Fergus a while ago.At least this is how I see it. But I'm quite sure that then you cannot have the same move for both jokers!

Oh, now I understand. After white has moved the white joker has no move as it is it's default. Check should be checked only immediately after the enemy moved.
Ah! But now we're right back to exactly how ChessV is implemented now! Where KJK is a draw, not a win... If the Joker doesn't check the enemy, how can King+Joker possibly checkmate?

Well, I think he meant that during your own turn enemy Jokers have no move (so that you can never move into their check), but that whether they deliver check should be judged in the opponent's turn (after he released the piece, but before he pressed the clock, as it were).

Well, I think he meant that during your own turn enemy Jokers have no move (so that you can never move into their check), but that whether they deliver check should be judged in the opponent's turn (after he released the piece, but before he pressed the clock, as it were).
This does not make sense to me. It sounds good but does not really clarify anything for me. It might be helpful to discuss an actual situation. In this position, black has just moved his King into the corner:
So now white's Joker moves as a King and moves to b2:
Is black's King in check or not? If not, then that's a stalemate. I do not think saying "whether they deliver check should be judged in the opponent's turn (after he released the piece, but before he pressed the clock, as it were)" changes anything. Any move the black King makes, it will then be judged that he is in check, so that move is illegal. Any move the black King makes is illegal, so the game is over. Whether it is checkmate or stalemate is determined by whether the King is in check. Am I missing something?
I know it's not my piece, but I would think that the Joker does check the king, since the king was the previously moved piece. It seems weird that the Joker could ever have no movement at all.
@Daniel,
This is not my piece either. I'm just using it. The joker has no movement at the beginning of the game.
@Greg,
The way I see the situation at hand (the actual situation that has started this discussion), the black king will be captured at the next move and this counts as a check to me, even if we are very technical about it, it is not. I'm afraid I have no further understanding on the matter

We can summarize this as:
- To judge whether in check at the start of your turn, the enemy Joker should be imagined to still have the move of the previous turn.
- To judge whether you are in check during or at the end of a turn, you should imagine the Joker to move as the piece that is moving in that turn.
Now Greg's example was special, because the Joker itself moved. If the white King had been on c2, the Joker on a5, and a white Knight on a4, and on the move before Queens were traded at c3, where the Knight recaptured (Na4xc3)... Is this checkmate or stalemate?
The Diagram considers it stalemate, because it lets the white Joker move as Knight after 1... Qxc3 2. Nxc3.
I think I had not understood this earlier. Now I see the conundrum.
This is a checkmate because the joker still has black queen's powers. Only after black moves the power is changed. In this case it cannot. So it is at least a stalemate. But for the reason stated above the black king is also in check.
Isn't this the same situation with having the king and joker unobstructed on the same orthogonal? This pins all rooks, queens, chancellors and so on.
@Greg,
I see why you hate the joker! And probably for similar reasons I love it!

Isn't this the same situation with having the king and joker unobstructed on the same orthogonal? This pins all rooks, queens, chancellors and so on.
No, this is different: moving a pinned piece is something the opponent punishes in his own turn, by capturing the King. The question here is whether the side that moved has delivered check with this move. Even when he does, he cannot capture the King. Because it is not his turn.
Anyway, the Diagram considers this stalemate, because the Imitator moves like a Knight. This is how I defined the I atom in XBetza:
A new atom in XBetza is I. Unlike the other atoms, it does not represent a fixed move: it stands for "all moves of the most recently moved (or imitated) piece type".
The most-recently moved piece is a Knight here. It doesn't say anywhere that the piece has to be an opponent. In your own turn it would of course be one. So this doesn't affect how the Joker moves. Just how it delivers check (which again is only important in the case of mate or castling).
25 comments displayed
Permalink to the exact comments currently displayed.
I'm sorry, I do not understand what you are asking. When a King is stalemated, the game is over.
There was a very long discussion about this on talkchess and another discussion here. The way I've programmed it was the concensus at the time, and for good reasons. I could change it, but I think you would like the results of that even less. It would forbid a lot of King moves. (The problem goes way beyond castling through check.) A King cannot move to any square that is attacked -- if the Joker still has its previous powers, it is potentially attacking a lot of squares and stopping the King from moving to them, despite the fact that if he did, the Joker would no longer be able to capture him because its powers have changed. Whether or not the Joker could actually capture the King on the next move is irrelevant. At the time of the King's move, the Joker either still has its powers or it doesn't. You can't have it both ways.
The Joker having the powers of the King when the other side is on the move is at least logically consistent. I don't like it, but then again, I don't like the Joker. Also, I don't understand why you are mentioning null move. I'm not sure what that has to do with anything.