Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
direction_table.cc
Go to the documentation of this file.
1
// cwchessboard -- A C++ chessboard tool set for gtkmm
2
//
3
//! @file direction_table.cc Program used to generate cwchess::direction_table[].
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
#include "sys.h"
25
#include <iostream>
26
#include <iomanip>
27
28
using
std::cout;
29
using
std::endl;
30
31
struct
Direction
{
32
int
x;
33
int
y;
34
};
35
36
Direction
dirs[] = {
37
{ -1, -1 },
38
{ 0, -1 },
39
{ 1, -1 },
40
{ -1, 0 },
41
{ 1, 0 },
42
{ -1, 1 },
43
{ 0, 1 },
44
{ 1, 1 }
45
};
46
47
int
main()
48
{
49
int
count = 0;
50
for
(
int
row = 0; row < 8; ++row)
51
{
52
for
(
int
col = 0; col < 8; ++col)
53
{
54
for
(
int
d = 0; d < 8; ++d)
55
{
56
int
r = row;
57
int
c = col;
58
uint64_t mask = 0;
59
for
(;;)
60
{
61
c += dirs[d].x;
62
r += dirs[d].y;
63
if
(c < 0 || c > 7 || r < 0 || r > 7)
64
break
;
65
mask |= CW_MASK_T_CONST(1) << ((r << 3) + c);
66
}
67
if
((count % 4) == 0)
68
cout <<
" "
;
69
cout <<
"{CW_MASK_T_CONST(0x"
<< std::hex << std::setfill(
'0'
) << std::setw(16) << mask <<
")}, "
;
70
if
((++count % 4) == 0)
71
cout <<
'\n'
;
72
}
73
}
74
}
75
}
Direction
Definition:
candidates_table.cc:31
Copyright © 2006 - 2010 Carlo Wood. All rights reserved.