Cleaned book/lines.
[rattatechess.git] / search.h
blobb4990a07e171e27b77cdad907366d66a1de7ec84
1 /***************************************************************************
2 platform.h - Platoform dependent utilities
3 -------------------
4 begin : Sun Oct 07 2007
5 copyright : (C) 2007 by Maurizio Monge
6 email : monge@linuz.sns.it
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef __SEARCH_H__
19 #define __SEARCH_H__
21 #include "engine.h"
23 #define MAX_PV 80
24 #define PLY 100
26 #define HISTORY_SIZE (64*64)
27 #define HISTORY_INDEX(m) (SQUARE_TO_64(m.from)*64 + SQUARE_TO_64(m.to))
29 #define WORST_MATE (INF-5000)
31 class SearchRoot
33 public:
34 class SearchStack
36 public:
37 Move *moves; /* generated moves */
38 int num_moves; /* num of moves */
39 int curr_move; /* the move being currently analyzed */
40 bool under_check;
41 int best_move;
42 SaveBuf save_buf;
43 Move null_threat;
44 bool null_threat_dangerous;
45 uint8_t escape_from[2];
48 Move mv_stack[200*MAX_PV];
49 int mv_stack_top;
50 SearchStack stack[MAX_PV];
52 uint16_t history_tot[HISTORY_SIZE];
53 uint16_t history_hit[HISTORY_SIZE];
55 Engine *engine;
56 Board board;
58 void print_pv(const Move& m);
59 bool check_draw(int curr_ply);
60 bool check_repetition(int curr_ply, int nfold);
61 bool null_move_ok();
62 void moves_heuristic(Move *mv, int num_mv, bool pv, int ply,
63 int orig_depth, Move best_mv_hash, bool quiesce, Move* prev, int* overall_extensions, bool expect_allbad);
64 void moves_quiescence_heuristic(Move *mv, int num_mv, const Move& hash,
65 int static_eval, int alpha, int beta, int depth, Move* prev);
66 int16_t search(int ply, int depth, bool pv,
67 int16_t alpha, int16_t beta, bool expect_allbad);
68 SearchRoot(Engine* e, const Board& b);
69 ~SearchRoot();
72 #endif //__SEARCH_H__