renamed/documented/improved the rule generators, and the rules now include centers for all fieldvals

This commit is contained in:
Zeno Rogue
2020-01-28 17:58:55 +01:00
parent 3df5eff7f8
commit c556d21434
9 changed files with 54 additions and 21 deletions
@@ -4,12 +4,14 @@ Honeycomb data generator.
Usage: Usage:
./hyper -geo 534h -tcano honeycomb-534.dat -quit ./hyper -geo 534h -gen-rule honeycomb-rules-534.dat -quit
./hyper -geo 535h -tcano honeycomb-535.dat -quit ./hyper -geo 535h -gen-rule honeycomb-rules-535.dat -quit
./hyper -geo 435h -tcano honeycomb-435.dat -quit ./hyper -geo 435h -gen-rule honeycomb-rules-435.dat -quit
You need to change the value of XS7 to 6 (for 435) or 12 (for others) You need to change the value of XS7 to 6 (for 435) or 12 (for others)
You also need to select 'fp used for rules'
*/ */
#include "zlib.h" #include "zlib.h"
@@ -145,9 +147,27 @@ void add_candidate(cell *c) {
void test_canonical(string fname) { void test_canonical(string fname) {
if(S7 != XS7) { println(hlog, "fix XS7=", S7); exit(4); } if(S7 != XS7) { println(hlog, "fix XS7=", S7); exit(4); }
stop_game();
reg3::reg3_rule_available = false;
start_game(); start_game();
cell *c0 = cwt.at;
add_candidate(c0); int qc = reg3::quotient_count();
vector<cell*> c0;
if(geometry == gSpace535) {
c0.resize(qc, cwt.at);
}
else {
for(int fv=0; fv<qc; fv++) {
cell *c = cwt.at;
for(int i=0; i<100 || c->master->fieldval != fv; i++) c = c->cmove(hrand(S7));
c->FV = 0;
c0.push_back(c);
}
}
for(cell* c: c0) add_candidate(c);
array<int, XS7> empty; array<int, XS7> empty;
for(auto& e: empty) e = -1; for(auto& e: empty) e = -1;
@@ -186,8 +206,6 @@ void test_canonical(string fname) {
} }
} }
int root = 0;
if(true) { if(true) {
println(hlog, "original rules: ", child_rules); println(hlog, "original rules: ", child_rules);
@@ -230,8 +248,6 @@ void test_canonical(string fname) {
number_states = lqids; number_states = lqids;
for(auto& p: id_of) p.second = ih[p.second]; for(auto& p: id_of) p.second = ih[p.second];
println(hlog, "rehashed"); println(hlog, "rehashed");
println(hlog, "origin = ", ih[0]);
root = ih[0];
fflush(stdout); fflush(stdout);
} }
@@ -334,6 +350,10 @@ void test_canonical(string fname) {
auto& fp = currfp; auto& fp = currfp;
hwrite_fpattern(ss, fp); hwrite_fpattern(ss, fp);
vector<int> root(qc, 0);
for(int i=0; i<qc; i++) root[i] = id_of[generate_ext_nei(c0[i])];
println(hlog, "root = ", root);
hwrite(ss, root); hwrite(ss, root);
println(hlog, "copy data"); println(hlog, "copy data");
@@ -353,7 +373,7 @@ auto fqhook =
using namespace arg; using namespace arg;
if(0) ; if(0) ;
else if(argis("-tcano")) { else if(argis("-gen-rule")) {
shift(); test_canonical(args()); shift(); test_canonical(args());
} }
else return 1; else return 1;
+8 -2
View File
@@ -1089,9 +1089,12 @@ EX struct fpattern& getcurrfp() {
static fpattern fp(0); static fpattern fp(0);
if(fp.Prime) return fp; if(fp.Prime) return fp;
// fp.Prime = 5; fp.force_hash = 0x72414D0C; fp.solve(); // fp.Prime = 5; fp.force_hash = 0x72414D0C; fp.solve();
// fp.Prime = 11; fp.force_hash = 0x5FC4CFF0; fp.solve(); #ifdef FP_RULES
fp.Prime = 11; fp.force_hash = 0x5FC4CFF0; fp.solve();
#else
shstream ins(STR("\x05\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\xfc\xff\xff\xff\x01\x00\x00\x00\x04\x00\x00\x00\xfc\xff\xff\xff\x04\x00\x00\x00\xfe\xff\xff\xff\x00\x00\x00\x00\x01\x00\x00\x00\xfe\xff\xff\xff\x04\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\xfc\xff\xff\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\xfc\xff\xff\xff\x02\x00\x00\x00\x00\x00\x00\x00\xfc\xff\xff\xff\x01\x00\x00\x00\xfd\xff\xff\xff\x00\x00\x00\x00\x02\x00\x00\x00\xfd\xff\xff\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00")); shstream ins(STR("\x05\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\xfc\xff\xff\xff\x01\x00\x00\x00\x04\x00\x00\x00\xfc\xff\xff\xff\x04\x00\x00\x00\xfe\xff\xff\xff\x00\x00\x00\x00\x01\x00\x00\x00\xfe\xff\xff\xff\x04\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\xfc\xff\xff\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\xfc\xff\xff\xff\x02\x00\x00\x00\x00\x00\x00\x00\xfc\xff\xff\xff\x01\x00\x00\x00\xfd\xff\xff\xff\x00\x00\x00\x00\x02\x00\x00\x00\xfd\xff\xff\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00"));
hread_fpattern(ins, fp); hread_fpattern(ins, fp);
#endif
return fp; return fp;
} }
if(geometry == gSpace435) { if(geometry == gSpace435) {
@@ -1100,9 +1103,12 @@ EX struct fpattern& getcurrfp() {
if(fp.Prime) return fp; if(fp.Prime) return fp;
// fp.Prime = 5; fp.force_hash = 0xEB201050; fp.solve(); // fp.Prime = 5; fp.force_hash = 0xEB201050; fp.solve();
// what is 0x72414D0C?? // what is 0x72414D0C??
// fp.Prime = 11; fp.force_hash = 0x65CE0C00; fp.solve(); #ifdef FP_RULES
fp.Prime = 11; fp.force_hash = 0x65CE0C00; fp.solve();
#else
shstream ins(STR("\x05\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\xfc\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xfc\xff\xff\xff\x04\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\xff\xff\xff\xff\x02\x00\x00\x00\x03\x00\x00\x00\x03\x00\x00\x00\xfd\xff\xff\xff\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\xfc\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\xfd\xff\xff\xff\xfd\xff\xff\xff\x00\x00\x00\x00\xfd\xff\xff\xff\x02\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\xfd\xff\xff\xff\x03\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00")); shstream ins(STR("\x05\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\xfc\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xfc\xff\xff\xff\x04\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\xff\xff\xff\xff\x02\x00\x00\x00\x03\x00\x00\x00\x03\x00\x00\x00\xfd\xff\xff\xff\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\xfc\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\xfd\xff\xff\xff\xfd\xff\xff\xff\x00\x00\x00\x00\xfd\xff\xff\xff\x02\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\xfd\xff\xff\xff\x03\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00"));
hread_fpattern(ins, fp); hread_fpattern(ins, fp);
#endif
return fp; return fp;
} }
if(geometry == gSpace336) { if(geometry == gSpace336) {
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+16 -9
View File
@@ -883,7 +883,7 @@ EX namespace reg3 {
fieldpattern::fpattern fp; fieldpattern::fpattern fp;
int root; vector<int> root;
string other; string other;
vector<short> children; vector<short> children;
@@ -916,8 +916,9 @@ EX namespace reg3 {
void find_mappings() { void find_mappings() {
auto &nles = nonlooping_earlier_states; auto &nles = nonlooping_earlier_states;
nles.clear(); nles.clear();
address init = {0, root}; vector<address> bfs;
vector<address> bfs = {init}; for(int i=0; i<isize(quotient_map->allh); i++)
bfs.emplace_back(i, root[i]);
auto mov = [&] (int fv, int d) { auto mov = [&] (int fv, int d) {
return quotient_map->allh[fv]->move(d)->fieldval; return quotient_map->allh[fv]->move(d)->fieldval;
}; };
@@ -943,7 +944,9 @@ EX namespace reg3 {
for(auto p: q) q2[p]++; for(auto p: q) q2[p]++;
DEBB(DF_GEOM, ("q2 = ", q2)); DEBB(DF_GEOM, ("q2 = ", q2));
bfs = {init}; bfs = {};
for(int i=0; i<isize(quotient_map->allh); i++)
bfs.emplace_back(i, root[i]);
for(int i=0; i<isize(bfs); i++) { for(int i=0; i<isize(bfs); i++) {
address last = bfs[i]; address last = bfs[i];
int state = last.second; int state = last.second;
@@ -968,9 +971,9 @@ EX namespace reg3 {
hrmap_reg3_rule() : fp(0) { hrmap_reg3_rule() : fp(0) {
if(S7 == 6) load_ruleset("honeycomb-435.dat"); if(S7 == 6) load_ruleset("honeycomb-rules-435.dat");
else if(ginf[geometry].vertex == 5) load_ruleset("honeycomb-535.dat"); else if(ginf[geometry].vertex == 5) load_ruleset("honeycomb-rules-535.dat");
else load_ruleset("honeycomb-534.dat"); else load_ruleset("honeycomb-rules-534.dat");
reg3::generate(); reg3::generate();
origin = tailored_alloc<heptagon> (S7); origin = tailored_alloc<heptagon> (S7);
@@ -981,7 +984,7 @@ EX namespace reg3 {
h.distance = 0; h.distance = 0;
h.zebraval = 0; h.zebraval = 0;
h.fieldval = 0; h.fieldval = 0;
h.fiftyval = root; h.fiftyval = root[0];
h.c7 = NULL; h.c7 = NULL;
h.c7 = newCell(S7, origin); h.c7 = newCell(S7, origin);
@@ -1168,7 +1171,7 @@ EX hrmap* new_map() {
if(geometry == gSeifertWeber) return new seifert_weber::hrmap_singlecell(108*degree); if(geometry == gSeifertWeber) return new seifert_weber::hrmap_singlecell(108*degree);
if(geometry == gHomologySphere) return new seifert_weber::hrmap_singlecell(36*degree); if(geometry == gHomologySphere) return new seifert_weber::hrmap_singlecell(36*degree);
if(quotient && !sphere) return new hrmap_field3(&currfp); if(quotient && !sphere) return new hrmap_field3(&currfp);
if(among(geometry, gSpace534, gSpace435, gSpace535)) return new hrmap_reg3_rule; if(in_rule()) return new hrmap_reg3_rule;
return new hrmap_reg3; return new hrmap_reg3;
} }
@@ -1176,6 +1179,10 @@ hrmap_reg3* regmap() {
return ((hrmap_reg3*) currentmap); return ((hrmap_reg3*) currentmap);
} }
EX int quotient_count() {
return isize(regmap()->quotient_map->allh);
}
EX int celldistance(cell *c1, cell *c2) { EX int celldistance(cell *c1, cell *c2) {
if(c1 == c2) return 0; if(c1 == c2) return 0;
if(c1 == currentmap->gamestart()) return c2->master->distance; if(c1 == currentmap->gamestart()) return c2->master->distance;