alphaBetaPlayer.cc Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
alphaBetaPlayer.cc
Go to the documentation of this file.
1 /* alphaBetaPlayer.cc
2 */
3 #include "osl/game_playing/alphaBetaPlayer.h"
4 #include "osl/game_playing/searchPlayer.tcc"
5 #include "osl/search/alphaBeta2.h"
6 #include "osl/search/alphaBeta3.h"
7 #include "osl/search/alphaBeta4.h"
8 #include "osl/search/simpleHashTable.h"
9 #include "osl/eval/progressEval.h"
10 #include "osl/eval/pieceEval.h"
11 #include <iostream>
12
13 #ifndef MINIMAL
14 osl::game_playing::
15 AlphaBeta2ProgressEvalPlayer::AlphaBeta2ProgressEvalPlayer()
16 {
17 }
18
19 osl::game_playing::
20 AlphaBeta2ProgressEvalPlayer::~AlphaBeta2ProgressEvalPlayer()
21 {
22 }
23
24 osl::game_playing::ComputerPlayer* osl::game_playing::
25 AlphaBeta2ProgressEvalPlayer::clone() const
26 {
27 return cloneIt(*this);
28 }
29
30 const osl::search::MoveWithComment osl::game_playing::
31 AlphaBeta2ProgressEvalPlayer::searchWithSecondsForThisMove(const GameState& gs, const search::TimeAssigned& org)
32 {
33 const MilliSeconds::Interval consumed
34 = setUpTable(gs, pawnValueOfTurn<AlphaBeta2ProgressEval>(gs.state().turn()));
35 const search::TimeAssigned msec(adjust(org, consumed));
36 searcher.reset();
37 try
38 {
39 searcher.reset(new AlphaBeta2ProgressEval(gs.state(), *checkmate_ptr, table_ptr.get(),
40 *recorder_ptr));
41 }
42 catch (std::bad_alloc&)
43 {
44 std::cerr << "panic. allocation of AlphaBeta2 failed\n";
45 }
46 return SearchPlayer::search<AlphaBeta2ProgressEval>(gs, msec);
47 }
48
49 bool osl::game_playing::
50 AlphaBeta2ProgressEvalPlayer::isReasonableMove(const GameState& gs,
51 Move move, int pawn_sacrifice)
52 {
53 setUpTable(gs, pawnValueOfTurn<AlphaBeta2ProgressEval>(gs.state().turn()));
54 AlphaBeta2ProgressEval searcher(gs.state(), *checkmate_ptr, table_ptr.get(),
55 *recorder_ptr);
56 return SearchPlayer::isReasonableMoveBySearch(searcher, move, pawn_sacrifice);
57 }
58 #endif
59
60 /* ------------------------------------------------------------------------- */
61
62 osl::game_playing::
63 AlphaBeta2OpenMidEndingEvalPlayer::AlphaBeta2OpenMidEndingEvalPlayer()
64 {
65 }
66
67 osl::game_playing::
68 AlphaBeta2OpenMidEndingEvalPlayer::~AlphaBeta2OpenMidEndingEvalPlayer()
69 {
70 }
71
72 osl::game_playing::ComputerPlayer* osl::game_playing::
73 AlphaBeta2OpenMidEndingEvalPlayer::clone() const
74 {
75 return cloneIt(*this);
76 }
77
78 const osl::search::MoveWithComment osl::game_playing::
79 AlphaBeta2OpenMidEndingEvalPlayer::searchWithSecondsForThisMove(const GameState& gs, const search::TimeAssigned& org)
80 {
81 const MilliSeconds::Interval consumed = setUpTable(gs, pawnValueOfTurn<AlphaBeta2OpenMidEndingEval>(gs.state().turn()));
82 const search::TimeAssigned msec(adjust(org, consumed));
83 searcher.reset();
84 try
85 {
86 searcher.reset(new AlphaBeta2OpenMidEndingEval(gs.state(), *checkmate_ptr, table_ptr.get(),
87 *recorder_ptr));
88 }
89 catch (std::bad_alloc&)
90 {
91 std::cerr << "panic. allocation of AlphaBeta2 failed\n";
92 }
93 return SearchPlayer::search<AlphaBeta2OpenMidEndingEval>(gs, msec);
94 }
95
96 const osl::search::MoveWithComment osl::game_playing::
97 AlphaBeta2OpenMidEndingEvalPlayer::analyzeWithSeconds(const GameState& gs, const search::TimeAssigned& org,
98 search::AlphaBeta2SharedRoot& out)
99 {
100 const search::MoveWithComment
101 result = searchWithSecondsForThisMove(gs, org);
102 out = dynamic_cast<AlphaBeta2OpenMidEndingEval&>(*searcher).sharedRootInfo();
103 return result;
104 }
105
106 bool osl::game_playing::
107 AlphaBeta2OpenMidEndingEvalPlayer::isReasonableMove(const GameState& gs,
108 Move move, int pawn_sacrifice)
109 {
110 setUpTable(gs, pawnValueOfTurn<AlphaBeta2OpenMidEndingEval>(gs.state().turn()));
111 AlphaBeta2OpenMidEndingEval searcher(gs.state(), *checkmate_ptr, table_ptr.get(),
112 *recorder_ptr);
113 return SearchPlayer::isReasonableMoveBySearch(searcher, move, pawn_sacrifice);
114 }
115
116 /* ------------------------------------------------------------------------- */
117
118 #ifndef MINIMAL
119 osl::game_playing::
120 AlphaBeta3OpenMidEndingEvalPlayer::AlphaBeta3OpenMidEndingEvalPlayer()
121 {
122 }
123
124 osl::game_playing::
125 AlphaBeta3OpenMidEndingEvalPlayer::~AlphaBeta3OpenMidEndingEvalPlayer()
126 {
127 }
128
129 osl::game_playing::ComputerPlayer* osl::game_playing::
130 AlphaBeta3OpenMidEndingEvalPlayer::clone() const
131 {
132 return cloneIt(*this);
133 }
134
135 const osl::search::MoveWithComment osl::game_playing::
136 AlphaBeta3OpenMidEndingEvalPlayer::searchWithSecondsForThisMove(const GameState& gs, const search::TimeAssigned& org)
137 {
138 const MilliSeconds::Interval consumed = setUpTable(gs, pawnValueOfTurn<AlphaBeta3>(gs.state().turn()));
139 const search::TimeAssigned msec(adjust(org, consumed));
140 searcher.reset();
141 try
142 {
143 searcher.reset(new AlphaBeta3(gs.state(), *checkmate_ptr, table_ptr.get(),
144 *recorder_ptr));
145 }
146 catch (std::bad_alloc&)
147 {
148 std::cerr << "panic. allocation of AlphaBeta3 failed\n";
149 }
150 return SearchPlayer::search<AlphaBeta3>(gs, msec);
151 }
152
153 bool osl::game_playing::
154 AlphaBeta3OpenMidEndingEvalPlayer::isReasonableMove(const GameState& gs,
155 Move move, int pawn_sacrifice)
156 {
157 setUpTable(gs, pawnValueOfTurn<AlphaBeta3>(gs.state().turn()));
158 AlphaBeta3 searcher(gs.state(), *checkmate_ptr, table_ptr.get(),
159 *recorder_ptr);
160 return SearchPlayer::isReasonableMoveBySearch(searcher, move, pawn_sacrifice);
161 }
162 #endif
163 /* ------------------------------------------------------------------------- */
164
165 osl::game_playing::
166 AlphaBeta4Player::AlphaBeta4Player()
167 {
168 }
169
170 osl::game_playing::
171 AlphaBeta4Player::~AlphaBeta4Player()
172 {
173 }
174
175 osl::game_playing::ComputerPlayer* osl::game_playing::
176 AlphaBeta4Player::clone() const
177 {
178 return cloneIt(*this);
179 }
180
181 const osl::search::MoveWithComment osl::game_playing::
182 AlphaBeta4Player::searchWithSecondsForThisMove(const GameState& gs, const search::TimeAssigned& org)
183 {
184 const MilliSeconds::Interval consumed = setUpTable(gs, pawnValueOfTurn<AlphaBeta4>(gs.state().turn()));
185 const search::TimeAssigned msec(adjust(org, consumed));
186 searcher.reset();
187 try
188 {
189 searcher.reset(new AlphaBeta4(gs.state(), *checkmate_ptr, table_ptr.get(),
190 *recorder_ptr));
191 }
192 catch (std::bad_alloc&)
193 {
194 std::cerr << "panic. allocation of AlphaBeta4 failed\n";
195 }
196 return SearchPlayer::search<AlphaBeta4>(gs, msec);
197 }
198
199 bool osl::game_playing::
200 AlphaBeta4Player::isReasonableMove(const GameState& gs,
201 Move move, int pawn_sacrifice)
202 {
203 setUpTable(gs, pawnValueOfTurn<AlphaBeta4>(gs.state().turn()));
204 AlphaBeta4 searcher(gs.state(), *checkmate_ptr, table_ptr.get(),
205 *recorder_ptr);
206 return SearchPlayer::isReasonableMoveBySearch(searcher, move, pawn_sacrifice);
207 }
208
209 /* ------------------------------------------------------------------------- */
210
211 // ;;; Local Variables:
212 // ;;; mode:c++
213 // ;;; c-basic-offset:2
214 // ;;; End: