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/>.
26 #include "hashtable.h"
38 Move killer_moves
[MAX_PLY
][MAX_KILLERS
];
39 HashTable
<Material
> material_table
;
43 unsigned int nodes_count
; // Used in search
49 MoveList search_moves
;
51 Game(const int tt_size
= TT_SIZE
, const int mt_size
= MT_SIZE
) :
52 material_table(mt_size
),
53 output_thinking(false),
58 Moves::init_mvv_lva_scores();
61 void add_piece(Color c
, PieceType t
, Square s
);
62 void del_piece(Color c
, PieceType t
, int i
);
63 void del_piece(Piece p
) {
64 del_piece(p
.color(), p
.type(), p
.index());
69 Position
& current_position() {
73 void init(std::string fen
);
75 bool is_check(Color c
) const {
76 Square s
= pieces
.position(c
, KING
, 0);
77 return board
.is_attacked_by(!c
, s
, pieces
);
80 void make_move(Move m
);
81 void undo_move(Move m
);
82 bool is_legal(Move m
);
83 bool is_dangerous(Move m
);
86 unsigned long long int perft(unsigned int depth
);
88 int quiescence(int alpha
, int beta
, int depth
, const int ply
);
90 template<NodeType node_type
>
91 int search(int alpha
, int beta
, int depth
, const int ply
);
93 Move
root(int max_depth
);
98 Move killer(int depth, int index) {
99 return killer_moves[depth][index];
102 Move (&killers(const int depth
))[MAX_KILLERS
] {
103 return killer_moves
[depth
];
105 void set_killer(const Move move
, const int depth
);
106 bool is_killer(const Move move
, const int depth
) {
107 return (move
== killer_moves
[depth
][0] ||
108 move
== killer_moves
[depth
][1]);
111 // Position's evaluation
113 int eval(int alpha
, int beta
);
118 void print_thinking_header();
119 void print_thinking(int depth
, int score
, Move m
);
120 std::string
output_pv(int depth
, int score
, Move m
);
121 std::string
output_move(Move m
);
122 std::string
output_square(Square s
) {
123 return output_square(board
.file(s
), board
.rank(s
));
125 std::string
output_square(File f
, Rank r
);
126 void print_tt_stats();
127 std::string
debug_move(Move m
);