Changes

Jump to: navigation, search

Color

2,750 bytes added, 12:02, 29 August 2018
Created page with "'''Home * Chess * Color''' border|right|thumb|240px| [[:Category:Viktor Vasnetsov|Viktor Vasnetsov - [https://en.wikipe..."
'''[[Main Page|Home]] * [[Chess]] * Color'''

[[FILE:Страшный суд.jpg|border|right|thumb|240px| [[:Category:Viktor Vasnetsov|Viktor Vasnetsov]] - [https://en.wikipedia.org/wiki/Last_Judgment Last Judgment] <ref>[https://en.wikipedia.org/wiki/Last_Judgment Last Judgment] fresco by [[:Category:Viktor Vasnetsov|Viktor Vasnetsov]], between 1885 and 1896, [https://en.wikipedia.org/wiki/St_Volodymyr%27s_Cathedral St. Vladimir's Cathedral], [https://en.wikipedia.org/wiki/Kiev Kiev], [https://en.wikipedia.org/wiki/Ukraine Ukraine], [https://en.wikipedia.org/wiki/Black-and-white_dualism Black-and-white dualism from Wikipedia], [https://en.wikipedia.org/wiki/Wikimedia_Commons Wikimedia Commons]</ref> ]]

In Chess, '''Color''' refers to the color of the two [[Pieces|piece sets]], the color each player is assigned to, the [[Side to move|side to move]], and the [[Color of a Square|color of a square]].
The [[Pieces|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|squares]] alternate and are referred to "light squares" and "dark squares", sometimes also referred to "White" and "Black" squares.
<span id="Definition"></span>
=Color Definition=
Since there are only two colors, one bit is sufficient to encode them. This is how one may define colors in [[Cpp|C++]]:
<pre>
enum enumColor {
ecWhite = 0,
ecBlack = 1
};
</pre>
=Toggle Color=
Since the players alternately move, one need to toggle the [[Side to move|side to move]] color after each [[Moves|move]] made inside the [[Chess Position]] object. This can be done by subtracting color from one (ecBlack), ...
<pre>
inline enumColor toggleColor(enumColor color) {
return ecBlack - color;
}
</pre>
... or a little bit cheaper, by xoring the color as left operand inside a register or memory cell with an immediate constant (ecBlack).
<pre>
inline enumColor toggleColor(enumColor color) {
return color ^ ecBlack;
}
</pre>
=See also=
* [[Color Flipping]]
* [[Color of a Square]]
* [[Color Weakness]]
* [[Side to move]]

=External Links=
* [https://en.wikipedia.org/wiki/Color Color from Wikipedia]
* [https://en.wikipedia.org/wiki/Black_and_white Black and whitefrom Wikipedia]
* [https://en.wikipedia.org/wiki/Black-and-white_dualism Black-and-white dualism from Wikipedia]
* [https://en.wikipedia.org/wiki/Black_%26_White_%28video_game%29 Black & White (video game) from Wikipedia]
* [https://en.wikipedia.org/wiki/Black Black from Wikipedia]
* [https://en.wikipedia.org/wiki/White White from Wikipedia]

=References=
<references />
'''[[Chess|Up one Level]]'''
[[Category:Viktor Vasnetsov]]

Navigation menu