Commit e27ed136 authored by Adam P. Goucher's avatar Adam P. Goucher
Browse files

General improvements

parent 03529e30
Pipeline #37853610 passed with stages
in 6 minutes and 20 seconds
......@@ -168,7 +168,7 @@ namespace apg {
return std::pair<pattern, pattern>(infy, infz);
}
cgsalvo<int64_t> sparsebuild(pattern infx, int64_t* bbox, int64_t* bbox3, bool existing_hand) {
cgsalvo<int64_t> sparsebuild(pattern infx, int64_t* bbox, int64_t* bbox3, bool &existing_hand) {
/*
* More scalable version of cg.preiterate.
*/
......@@ -190,6 +190,8 @@ namespace apg {
}
cs = cs2;
if (excluded_popcount(spat) == 0) { existing_hand = true; break; }
// Get next cluster and construct it:
pattern brcluster = get_lowerright(spat, 24, 40);
pattern leftover = spat - brcluster;
......@@ -236,6 +238,27 @@ namespace apg {
return cs;
}
bool find_hands(pattern &infx, int64_t* bbox3) {
auto lab = infx.getlab();
pattern findme2(lab, "3b2o$2bo2bo$bob2obo$obo2bobo$obo2bobo$bob2obo$2bo2bo$3b2o!", "b3s23");
pattern findme3(lab, "3$3b2H$3b2H!", "b3s23");
pattern replaceme2(lab, "3$3b2o$3b2o!", "b3s23");
pattern existing_hands = infx.match(findme2);
infx -= existing_hands.convolve(findme2);
existing_hands += infx.match(findme3);
bool existing_hand = existing_hands.nonempty();
if (existing_hand) {
existing_hands.convolve(replaceme2).getrect(bbox3);
}
return existing_hand;
}
bool ne_constell(pattern infx, int64_t* bbox2, scstream &scs) {
std::cerr << "Trying ne_constell()" << std::endl;
......@@ -273,12 +296,15 @@ namespace apg {
ba += "39bobo$38bobo$37bobo$36bobo$35bobo$34bobo$33bobo$32bobo$31bobo$30bobo$";
ba += "29bobo$28bobo$27bobo$26bobo$25bobo$26bo!";
pattern blocking_apparatus(lab, ba, "b3s23");
to_build += blocking_apparatus(bbox3[0], bbox3[1]);
cgsalvo<int64_t> cs = sparsebuild(to_build, bbox, bbox3, true);
bool existing_hand = find_hands(to_build, bbox3);
bool always_true = true;
cgsalvo<int64_t> cs = sparsebuild(to_build, bbox, bbox3, always_true);
for (auto ng = cs.gliders.begin(); ng != cs.gliders.end(); ++ng) {
int64_t il = ng->first - 3;
paralanes.emplace_back(il, std::pair<char, char>('p', ng->second));
......@@ -292,7 +318,7 @@ namespace apg {
// Now actually operate the elbow to emit the gliders:
el.desirate(scs, 2 * fd_forward);
scs.concat(elbow_dup, 0);
if (!existing_hand) { scs.concat(elbow_dup, 0); }
for (auto it = paralanes.begin(); it != paralanes.end(); ++it) {
if (!el.fire_parallel(scs, *it, middle)) { std::cerr << "Fatal error!" << std::endl; }
......@@ -305,20 +331,7 @@ namespace apg {
int64_t bbox3[4] = {bbox2[0] - 47, bbox2[1] - 42, bbox2[2], bbox2[3]};
auto lab = infx.getlab();
pattern findme2(lab, "3b2o$2bo2bo$bob2obo$obo2bobo$obo2bobo$bob2obo$2bo2bo$3b2o!", "b3s23");
pattern findme3(lab, "3$3b2H$3b2H!", "b3s23");
pattern replaceme2(lab, "3$3b2o$3b2o!", "b3s23");
pattern existing_hands = infx.match(findme2) + infx.match(findme3);
bool existing_hand = existing_hands.nonempty();
if (existing_hand) {
existing_hands.convolve(replaceme2).getrect(bbox3);
}
pattern to_build = infx - existing_hands.convolve(findme2);
pattern to_build = infx; bool existing_hand = find_hands(to_build, bbox3);
int64_t bbox[4] = {0}; cgsalvo<int64_t> cs = sparsebuild(to_build, bbox, bbox3, existing_hand);
......
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