Color


 * Home * Chess * Color**
 * [[image:DayandNight.jpg width="371" height="215" link="http://www.mcescher.com/Gallery/switz-bmp/LW303.jpg"]] ||~   || In Chess, **Color** refers to the color of the two piece sets, the color each player is assigned to, the side to move and the color of a square.

The pieces are divided, into white and black sets, but their colors should not taken literally. The players are referred to as "White" and "Black", they control their associated pieces. The colors of the sixty-four squares alternate and are referred to "light squares" and "dark squares", sometimes also referred to "White" and "Black" squares. || toc =Color Definition= Since there are only two colors, one bit is sufficient to encode them. This is how one may define colors in C++: code format="cpp" enum enumColor { ecWhite = 0, ecBlack = 1 }; code
 * M. C. Escher, Day and Night, 1938 ||~  ||^   ||

=Toggle Color= Since the players alternately move, one need to toggle the side to move color after each move made inside the Chess Position object. This can be done by subtracting color from one (ecBlack), ... code format="cpp" inline enumColor toggleColor(enumColor color) { return ecBlack - color; } code ... or a little bit cheaper by xoring with the color with one (ecBlack). code format="cpp" inline enumColor toggleColor(enumColor color) { return color ^ ecBlack; } code =See also=
 * Color Flipping
 * Color of a Square
 * Color Weakness
 * Side to move

=External Links=
 * [|Color from Wikipedia]
 * [|Black-and-white from Wikipedia]
 * [|Black-and-white dualism from Wikipedia]
 * [|Black & White (video game) from Wikipedia]
 * [|Black from Wikipedia]
 * [|White from Wikipedia]

=References= =What links here?= include page="Color" component="backlinks" limit="90"
 * Up one Level**