Code.cc
Go to the documentation of this file.
1 // cwchessboard -- A C++ chessboard tool set
2 //
3 //! @file Code.cc This file contains the implementation of class Code.
4 //
5 // Copyright (C) 2008, by
6 //
7 // Carlo Wood, Run on IRC <carlo@alinoe.com>
8 // RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt
9 // Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 2 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 
24 #ifndef USE_PCH
25 #include "sys.h"
26 #endif
27 
28 #include "Code.h"
29 #include "CwChessboardCodes.h"
30 
31 namespace cwchess {
32 
33 /*
34  * Code is encoded as CTTT, where C is the color and TTT the type.
35  * CwChessboardCode is encoded as TTTC.
36 *
37  * In both cases, 0 is black and 1 is white, however TTT is encoded differently.
38 *
39  * Code uses:
40  * nothing = 0,
41  * black_pawn = 1,
42  * black_knight = 2,
43  * black_king = 3,
44  * black_bishop = 5,
45  * black_rook = 6,
46  * black_queen = 7,
47  * white_pawn = 9,
48  * white_knight = 10,
49  * white_king = 11,
50  * white_bishop = 13,
51  * white_rook = 14,
52  * white_queen = 15.
53 *
54  * CwChessboardCode uses:
55  * empty_square = 0,
56  * black_pawn = 2,
57  * white_pawn = 3,
58  * black_rook = 4,
59  * white_rook = 5,
60  * black_knight = 6,
61  * white_knight = 7,
62  * black_bishop = 8,
63  * white_bishop = 9,
64  * black_queen = 10,
65  * white_queen = 11,
66  * black_king = 12,
67  * white_king = 13.
68 * /
69 CwChessboardCode Code::Code_to_CwChessboardCode[16] = {
70  ::empty_square, /* nothing = 0* /
71  ::black_pawn, /* black_pawn = 1* /
72  ::black_knight, /* black_knight = 2* /
73  ::black_king, /* black_king = 3* /
74  0, /* unused (4)* /
75  ::black_bishop, /* black_bishop = 5* /
76  ::black_rook, /* black_rook = 6* /
77  ::black_queen, /* black_queen = 7* /
78  0, /* unused (8)* /
79  ::white_pawn, /* white_pawn = 9* /
80  ::white_knight, /* white_knight = 10* /
81  ::white_king, /* white_king = 11* /
82  0, /* unused (12)* /
83  ::white_bishop, /* white_bishop = 13* /
84  ::white_rook, /* white_rook = 14* /
85  ::white_queen /* white_queen = 15* /
86 };
87 
88 CodeData Code::CwChessboardCode_to_Code[14] = {
89  { 0 }, /* empty_square = 0* /
90  { 0 }, /* unused (1)* /
91  black_pawn, /* black_pawn = 2* /
92  white_pawn, /* white_pawn = 3* /
93  black_rook, /* black_rook = 4* /
94  white_rook, /* white_rook = 5* /
95  black_knight, /* black_knight = 6* /
96  white_knight, /* white_knight = 7* /
97  black_bishop, /* black_bishop = 8* /
98  white_bishop, /* white_bishop = 9* /
99  black_queen, /* black_queen = 10* /
100  white_queen, /* white_queen = 11* /
101  black_king, /* black_king = 12* /
102  white_king /* white_king = 13* /
103 };
104 
105 } // namespace cwchess
CodeData const black_pawn
A constant representing a black pawn.
Definition: Code.h:66
A namespace for all chess related objects that are not related to the GUI.
Definition: Array.h:39
CwChessboardCode const empty_square
uint16_t CwChessboardCode
A code to specify a chess piece.
CodeData const white_queen
A constant representing a white queen.
Definition: Code.h:62
CodeData const black_queen
A constant representing a black queen;.
Definition: Code.h:74
CodeData const black_rook
A constant representing a black rook;.
Definition: Code.h:68
CodeData const white_rook
A constant representing a white rook.
Definition: Code.h:56
CodeData const black_bishop
A constant representing a black bishop;.
Definition: Code.h:72
CodeData const black_king
A constant representing a black king;.
Definition: Code.h:76
CodeData const white_pawn
A constant representing a white pawn.
Definition: Code.h:54
CodeData const black_knight
A constant representing a black knight;.
Definition: Code.h:70
CodeData const white_king
A constant representing a white king.
Definition: Code.h:64
This file contains the definitions of the CwChessboardCode constants.
This file contains the declaration of class Code.
CodeData const white_bishop
A constant representing a white bishop.
Definition: Code.h:60
CodeData const white_knight
A constant representing a white knight.
Definition: Code.h:58

Copyright © 2006 - 2010 Carlo Wood.  All rights reserved.