00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "sys.h"
00025 #include <iostream>
00026 #include <iomanip>
00027
00028 using std::cout;
00029 using std::endl;
00030
00031 struct Direction {
00032 int x;
00033 int y;
00034 };
00035
00036 struct Piece {
00037 char const* name;
00038 int depth;
00039 int nrdirs;
00040 Direction direction[4];
00041 };
00042
00043 Piece piece[] = {
00044 { "Knight", 1, 4, { { 1, 2 }, { 2, 1 }, { 2, -1, }, { 1, -2 } } },
00045 { "King", 1, 4, { { 0, 1 }, { 1, 0 }, { 1, 1 }, { 1, -1 } } },
00046 { "Bishop", 8, 2, { { 1, 1 }, { 1, -1 } } },
00047 { "Rook", 8, 2, { { 0, 1 }, { 1, 0 } } },
00048 { "Queen", 8, 4, { { 0, 1 }, { 1, 0 }, { 1, 1 }, { 1, -1 } } }
00049 };
00050
00051 uint64_t colrow2mask(int col, int row)
00052 {
00053 return CW_MASK_T_CONST(1) << ((col << 3) + row);
00054 }
00055
00056 int main()
00057 {
00058 for (int p = 0; p < 5; ++p)
00059 {
00060 cout << "// " << piece[p].name << '\n';
00061 for (int col = 0; col < 8; ++col)
00062 {
00063 for (int row = 0; row < 8; ++row)
00064 {
00065 uint64_t mask = 0;
00066 for (int dir = 0; dir < piece[p].nrdirs; ++dir)
00067 {
00068 for (int depth = -piece[p].depth; depth <= piece[p].depth; ++depth)
00069 {
00070 if (depth == 0)
00071 continue;
00072 int tcol = col + depth * piece[p].direction[dir].x;
00073 if (tcol < 0 || tcol > 7)
00074 continue;
00075 int trow = row + depth * piece[p].direction[dir].y;
00076 if (trow < 0 || trow > 7)
00077 continue;
00078 mask |= colrow2mask(tcol, trow);
00079 }
00080 }
00081 std::cout << std::hex << "{ CW_MASK_T_CONST(0x" << std::setfill('0') << std::setw(16) << mask << ") }, ";
00082 if (row == 3)
00083 std::cout << '\n';
00084 }
00085 std::cout << '\n';
00086 }
00087 }
00088 }