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

Load (currently unused) 0-degree recipes

parent c815330c
Pipeline #36579033 passed with stages
in 6 minutes and 21 seconds
......@@ -89,7 +89,9 @@ namespace apg {
endblocks[i] += offset;
}
for (uint64_t i = 0; i < gouts.size(); i++) {
gouts[i].first += offset;
if ((gouts[i].second.first == 'x') || (gouts[i].second.first == 'i')) {
gouts[i].first += offset;
}
if (offset & 1) { gouts[i].second.first ^= ('x' ^ 'i'); }
}
initpos += offset;
......@@ -158,6 +160,7 @@ namespace apg {
std::vector<scstream> emitters;
std::vector<scstream> movers;
std::map<std::pair<char, int64_t>, scstream> emmap;
std::map<int64_t, std::vector<scstream> > zerodeg;
void loadpush(std::string filename) {
......@@ -182,6 +185,21 @@ namespace apg {
std::cerr << "Snarkmaker string = " << snarkmaker.length() << " bytes." << std::endl;
}
void load0deg(std::string filename) {
std::ifstream infile(filename);
std::string line;
while (std::getline(infile, line)) {
scstream scs(line);
zerodeg[scs.gouts[0].first].push_back(scs);
scstream scs2("[0, 109, 90, 93, 91, 90, 95, 91, 91, 138, 157, 96, 90, 120, 91, 97, 107, 90, 90, 93, 188] 0move44");
scs2.concat(scs, 0);
zerodeg[scs.gouts[0].first].push_back(scs2);
}
}
void loadrecs(std::string filename) {
scstream scempty;
......@@ -296,6 +314,34 @@ namespace apg {
}
bool fire_parallel(scstream &scs, lanespec desired, int64_t origback) {
lanespec rel = desired;
if (scs.endblocks.back() & 1) { rel.first *= -1; }
auto it = zerodeg.find(rel.first);
if ((it == zerodeg.end()) || (it->second.size() == 0)) {
return false;
} else {
int64_t bestcost = 1000000000;
scstream gls;
for (auto it2 = it->second.begin(); it2 != it->second.end(); ++it2) {
int64_t newcost = 400 * it2->gstream.size(); // and now add the change in quadratic penalty:
newcost += (2 * (scs.endblocks.back() - origback) + it2->endblocks.back()) * it2->endblocks.back();
if (newcost < bestcost) {
bestcost = newcost;
gls = (*it2);
}
}
uint32_t parity = (rel.second.second == gls.gouts.back().second.second) ? 2 : 1;
scs.concat(gls, parity);
return true;
}
}
void desirate(scstream &scs, lanespec desired) {
while (!desirast(scs, desired)) { }
}
......
......@@ -26,8 +26,12 @@ namespace apg {
sparselab(lifetree_abstract<uint32_t>* lt) : cfier(lt, "b3s23") {
lab = lt;
std::cerr << "Loading elbow recipes..." << std::endl;
cg.datadir = "data/";
el.loadrecs("data/simeks/pp.txt");
el.load0deg("data/simeks/pp0deg.txt");
el.loadpush("data/corderpush2.txt");
el.loadsm("data/snarkmaker.txt");
std::ifstream ins("data/corderpush.txt");
......@@ -36,6 +40,8 @@ namespace apg {
corderpush += " " + item;
}
normalpush = "[0,109,91,93,90,132,115,127,91,90,91,95,90,114,162,233,159,90,155,126,93,118,90,91,90,90] 7move17";
std::cerr << "...elbow recipes loaded." << std::endl;
}
pattern get_exclusions(pattern inpat) {
......
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