InferiorCells.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #ifndef INFERIOR_CELLS_HPP
00007 #define INFERIOR_CELLS_HPP
00008
00009 #include "Hex.hpp"
00010 #include "Digraph.hpp"
00011
00012 _BEGIN_BENZENE_NAMESPACE_
00013
00014
00015
00016 class VulnerableKiller
00017 {
00018 public:
00019
00020
00021 VulnerableKiller(HexPoint killer);
00022
00023
00024 VulnerableKiller(HexPoint killer, const bitset_t& carrier);
00025
00026 HexPoint killer() const;
00027 bitset_t carrier() const;
00028
00029 bool operator==(const VulnerableKiller& other) const;
00030 bool operator!=(const VulnerableKiller& other) const;
00031 bool operator<(const VulnerableKiller& other) const;
00032
00033 private:
00034 HexPoint m_killer;
00035 bitset_t m_carrier;
00036 };
00037
00038 inline VulnerableKiller::VulnerableKiller(HexPoint killer)
00039 : m_killer(killer),
00040 m_carrier()
00041 {
00042 }
00043
00044 inline VulnerableKiller::VulnerableKiller(HexPoint killer,
00045 const bitset_t& carrier)
00046 : m_killer(killer),
00047 m_carrier(carrier)
00048 {
00049 }
00050
00051 inline HexPoint VulnerableKiller::killer() const
00052 {
00053 return m_killer;
00054 }
00055
00056 inline bitset_t VulnerableKiller::carrier() const
00057 {
00058 return m_carrier;
00059 }
00060
00061 inline bool VulnerableKiller::operator==(const VulnerableKiller& other) const
00062 {
00063
00064
00065
00066 return (m_killer == other.m_killer);
00067 }
00068
00069 inline bool VulnerableKiller::operator!=(const VulnerableKiller& other) const
00070 {
00071 return !operator==(other);
00072 }
00073
00074 inline bool VulnerableKiller::operator<(const VulnerableKiller& other) const
00075 {
00076 if (m_killer != other.m_killer)
00077 return m_killer < other.m_killer;
00078 return false;
00079 }
00080
00081
00082
00083
00084 class InferiorCells
00085 {
00086 public:
00087
00088
00089 InferiorCells();
00090
00091
00092
00093 bitset_t Dead() const;
00094 bitset_t Captured(HexColor color) const;
00095 bitset_t PermInf(HexColor color) const;
00096 bitset_t PermInfCarrier(HexColor color) const;
00097 bitset_t MutualFillin(HexColor color) const;
00098 bitset_t MutualFillinCarrier(HexColor color) const;
00099
00100
00101 bitset_t Vulnerable() const;
00102
00103
00104
00105
00106
00107
00108 bitset_t Reversible() const;
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 bitset_t Dominated() const;
00121
00122 bitset_t All() const;
00123
00124 bitset_t Fillin(HexColor color) const;
00125
00126 const std::set<VulnerableKiller>& Killers(HexPoint p) const;
00127
00128 const std::set<HexPoint>& Reversers(HexPoint p) const;
00129 bitset_t AllReversers() const;
00130 bitset_t AllReversibleCarriers() const;
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 std::string GuiOutput() const;
00143
00144
00145
00146 bitset_t FindPresimplicialPairs() const;
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 bitset_t DeductionSet(HexColor color) const;
00158
00159
00160
00161 void AddDead(const bitset_t& dead);
00162 void AddDead(HexPoint dead);
00163
00164 void AddCaptured(HexColor color, const bitset_t& captured);
00165 void AddCaptured(HexColor color, HexPoint captured);
00166
00167 void AddPermInf(HexColor color, const bitset_t& cells,
00168 const bitset_t& carrier);
00169 void AddPermInf(HexColor color, HexPoint cell, const bitset_t& carrier);
00170
00171 void AddMutualFillin(HexColor color, const bitset_t& cells,
00172 const bitset_t& carrier);
00173 void AddMutualFillin(HexColor color, HexPoint cell,
00174 const bitset_t& carrier);
00175
00176 void AddDominated(HexPoint cell, HexPoint dominator);
00177 void AddDominated(HexPoint cell, const std::set<HexPoint>& dom);
00178
00179 void AddVulnerable(HexPoint cell, HexPoint killer);
00180 void AddVulnerable(HexPoint cell, const std::set<HexPoint>& killers);
00181 void AddVulnerable(HexPoint cell, const VulnerableKiller& killer);
00182 void AddVulnerable(HexPoint cell, const std::set<VulnerableKiller>& dom);
00183
00184 void AddReversible(HexPoint cell, bitset_t carrier, HexPoint reverser);
00185 void AddReversible(HexPoint cell, bitset_t carrier,
00186 const std::set<HexPoint>& reversers);
00187
00188 void AddDominatedFrom(const InferiorCells& other);
00189 void AddVulnerableFrom(const InferiorCells& other);
00190 void AddReversibleFrom(const InferiorCells& other);
00191 void AddPermInfFrom(HexColor color, const InferiorCells& other);
00192 void AddMutualFillinFrom(HexColor color, const InferiorCells& other);
00193
00194
00195
00196 void Clear();
00197
00198 void ClearDead();
00199 void ClearVulnerable();
00200 void ClearReversible();
00201 void ClearDominated();
00202 void ClearCaptured(HexColor color);
00203 void ClearPermInf(HexColor color);
00204 void ClearMutualFillin(HexColor color);
00205
00206 void RemoveDead(const bitset_t& dead);
00207 void RemoveCaptured(HexColor color, const bitset_t& captured);
00208 void RemoveDominated(const bitset_t& dominated);
00209 void RemoveVulnerable(const bitset_t& vulnerable);
00210 void RemoveReversible(const bitset_t& reversible);
00211 void RemoveReversible(HexPoint reversible);
00212 void RemovePermInf(HexColor color, const bitset_t& perminf);
00213 void RemoveMutualFillin(HexColor color, const bitset_t& mutual);
00214
00215 private:
00216
00217
00218
00219 void AssertPairwiseDisjoint() const;
00220
00221
00222
00223 bitset_t m_dead;
00224
00225 bitset_t m_captured[BLACK_AND_WHITE];
00226
00227 bitset_t m_perm_inf[BLACK_AND_WHITE];
00228 bitset_t m_perm_inf_carrier[BLACK_AND_WHITE];
00229
00230 bitset_t m_mutual_fillin[BLACK_AND_WHITE];
00231 bitset_t m_mutual_fillin_carrier[BLACK_AND_WHITE];
00232
00233
00234
00235
00236
00237 bitset_t m_vulnerable;
00238 std::set<VulnerableKiller> m_killers[BITSETSIZE];
00239
00240
00241
00242
00243 bitset_t m_reversible;
00244 std::set<HexPoint> m_reversers[BITSETSIZE];
00245
00246 bitset_t m_allReversibleCarriers;
00247 bitset_t m_allReversers;
00248
00249
00250
00251
00252
00253 Digraph<HexPoint> m_dom_graph;
00254
00255
00256
00257
00258 mutable bool m_dominated_computed;
00259
00260
00261
00262 mutable bitset_t m_dominated;
00263
00264 };
00265
00266 inline bitset_t InferiorCells::Dead() const
00267 {
00268 return m_dead;
00269 }
00270
00271 inline bitset_t InferiorCells::Vulnerable() const
00272 {
00273 return m_vulnerable;
00274 }
00275
00276 inline bitset_t InferiorCells::Reversible() const
00277 {
00278 return m_reversible;
00279 }
00280
00281 inline bitset_t InferiorCells::Captured(HexColor color) const
00282 {
00283 return m_captured[color];
00284 }
00285
00286 inline bitset_t InferiorCells::PermInf(HexColor color) const
00287 {
00288 return m_perm_inf[color];
00289 }
00290
00291 inline bitset_t InferiorCells::PermInfCarrier(HexColor color) const
00292 {
00293 return m_perm_inf_carrier[color];
00294 }
00295
00296 inline bitset_t InferiorCells::MutualFillin(HexColor color) const
00297 {
00298 return m_mutual_fillin[color];
00299 }
00300
00301 inline bitset_t InferiorCells::MutualFillinCarrier(HexColor color) const
00302 {
00303 return m_mutual_fillin_carrier[color];
00304 }
00305
00306 inline
00307 const std::set<VulnerableKiller>& InferiorCells::Killers(HexPoint p) const
00308 {
00309 return m_killers[p];
00310 }
00311
00312 inline
00313 const std::set<HexPoint>& InferiorCells::Reversers(HexPoint p) const
00314 {
00315 return m_reversers[p];
00316 }
00317
00318 inline bitset_t InferiorCells::AllReversers() const
00319 {
00320 return m_allReversers;
00321 }
00322
00323 inline bitset_t InferiorCells::AllReversibleCarriers() const
00324 {
00325 return m_allReversibleCarriers;
00326 }
00327
00328
00329
00330
00331 namespace InferiorCellsUtil
00332 {
00333
00334 bitset_t FindDominationCaptains(const Digraph<HexPoint>& graph);
00335
00336 }
00337
00338
00339
00340 _END_BENZENE_NAMESPACE_
00341
00342 #endif // INFERIOR_CELLS_HPP