1 /* Copyright (C) 2007-2012 Vincent Ollivier
3 * Purple Haze is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * Purple Haze is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 const Score BEST_SCORE
= 127;
30 const Score KILLERS_SCORE
= 0;
32 const int MOVES_STATE_SIZE
= 5;
33 enum MovesState
: unsigned char {
34 BEST
, GOOD_CAPTURES
, KILLERS
, BAD_CAPTURES
, QUIET_MOVES
, UNDEF_MOVES
40 ExtendedMove list
[MAX_PLY
][MAX_MOVES
];
41 unsigned int ply
; // TODO: Redundant with Tree::ply()?
44 MoveList() : list(), ply(0) {}
55 ExtendedMove
& operator[] (unsigned char i
) {
59 // Only used in unit tests
68 static Score mvv_lva_scores
[NB_PIECE_TYPES
][NB_PIECE_TYPES
];
71 const Position
& current_position
;
76 unsigned char size
[MOVES_STATE_SIZE
]; // Moves types counters
77 MovesState generation_state
;
78 bool use_lazy_generation
;
81 Moves(const Board
& b
, const Pieces
& ps
, const Position
& cn
,
82 MoveList
& ml
, bool lg
= true) :
83 moves(ml
), current_position(cn
), board(b
), pieces(ps
),
86 generation_state(BEST
),
87 use_lazy_generation(lg
)
89 moves
.inc_ply(); // Increment move list internal counter
93 moves
.dec_ply(); // Decrement move list internal counter
96 void generate(MoveType mt
= NULL_MOVE
); // here NULL_MOVE => ALL_MOVE
97 void generate_pieces(Color c
, PieceType t
, MoveType mt
);
98 void add(Move m
, MovesState mt
= UNDEF_MOVES
);
100 MovesState
state() const {
101 return generation_state
;
104 static void init_mvv_lva_scores();
105 Score
mvv_lva_score(Move m
);
107 // Only used in unit tests
108 int count(MovesState mt
) const {
118 #endif /* !MOVES_H */