My Project
core
osl
move_classifier
kingOpenMove.cc
Go to the documentation of this file.
1
#include "
osl/move_classifier/kingOpenMove.h
"
2
#include "
osl/numEffectState.h
"
3
4
template
<osl::Player P>
5
template
<
bool
hasException>
6
bool
osl::move_classifier::KingOpenMove<P>::
7
isMemberMain
(
const
NumEffectState
& state,
Ptype
,
Square
from,
Square
to,
8
Square
exceptFor)
9
{
10
assert(! from.
isPieceStand
());
11
Square
king_position=state.template kingSquare<P>();
12
if
(king_position.
isPieceStand
())
13
return
false
;
17
assert(king_position != from);
21
Offset
offset=
Board_Table
.
getShortOffsetNotKnight
(
Offset32
(king_position,from));
26
if
(offset.
zero
() ||
27
offset==
Board_Table
.
getShortOffsetNotKnight
(
Offset32
(king_position,to)))
28
return
false
;
29
if
(!state.
isEmptyBetween
(from,king_position,offset,
true
))
return
false
;
30
Square
pos=from;
31
Piece
p;
32
for
(pos-=offset;;pos-=offset){
33
// TODO: exceptFor を毎回チェックする必要があるのはoffset方向の時だけ
34
if
(! ((hasException && (pos == exceptFor))
35
|| (p=state.
pieceAt
(pos), p.
isEmpty
())))
36
break
;
37
assert(pos.
isOnBoard
());
38
}
43
if
(! p.
isOnBoardByOwner
<
alt
(P)>())
44
return
false
;
45
return
Ptype_Table
.
getEffect
(p.
ptypeO
(),pos,king_position).
hasEffect
();
46
}
47
48
namespace
osl
49
{
50
// explicit template instantiation
51
template
struct
move_classifier::KingOpenMove<BLACK>
;
52
template
struct
move_classifier::KingOpenMove<WHITE>
;
53
54
template
bool
move_classifier::KingOpenMove<BLACK>::isMemberMain<true>
(
const
NumEffectState
&,
Ptype
,
Square
,
Square
,
Square
);
55
template
bool
move_classifier::KingOpenMove<BLACK>::isMemberMain<false>
(
const
NumEffectState
&,
Ptype
,
Square
,
Square
,
Square
);
56
template
bool
move_classifier::KingOpenMove<WHITE>::isMemberMain<true>
(
const
NumEffectState
&,
Ptype
,
Square
,
Square
,
Square
);
57
template
bool
move_classifier::KingOpenMove<WHITE>::isMemberMain<false>
(
const
NumEffectState
&,
Ptype
,
Square
,
Square
,
Square
);
58
}
59
60
// ;;; Local Variables:
61
// ;;; mode:c++
62
// ;;; c-basic-offset:2
63
// ;;; End:
osl::BoardTable::getShortOffsetNotKnight
const Offset getShortOffsetNotKnight(Offset32 offset32) const
Longの利きの可能性のあるoffsetの場合は, 反復に使う offsetを Knight以外のShortの利きのoffsetの場合はそれ自身を返す.
Definition
boardTable.h:119
osl::EffectContent::hasEffect
bool hasEffect() const
短い利きがあるか,間がemptyなら長い利きがある
Definition
effectContent.h:34
osl::NumEffectState
利きを持つ局面
Definition
numEffectState.h:34
osl::Offset32Base
差が uniqになるような座標の差分.
Definition
offset32.h:17
osl::Offset
座標の差分
Definition
basic_type.h:430
osl::Offset::zero
bool zero() const
Definition
basic_type.h:502
osl::Piece
駒.
Definition
basic_type.h:788
osl::Piece::ptypeO
PtypeO ptypeO() const
Definition
basic_type.h:824
osl::Piece::isEmpty
bool isEmpty() const
Definition
basic_type.h:913
osl::Piece::isOnBoardByOwner
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
Definition
basic_type.h:852
osl::PtypeTable::getEffect
const EffectContent getEffect(PtypeO ptypeo, Square from, Square to) const
fromにいるptypeoがtoに利きを持つか?
Definition
ptypeTable.h:112
osl::SimpleState::isEmptyBetween
bool isEmptyBetween(Square from, Square to, Offset offset, bool pieceExistsAtTo=false) const
Definition
simpleState.h:267
osl::SimpleState::pieceAt
const Piece pieceAt(Square sq) const
Definition
simpleState.h:167
osl::Square
Definition
basic_type.h:532
osl::Square::isPieceStand
bool isPieceStand() const
Definition
basic_type.h:576
osl::Square::isOnBoard
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する.
Definition
basic_type.h:583
kingOpenMove.h
osl
Definition
additionalEffect.h:6
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition
basic_type.h:84
osl::Ptype_Table
const PtypeTable Ptype_Table
Definition
tables.cc:97
osl::Board_Table
const BoardTable Board_Table
Definition
tables.cc:95
osl::alt
constexpr Player alt(Player player)
Definition
basic_type.h:13
numEffectState.h
osl::move_classifier::KingOpenMove
Pの王をopen checkにする手でないことをチェック.
Definition
kingOpenMove.h:22
osl::move_classifier::KingOpenMove::isMemberMain
static bool isMemberMain(const NumEffectState &state, Ptype ptype, Square from, Square to, Square exceptFor)
Definition
kingOpenMove.cc:7
Generated by
1.9.8