Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
lib
move_generator
legalMoves.cc
Go to the documentation of this file.
1
/* legalMoves.cc
2
*/
3
#include "
osl/move_generator/legalMoves.h
"
4
#include "
osl/move_classifier/moveAdaptor.h
"
5
#include "
osl/move_classifier/pawnDropCheckmate.h
"
6
#include "
osl/move_classifier/safeMove.h
"
7
#include "
osl/move_generator/allMoves.h
"
8
#include "
osl/move_generator/escape_.h
"
9
#include "
osl/container/moveVector.h
"
10
#include "
osl/effect_util/effectUtil.h
"
11
#include <boost/foreach.hpp>
12
13
void
osl::move_generator::
14
LegalMoves::generate
(
const
NumEffectState& state, MoveVector&
moves
)
15
{
16
if
(state.inCheck())
17
{
18
// 王手がかかっている時は防ぐ手のみを生成, 王手回避は不成も生成
19
GenerateEscapeKing::generate
(state, moves);
20
}
21
else
22
{
23
// そうでなければ全ての手を生成
24
MoveVector all_moves;
25
GenerateAllMoves::generate
(state.turn(), state, all_moves);
26
// この指手は,玉の素抜きがあったり,打歩詰の可能性があるので
27
// 確認が必要
28
using namespace
osl::move_classifier;
29
BOOST_FOREACH(
Move
m, all_moves)
30
{
31
if
(m.
isDrop
()
32
||
PlayerMoveAdaptor<SafeMove>::isMember
(state, m))
33
{
34
if
(!
PlayerMoveAdaptor<PawnDropCheckmate>::isMember
(state, m))
35
{
36
moves.push_back(m);
37
}
38
}
39
}
40
}
41
}
42
43
void
osl::move_generator::
44
LegalMoves::generateWithFullUnpromotions
(
const
NumEffectState& state,
45
MoveVector&
moves
)
46
{
47
generate
(state, moves);
48
if
(state.inCheck())
49
return
;
50
for
(
int
i=0, iend=moves.size(); i<iend; ++i) {
51
const
osl::Move
move = moves[i];
52
if
(move.
hasIgnoredUnpromote
())
53
moves.push_back(move.
unpromote
());
54
}
55
}
56
57
// ;;; Local Variables:
58
// ;;; mode:c++
59
// ;;; c-basic-offset:2
60
// ;;; End:
Generated on Sun Jul 21 2013 13:37:24 by
1.8.4