00001
00002
00003
00004
00005
00006 #ifndef ICENGINE_H
00007 #define ICENGINE_H
00008
00009 #include "Digraph.hpp"
00010 #include "Groups.hpp"
00011 #include "InferiorCells.hpp"
00012 #include "IcePatternSet.hpp"
00013 #include "HandCodedPattern.hpp"
00014 #include "PatternState.hpp"
00015
00016 _BEGIN_BENZENE_NAMESPACE_
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 class ICEngine
00027 {
00028 public:
00029
00030
00031
00032
00033 ICEngine();
00034
00035
00036 virtual ~ICEngine();
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 void ComputeInferiorCells(HexColor color, Groups& board,
00047 PatternState& pastate,
00048 InferiorCells& out) const;
00049
00050
00051
00052
00053 void ComputeFillin(HexColor color, Groups& board,
00054 PatternState& pastate, InferiorCells& out,
00055 HexColorSet colors_to_capture=ALL_COLORS) const;
00056
00057
00058
00059
00060
00061 std::size_t ComputeDeadCaptured(Groups& board, PatternState& pastate,
00062 InferiorCells& inf,
00063 HexColorSet colors_to_capture) const;
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 bitset_t FindDead(const PatternState& board,
00074 const bitset_t& consider) const;
00075
00076
00077 void FindVulnerable(const PatternState& board, HexColor color,
00078 const bitset_t& consider,
00079 InferiorCells& inf) const;
00080
00081
00082 void FindReversible(const PatternState& board, HexColor color,
00083 const bitset_t& consider,
00084 InferiorCells& inf) const;
00085
00086
00087
00088 void FindDominated(const PatternState& board, HexColor color,
00089 const bitset_t& consider, InferiorCells& inf) const;
00090
00091
00092 void FindDominatedOnCell(const PatternState& pastate,
00093 HexColor color,
00094 HexPoint cell,
00095 PatternHits& hits) const;
00096
00097
00098 void FindHandCodedDominated(const StoneBoard& board, HexColor color,
00099 const bitset_t& consider,
00100 InferiorCells& inf) const;
00101
00102
00103
00104 bitset_t FindCaptured(const PatternState& board, HexColor color,
00105 const bitset_t& consider) const;
00106
00107
00108
00109 bitset_t FindPermanentlyInferior(const PatternState& board,
00110 HexColor color,
00111 const bitset_t& consider,
00112 bitset_t& carrier) const;
00113
00114
00115
00116 void FindMutualFillin(const PatternState& board,
00117 HexColor color,
00118 const bitset_t& consider,
00119 bitset_t& carrier,
00120 bitset_t *mut) const;
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 bool FindPresimplicialPairs() const;
00131
00132
00133 void SetFindPresimplicialPairs(bool enable);
00134
00135
00136 bool FindPermanentlyInferior() const;
00137
00138
00139 void SetFindPermanentlyInferior(bool enable);
00140
00141
00142 bool FindMutualFillin() const;
00143
00144
00145 void SetFindMutualFillin(bool enable);
00146
00147
00148 bool FindAllPatternKillers() const;
00149
00150
00151 void SetFindAllPatternKillers(bool enable);
00152
00153
00154 bool FindAllPatternReversers() const;
00155
00156
00157 void SetFindAllPatternReversers(bool enable);
00158
00159
00160 bool FindAllPatternDominators() const;
00161
00162
00163 void SetFindAllPatternDominators(bool enable);
00164
00165
00166 bool UseHandCodedPatterns() const;
00167
00168
00169 void SetUseHandCodedPatterns(bool enable);
00170
00171
00172
00173
00174 bool BackupOpponentDead() const;
00175
00176
00177 void SetBackupOpponentDead(bool enable);
00178
00179
00180 bool FindThreeSidedDeadRegions() const;
00181
00182
00183 void SetFindThreeSidedDeadRegions(bool enable);
00184
00185
00186
00187
00188
00189
00190 bool IterativeDeadRegions() const;
00191
00192
00193 void SetIterativeDeadRegions(bool enable);
00194
00195
00196
00197 private:
00198
00199 bool m_find_presimplicial_pairs;
00200
00201
00202 bool m_find_permanently_inferior;
00203
00204
00205 bool m_find_mutual_fillin;
00206
00207
00208 bool m_find_all_pattern_killers;
00209
00210
00211 bool m_find_all_pattern_reversers;
00212
00213
00214 bool m_find_all_pattern_dominators;
00215
00216
00217 bool m_use_handcoded_patterns;
00218
00219
00220 bool m_backup_opponent_dead;
00221
00222
00223 bool m_find_three_sided_dead_regions;
00224
00225
00226 bool m_iterative_dead_regions;
00227
00228 std::vector<HandCodedPattern> m_hand_coded;
00229
00230 IcePatternSet m_patterns;
00231
00232 void LoadPatterns();
00233
00234 void LoadHandCodedPatterns();
00235
00236 std::size_t FillinPermanentlyInferior(Groups& groups,
00237 PatternState& board, HexColor color,
00238 InferiorCells& out,
00239 HexColorSet colors_to_capture) const;
00240
00241 std::size_t FillInMutualFillin(Groups& groups,
00242 PatternState& board, HexColor color,
00243 InferiorCells& out,
00244 HexColorSet colors_to_capture) const;
00245
00246 std::size_t CliqueCutsetDead(Groups& groups, PatternState& pastate,
00247 InferiorCells& out) const;
00248
00249 std::size_t BackupOpponentDead(HexColor color, const StoneBoard& board,
00250 PatternState& pastate, InferiorCells& out) const;
00251
00252 std::size_t FillInVulnerable(HexColor color, Groups& groups,
00253 PatternState& pastate, InferiorCells& inf,
00254 HexColorSet colors_to_capture) const;
00255
00256 void CheckHandCodedDominates(const StoneBoard& brd, HexColor color,
00257 const HandCodedPattern& pattern,
00258 const bitset_t& consider,
00259 InferiorCells& inf) const;
00260
00261 };
00262
00263 inline bool ICEngine::FindPresimplicialPairs() const
00264 {
00265 return m_find_presimplicial_pairs;
00266 }
00267
00268 inline void ICEngine::SetFindPresimplicialPairs(bool enable)
00269 {
00270 m_find_presimplicial_pairs = enable;
00271 }
00272
00273 inline bool ICEngine::FindPermanentlyInferior() const
00274 {
00275 return m_find_permanently_inferior;
00276 }
00277
00278 inline void ICEngine::SetFindPermanentlyInferior(bool enable)
00279 {
00280 m_find_permanently_inferior = enable;
00281 }
00282
00283 inline bool ICEngine::FindMutualFillin() const
00284 {
00285 return m_find_mutual_fillin;
00286 }
00287
00288 inline void ICEngine::SetFindMutualFillin(bool enable)
00289 {
00290 m_find_mutual_fillin = enable;
00291 }
00292
00293 inline bool ICEngine::FindAllPatternKillers() const
00294 {
00295 return m_find_all_pattern_killers;
00296 }
00297
00298 inline void ICEngine::SetFindAllPatternKillers(bool enable)
00299 {
00300 m_find_all_pattern_killers = enable;
00301 }
00302
00303 inline bool ICEngine::FindAllPatternReversers() const
00304 {
00305 return m_find_all_pattern_reversers;
00306 }
00307
00308 inline void ICEngine::SetFindAllPatternReversers(bool enable)
00309 {
00310 m_find_all_pattern_reversers = enable;
00311 }
00312
00313 inline bool ICEngine::FindAllPatternDominators() const
00314 {
00315 return m_find_all_pattern_dominators;
00316 }
00317
00318 inline void ICEngine::SetFindAllPatternDominators(bool enable)
00319 {
00320 m_find_all_pattern_dominators = enable;
00321 }
00322
00323 inline bool ICEngine::UseHandCodedPatterns() const
00324 {
00325 return m_use_handcoded_patterns;
00326 }
00327
00328 inline void ICEngine::SetUseHandCodedPatterns(bool enable)
00329 {
00330 m_use_handcoded_patterns = enable;
00331 }
00332
00333 inline bool ICEngine::BackupOpponentDead() const
00334 {
00335 return m_backup_opponent_dead;
00336 }
00337
00338 inline void ICEngine::SetBackupOpponentDead(bool enable)
00339 {
00340 m_backup_opponent_dead = enable;
00341 }
00342
00343 inline bool ICEngine::FindThreeSidedDeadRegions() const
00344 {
00345 return m_find_three_sided_dead_regions;
00346 }
00347
00348 inline void ICEngine::SetFindThreeSidedDeadRegions(bool enable)
00349 {
00350 m_find_three_sided_dead_regions = enable;
00351 }
00352
00353 inline bool ICEngine::IterativeDeadRegions() const
00354 {
00355 return m_iterative_dead_regions;
00356 }
00357
00358 inline void ICEngine::SetIterativeDeadRegions(bool enable)
00359 {
00360 m_iterative_dead_regions = enable;
00361 }
00362
00363
00364
00365
00366 namespace IceUtil
00367 {
00368
00369
00370 void Update(InferiorCells& out, const InferiorCells& in);
00371 }
00372
00373
00374
00375 _END_BENZENE_NAMESPACE_
00376
00377 #endif // ICENGINE_H