00001 // cwchessboard -- A C++ chessboard tool set 00002 // 00003 //! @file Code.cc This file contains the implementation of class Code. 00004 // 00005 // Copyright (C) 2008, by 00006 // 00007 // Carlo Wood, Run on IRC <carlo@alinoe.com> 00008 // RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt 00009 // Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61 00010 // 00011 // This program is free software: you can redistribute it and/or modify 00012 // it under the terms of the GNU General Public License as published by 00013 // the Free Software Foundation, either version 2 of the License, or 00014 // (at your option) any later version. 00015 // 00016 // This program is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU General Public License 00022 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 00024 #ifndef USE_PCH 00025 #include "sys.h" 00026 #endif 00027 00028 #include "Code.h" 00029 #include "CwChessboardCodes.h" 00030 00031 namespace cwchess { 00032 00033 /* 00034 * Code is encoded as CTTT, where C is the color and TTT the type. 00035 * CwChessboardCode is encoded as TTTC. 00036 * 00037 * In both cases, 0 is black and 1 is white, however TTT is encoded differently. 00038 * 00039 * Code uses: 00040 * nothing = 0, 00041 * black_pawn = 1, 00042 * black_knight = 2, 00043 * black_king = 3, 00044 * black_bishop = 5, 00045 * black_rook = 6, 00046 * black_queen = 7, 00047 * white_pawn = 9, 00048 * white_knight = 10, 00049 * white_king = 11, 00050 * white_bishop = 13, 00051 * white_rook = 14, 00052 * white_queen = 15. 00053 * 00054 * CwChessboardCode uses: 00055 * empty_square = 0, 00056 * black_pawn = 2, 00057 * white_pawn = 3, 00058 * black_rook = 4, 00059 * white_rook = 5, 00060 * black_knight = 6, 00061 * white_knight = 7, 00062 * black_bishop = 8, 00063 * white_bishop = 9, 00064 * black_queen = 10, 00065 * white_queen = 11, 00066 * black_king = 12, 00067 * white_king = 13. 00068 * / 00069 CwChessboardCode Code::Code_to_CwChessboardCode[16] = { 00070 ::empty_square, /* nothing = 0* / 00071 ::black_pawn, /* black_pawn = 1* / 00072 ::black_knight, /* black_knight = 2* / 00073 ::black_king, /* black_king = 3* / 00074 0, /* unused (4)* / 00075 ::black_bishop, /* black_bishop = 5* / 00076 ::black_rook, /* black_rook = 6* / 00077 ::black_queen, /* black_queen = 7* / 00078 0, /* unused (8)* / 00079 ::white_pawn, /* white_pawn = 9* / 00080 ::white_knight, /* white_knight = 10* / 00081 ::white_king, /* white_king = 11* / 00082 0, /* unused (12)* / 00083 ::white_bishop, /* white_bishop = 13* / 00084 ::white_rook, /* white_rook = 14* / 00085 ::white_queen /* white_queen = 15* / 00086 }; 00087 00088 CodeData Code::CwChessboardCode_to_Code[14] = { 00089 { 0 }, /* empty_square = 0* / 00090 { 0 }, /* unused (1)* / 00091 black_pawn, /* black_pawn = 2* / 00092 white_pawn, /* white_pawn = 3* / 00093 black_rook, /* black_rook = 4* / 00094 white_rook, /* white_rook = 5* / 00095 black_knight, /* black_knight = 6* / 00096 white_knight, /* white_knight = 7* / 00097 black_bishop, /* black_bishop = 8* / 00098 white_bishop, /* white_bishop = 9* / 00099 black_queen, /* black_queen = 10* / 00100 white_queen, /* white_queen = 11* / 00101 black_king, /* black_king = 12* / 00102 white_king /* white_king = 13* / 00103 }; 00104 00105 } // namespace cwchess