hgm wrote:
Using a square-dependent key for the Joker alias is a bit redundant, however. It is used here as a kludge to make sure that in absence of a Joker the 'Joker alias' does not affect the key. But the price is high, because you have to update joker_sqr, and use some trick to let it point to a dummy key that is zero when no Joker is present. Plus that it gets you into trouble when there would be multiple Jokers on the board.
No you have not understood at all. JOKER_0 is
_not_ to be used when there are no jokers, but at starting position when the type of joker is not defined because there is not an opponent's previous move.
hgm wrote:
In fact, all you would want is a signature of the current Joker piece type in the key when there is at least one Joker. So having an extra transient key jokerKey[pieceType][nrOfJokers] seems the cleanest solution
This is completely broken, but I will let you to figure it out yourself.
I just add that an alternative solution to avoid multiple joker pseudo-pieces per-square hash keys is to use only one per-square JOKER zobrist key set, considering it just another piece and then update the hash key upon opponent move in this way:
Code: Select all
pos_key ^= Zobrist::psq[piece_old][joker_sq] ^ Zobrist::psq[piece_new][joker_sq];
So for instance if opponent moves a rook and current joker aliases a bishop the key is updated, after usual updating code, as following:
Code: Select all
pos_key ^= Zobrist::psq[bishop][joker_sq] ^ Zobrist::psq[rook][joker_sq];
This scheme has the disadvantage that when you move a joker, you have to move also the corresponding piece, so, in the above example, if I move the rook-joker from old_sq to new_sq, after the usual key updating I have to add:
Code: Select all
pos_key ^= Zobrist::psq[rook][old_sq] ^ Zobrist::psq[rook][new_sq];
So all in all I still prefer my previous scheme.