VCSet.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #ifndef VCSET_HPP
00007 #define VCSET_HPP
00008
00009 #include "SgSystem.h"
00010 #include "SgStatistics.h"
00011
00012 #include "ChangeLog.hpp"
00013 #include "ConstBoard.hpp"
00014 #include "Groups.hpp"
00015 #include "Hex.hpp"
00016 #include "VC.hpp"
00017 #include "VCList.hpp"
00018
00019 _BEGIN_BENZENE_NAMESPACE_
00020
00021
00022
00023
00024 class VCSet
00025 {
00026 public:
00027
00028
00029 VCSet(const ConstBoard& brd, HexColor color);
00030
00031
00032 VCSet(const VCSet& other);
00033
00034
00035 virtual ~VCSet();
00036
00037
00038
00039
00040 HexColor Color() const;
00041
00042
00043 const ConstBoard& Board() const;
00044
00045
00046
00047 int SoftLimit(VC::Type) const;
00048
00049
00050 const VCList& GetList(VC::Type type, HexPoint x, HexPoint y) const;
00051
00052
00053 VCList& GetList(VC::Type type, HexPoint x, HexPoint y);
00054
00055
00056
00057
00058 bool Exists(HexPoint x, HexPoint y, VC::Type type) const;
00059
00060
00061
00062
00063 bool SmallestVC(HexPoint x, HexPoint y, VC::Type type, VC& out) const;
00064
00065
00066
00067 void VCs(HexPoint x, HexPoint y, VC::Type type,
00068 std::vector<VC>& out) const;
00069
00070
00071
00072
00073
00074
00075
00076 void SetSoftLimit(VC::Type, int limit);
00077
00078
00079 void Clear();
00080
00081
00082
00083
00084
00085
00086
00087 VCList::AddResult Add(const VC& vc, ChangeLog<VC>* log);
00088
00089
00090
00091
00092 void Revert(ChangeLog<VC>& log);
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 void operator=(const VCSet& other);
00103
00104
00105 bool operator==(const VCSet& other) const;
00106
00107
00108 bool operator!=(const VCSet& other) const;
00109
00110
00111
00112 private:
00113
00114
00115
00116 void AllocateAndCopyLists(const VCSet& other);
00117
00118
00119 void FreeLists();
00120
00121
00122 const ConstBoard* m_brd;
00123
00124
00125 HexColor m_color;
00126
00127
00128
00129
00130 VCList* m_vc[VC::NUM_TYPES][BITSETSIZE][BITSETSIZE];
00131 };
00132
00133 inline HexColor VCSet::Color() const
00134 {
00135 return m_color;
00136 }
00137
00138 inline const ConstBoard& VCSet::Board() const
00139 {
00140 return *m_brd;
00141 }
00142
00143 inline const VCList&
00144 VCSet::GetList(VC::Type type, HexPoint x, HexPoint y) const
00145 {
00146 return *m_vc[type][x][y];
00147 }
00148
00149 inline VCList&
00150 VCSet::GetList(VC::Type type, HexPoint x, HexPoint y)
00151 {
00152 return *m_vc[type][x][y];
00153 }
00154
00155 inline
00156 VCList::AddResult VCSet::Add(const VC& vc, ChangeLog<VC>* log)
00157 {
00158 return m_vc[vc.type()][vc.x()][vc.y()]->add(vc, log);
00159 }
00160
00161 inline int VCSet::SoftLimit(VC::Type type) const
00162 {
00163 return m_vc[type]
00164 [HexPointUtil::colorEdge1(m_color)]
00165 [HexPointUtil::colorEdge2(m_color)]->softlimit();
00166 }
00167
00168
00169
00170
00171 struct VCSetStatistics
00172 {
00173 std::size_t m_fulls;
00174
00175 std::size_t m_semis;
00176
00177 SgStatisticsExt<float, std::size_t> m_fullCounts;
00178
00179 SgStatisticsExt<float, std::size_t> m_semiCounts;
00180
00181 SgStatisticsExt<float, std::size_t> m_fullCountsCell;
00182
00183 SgStatisticsExt<float, std::size_t> m_semiCountsCell;
00184
00185 SgStatisticsExt<float, std::size_t> m_fullConnectedTo;
00186
00187 SgStatisticsExt<float, std::size_t> m_semiConnectedTo;
00188
00189 SgHistogram<std::size_t, std::size_t> m_fullHisto;
00190
00191 SgHistogram<std::size_t, std::size_t> m_semiHisto;
00192
00193 VCSetStatistics();
00194
00195 std::string Write() const;
00196 };
00197
00198
00199
00200
00201 namespace VCSetUtil
00202 {
00203
00204
00205 bitset_t ConnectedTo(const VCSet& con, const Groups& groups,
00206 HexPoint x, VC::Type type);
00207
00208
00209
00210 bool EqualOnGroups(const VCSet& c1, const VCSet& c2,
00211 const Groups& groups);
00212
00213
00214 VCSetStatistics ComputeStatistics(const VCSet& con, const Groups& groups,
00215 std::size_t maxConnections,
00216 int numBins);
00217 }
00218
00219
00220
00221 _END_BENZENE_NAMESPACE_
00222
00223 #endif // VCSET_HPP