alphaBeta3.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
alphaBeta3.h
Go to the documentation of this file.
1 /* alphaBeta3.h
2 */
3 #ifndef OSL_ALPHABETA3_H
4 #define OSL_ALPHABETA3_H
5 #include "osl/state/numEffectState.h"
6 #include "osl/search/searchTimer.h"
7 #include "osl/search/fixedEval.h"
8 // temporal
9 #include "osl/search/searchState2.h"
10 #include "osl/eval/ml/openMidEndingEval.h"
11 #include "osl/eval/progressEval.h"
12 #include "osl/container/moveVector.h"
13
14 namespace osl
15 {
16 namespace search
17 {
18 class CountRecorder;
19 class SimpleHashTable;
20 struct MoveWithComment;
21 class AlphaBeta3 : public SearchTimer, FixedEval
22 {
23 public:
24 // interface required for game_playing::SearchPlayer
25 typedef SearchState2::checkmate_t checkmate_t;
26 typedef eval::ml::OpenMidEndingEval eval_t;
27 // typedef eval::PieceEval eval_t;
28 // typedef eval::ProgressEval eval_t;
29 AlphaBeta3(const NumEffectState& s, checkmate_t& checker,
30 SimpleHashTable *t, CountRecorder&);
31 ~AlphaBeta3();
32 Move computeBestMoveIteratively(int limit, int step,
33 int initial_limit=600,
34 size_t node_limit=1600000,
35 const TimeAssigned& assign=TimeAssigned(MilliSeconds::Interval(60*1000)),
36 MoveWithComment *additional_info=0);
37 bool isReasonableMove(Move move, int pawn_sacrifice=1);
38 void setRootIgnoreMoves(const MoveVector *rim, bool);
39 void setHistory(const MoveStack& h);
40 void enableMultiPV(unsigned int) {}
41
42 static void showNodeDepth(std::ostream&);
43 static void clearNodeDepth();
44
45 // original staff
46 enum MoveCategory { Initial, KingEscape, Pass, TakeBack, Capture, Killer, CaptureAll, All };
47 enum { MaxDepth = 64 };
48 enum NodeType { PvNode = 0, CutNode = 1, AllNode = -1 };
49 struct SearchInfo;
50 struct PVInfo
51 {
52 Move move;
53 int height;
54 bool in_check;
55 };
56 struct PVVector : public FixedCapacityVector<PVInfo,MaxDepth>
57 {
58 void setPV(Move m, const SearchInfo&, const PVVector&);
59 };
60 struct SearchInfo
61 {
62 SearchInfo();
63 // input
64 // (modified: alpha, node_type, eval)
65 Move moved;
66 HashKey hash_key;
67 PathEncoding path;
68 int height, extended;
69 int alpha, beta;
70 NodeType node_type;
71 eval_t eval; // before moved
72 // output
73 int search_value;
74 int moves_tried;
75 bool in_check;
76 PVVector pv;
77 // work area
78 MoveVector moves;
79 MoveCategory move_type;
80 unsigned int move_index;
81 };
82 private:
83 template <Player P> struct CallSearch;
84 template <Player P> struct CallQuiesce;
85 friend struct CallSearch<BLACK>;
86 friend struct CallSearch<WHITE>;
87 friend struct CallQuiesce<BLACK>;
88 friend struct CallQuiesce<WHITE>;
89 Move searchRoot(int limit);
90 template <Player P> int makeMoveAndSearch(Move, int consume);
91 template <Player P> void presearch();
92 template <Player P> void search();
93 template <Player P> Move nextMove();
94 template <Player P> void quiesceRoot();
95 template <Player P> int makeMoveAndQuiesce(Move);
96 template <Player P> void quiesce();
97 private:
98 volatile int stop_by_alarm;
99 NumEffectState state;
100 int depth;
101 CountRecorder& recorder;
102 SimpleHashTable *table_common;
103 public: // public for test
104 template <Player P>
105 static void generateAllMoves(const NumEffectState& state, const SearchInfo&, SearchInfo&);
106 template <Player P>
107 static void generateCapture(const NumEffectState& state, SearchInfo&);
108 template <Player P>
109 static void generateCaptureAll(const NumEffectState& state, SearchInfo&);
110 template <Player P>
111 static bool seePlusLight(const NumEffectState& state, Move m);
112 private:
113 bool reductionOk() const;
114 int evalValue() const;
115 };
116
117 }
118 using search::AlphaBeta3;
119 }
120
121 #endif /* OSL_ALPHABETA3_H */
122 // ;;; Local Variables:
123 // ;;; mode:c++
124 // ;;; c-basic-offset:2
125 // ;;; End: