9 #ifndef __Rubik__EnvUtil__
10 #define __Rubik__EnvUtil__
47 template <
class Environment,
class State>
49 uint64_t maxBucketSize);
51 template <
class Environment,
class State>
53 uint64_t maxBucketSize);
55 template <
class Environment,
class State>
57 std::vector<bucketChanges> &twoPieceChanges,
58 uint64_t maxBucketSize);
60 template <
class Environment,
class State>
65 template <
class Environment,
class State>
71 int64_t maxVal2 = cc.getMaxSinglePlayerRank2();
72 int64_t maxRank = cc.getMaxSinglePlayerRank();
76 uint64_t bucketSize = 0;
81 for (int64_t x = 0; x < maxRank; x++)
83 cc.unrankPlayer(x, s, 0);
86 cc.rankPlayerFirstTwo(s, 0, r1);
88 int64_t maxValOther = cc.getMaxSinglePlayerRank2(r1);
91 if (bucketSize > maxBucketSize)
96 data[r1].unused =
false;
97 data[r1].bucketID = currBucket;
98 data[r1].numEntries = maxValOther;
99 data[r1].bucketOffset = bucketSize;
100 bucketSize += maxValOther;
107 template <
class Environment,
class State>
109 uint64_t maxBucketSize)
114 int64_t maxRank = cc.getMaxSinglePlayerRank();
118 buckets[0].theSize = 0;
123 for (int64_t x = 0; x < maxRank; x++)
125 cc.unrankPlayer(x, s, 0);
127 int64_t r1, r2, r3, r4;
128 cc.rankPlayer(s, 0, r1, r2);
129 cc.rankPlayerFirstTwo(s, 0, r3);
130 cc.rankPlayerRemaining(s, 0, r4);
134 int64_t maxValOther = cc.getMaxSinglePlayerRank2(r1);
137 if (buckets[currBucket].theSize > maxBucketSize)
140 buckets.resize(buckets.size()+1);
141 buckets[currBucket].theSize = 0;
143 buckets[currBucket].theSize += maxValOther;
146 while (buckets[currBucket].theSize%
openSize != 0)
147 buckets[currBucket].theSize++;
151 template <
class Environment,
class State>
153 std::vector<bucketChanges> &twoPieceChanges,
154 uint64_t maxBucketSize)
159 int64_t maxVal2 = cc.getMaxSinglePlayerRank2();
160 int64_t maxRank = cc.getMaxSinglePlayerRank();
162 twoPieceChanges.resize(maxVal2);
166 buckets[0].theSize = 0;
171 for (int64_t x = 0; x < maxRank; x++)
173 cc.unrankPlayer(x, s, 0);
175 int64_t r1, r2, r3, r4;
176 cc.rankPlayer(s, 0, r1, r2);
177 cc.rankPlayerFirstTwo(s, 0, r3);
178 cc.rankPlayerRemaining(s, 0, r4);
182 int64_t maxValOther = cc.getMaxSinglePlayerRank2(r1);
185 if (buckets[currBucket].theSize > maxBucketSize)
188 buckets.resize(buckets.size()+1);
189 buckets[currBucket].theSize = 0;
191 twoPieceChanges[r1].lastDepthWritten = -1;
192 twoPieceChanges[r1].currDepthWritten = -1;
193 twoPieceChanges[r1].updated =
false;
197 buckets[currBucket].theSize += maxValOther;
199 while (buckets[currBucket].theSize%
openSize != 0)
200 buckets[currBucket].theSize++;
205 template <
class Environment,
class State>
208 uint64_t maxBucketSize;
211 int64_t maxRank = cc.getMaxSinglePlayerRank();
213 uint64_t statesLeft = 0;
216 for (int64_t x = 0; x < maxRank; x++)
218 cc.unrankPlayer(x, s, 0);
221 cc.rankPlayerFirstTwo(s, 0, r1);
223 int64_t maxValOther = cc.getMaxSinglePlayerRank2(r1);
226 statesLeft += maxValOther;
233 printf(
"%" PRId64
" total states. Using 2 buckets, each with about %" PRId64
" entries\n",
234 statesLeft, maxBucketSize);
236 return maxBucketSize;