Side to move

From Chessprogramming wiki
Revision as of 16:54, 10 May 2018 by GerdIsenberg (talk | contribs) (Created page with "'''Home * Chess * Position * Side to move''' '''Side to move''' is either the white or black player, who alternatively have the right and...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Home * Chess * Position * Side to move

Side to move is either the white or black player, who alternatively have the right and the obligation to move. Thus, side to move is a mandatory member or variable inside a Position structure or object, usually a variable or member of a defined Color value range {0,1} or {white, black}, which is toggled after each make - or unmake move. Alternatively, one may use a boolean with the semantic White to move (wtm) or the complement (Black to move - btm)

btm = !wtm
btm =  1 - wtm; // assuming color ::= {0,1} enum
btm =  wtm ^ 1; // assuming color ::= {0,1} enum

In the Forsyth-Edwards Notation the side to move is specified after the piece placement with the lowercase letters 'w' or 'b'.

However, inside a search tree object, it is sufficient to keep the side to move inside the root node only, and to further rely on the least significant bit (lsb) of the ply-index, which is likely maintained during the search anyway. The ply-index is initialized with zero at the root and incremented after each half move played down the tree. If the ply-index is even (lsb clear) at any node, it has the side to move of the root, odd plies (lsb set) imply the other side to move:

side_2_move = (side_2_move@root + ply) & 1; // assuming color ::= {0,1} enum

See also

Forum Posts

Up one Level