Commit db78211c authored by Adam P. Goucher's avatar Adam P. Goucher

Speed improvements for incubator

parent b7e7407c
#ifndef LIFELIB_VERSION /*
__version__=[x.replace('"', '') for x in '''
*/
#define LIFELIB_VERSION "ll1.5"
#define LIFELIB_VERSION "ll1.51"
// '''.split() if ('ll' in x)][0]
#endif
......@@ -403,13 +403,20 @@ namespace apg {
bitworld env = lrem;
env += planes[M];
bool glider_plane = ((M == 1) && (planes.size() == 3));
bitworld lrem2 = lrem;
if (glider_plane) { lrem2 -= planes[2]; }
std::map<std::string, int64_t> tally;
while (lrem.population() != 0) {
while (lrem2.population() != 0) {
// Obtain cluster:
bitworld cluster = grow_cluster(lrem.get1cell(), env, zoi);
bitworld cluster = grow_cluster(lrem2.get1cell(), env, zoi);
cluster &= lrem;
lrem -= cluster;
lrem2 -= cluster;
uint64_t bb = 0;
// Obtain representation (may be a pseudo-object):
......@@ -486,6 +493,9 @@ namespace apg {
tally[elements[i]] += 1;
}
}
if (lrem.population() > 0) { tally["xq4_153"] += (lrem.population() / 5); }
return tally;
}
......
......@@ -8,6 +8,7 @@ namespace apg {
struct Incube {
uint64_t d[H];
uint64_t hist[H];
uint64_t gl[H];
};
template<int W, int H>
......@@ -16,9 +17,9 @@ namespace apg {
public:
std::map<std::pair<int, int>, Incube<W, H> > tiles;
int isGlider(Incube<W, H> *sqt, int px, int py, bool nuke, uint64_t* cachearray) {
int isGlider(Incube<W, H> *sqt, int px, int py) {
if (cachearray[py] & (1ull << px)) { return 2; }
if (sqt->gl[py] & (1ull << px)) { return 2; }
if ((px < 2) || (py < 2) || (px > W - 3) || (py > H - 5)) { return 0; }
......@@ -68,16 +69,9 @@ namespace apg {
if (array[high3] & (1ull << low6)) {
cachearray[y-1] |= (7ull << (x - 1));
cachearray[y ] |= (7ull << (x - 1));
cachearray[y+1] |= (7ull << (x - 1));
if (nuke) {
// Destroy the glider:
for (int j = -1; j <= 1; j++) {
sqt->d[y+j] &= (~(7ull << (x-1)));
}
}
sqt->gl[y-1] |= (7ull << (x - 1));
sqt->gl[y ] |= (7ull << (x - 1));
sqt->gl[y+1] |= (7ull << (x - 1));
return 1;
} else {
......@@ -170,6 +164,7 @@ namespace apg {
if ((annoyance > 0) && (excess != 0)) {
excess[annoyance] += 1;
}
if (annoyance == 0) { isGlider(sqt, x, y); }
}
}
}
......@@ -185,7 +180,7 @@ namespace apg {
Incube<W, H>* sqt = &(it->second);
int64_t x = it->first.first * (W / 8);
int64_t y = it->first.second * (H / 8);
uint64_t* q = (z ? sqt->hist : sqt->d);
uint64_t* q = (z ? ((z == 2) ? sqt->gl : sqt->hist) : sqt->d);
uint64_t f[8] = {0};
for (uint64_t j = 0; j < (H / 8); j++) {
int bis = best_instruction_set();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment