Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
osl
ntesuki
rzone.h
Go to the documentation of this file.
1
/* rzone.h
2
*/
3
#ifndef _NTESUKI_RZONE_H
4
#define _NTESUKI_RZONE_H
5
#include "
osl/state/numEffectState.h
"
6
#include "
osl/ntesuki/ntesukiMoveGenerator.h
"
7
8
#include "
osl/ntesuki/ntesukiExceptions.h
"
9
#include "
osl/container/moveVector.h
"
10
11
#include <
osl/stl/vector.h
>
12
#include <bitset>
13
#include <iosfwd>
14
15
using namespace
osl::state;
16
17
namespace
osl
18
{
19
namespace
ntesuki
20
{
21
class
22
Rzone
23
{
24
typedef
std::bitset<0x100>
mask_t
;
25
mask_t
mask
;
26
public
:
28
Rzone
(NumEffectState state,
29
Player
p)
30
{
31
const
Square
pos = state.kingSquare(p);
32
if
(!pos.
isOnBoard
())
return
;
33
unsigned
int
index = pos.
index
();
34
ntesuki_assert
(index <
Square::indexMax
());
35
mask.set(index);
36
}
37
38
Rzone
() {}
39
40
Rzone
(
const
Square
pos)
41
{
42
unsigned
int
index = pos.
index
();
43
ntesuki_assert
(index <
Square::indexMax
());
44
mask.set(index);
45
}
46
48
bool
any
()
const
49
{
50
return
mask.any();
51
}
52
54
bool
test
(
Square
pos)
const
55
{
56
return
mask.test(pos.
index
());
57
}
58
60
bool
operator==
(
const
Rzone
rhs)
const
61
{
62
return
mask == rhs.
mask
;
63
}
64
66
Rzone
operator+
(
const
Rzone
rhs)
const
67
{
68
mask_t m = mask | rhs.
mask
;
69
return
Rzone
(m);
70
}
71
73
Rzone
operator-
(
const
Rzone
rhs)
const
74
{
75
ntesuki_assert
((rhs.
mask
& mask) == rhs.
mask
);
76
mask_t m = (rhs.
mask
^ mask) & mask;
77
return
Rzone
(m);
78
}
79
81
Rzone
update
(
const
Rzone
rhs)
82
{
83
mask_t mask_orig = mask;
84
mask |= rhs.
mask
;
85
86
mask_t mask_diff = (mask_orig ^ mask) & mask;
87
88
return
Rzone
(mask_diff);
89
}
91
friend
std::ostream&
operator<<
(std::ostream& os,
92
const
Rzone
& rzone)
93
{
94
return
os << rzone.
mask
;
95
}
96
private
:
97
Rzone
(mask_t _mask) : mask(_mask) {}
98
99
};
100
}
//ntesuki
101
}
//osl
102
103
#endif
/* _NTESUKI_SEACHER_H */
104
// ;;; Local Variables:
105
// ;;; mode:c++
106
// ;;; c-basic-offset:2
107
// ;;; End:
Generated on Sun Jul 21 2013 13:37:26 by
1.8.4