From d0075809675dcbb9d96e11d128d8b5cc8676a0b1 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 7 Nov 2017 00:40:46 +0100 Subject: [PATCH] configurable field patterns --- cell.cpp | 12 ++--- classes.h | 2 +- fieldpattern.cpp | 5 ++ geom-exp.cpp | 116 ++++++++++++++++++++++++++++++++++++++++++++++- langen.cpp | 1 + 5 files changed, 127 insertions(+), 9 deletions(-) diff --git a/cell.cpp b/cell.cpp index 929d86be..e5680385 100644 --- a/cell.cpp +++ b/cell.cpp @@ -442,9 +442,9 @@ struct hrmap_quotient : hrmap { } - int TOT = connections.size() / 7; + int TOT = connections.size() / S7; printf("heptagons = %d\n", TOT); - printf("all cells = %d\n", TOT*10/3); + printf("all cells = %d\n", TOT*(S7+S3)/S3); if(!TOT) exit(1); allh.resize(TOT); for(int i=0; iemeraldval = 0; h->zebraval = 0; h->fiftyval = 0; - h->fieldval = 7*i; + h->fieldval = S7*i; h->rval0 = h->rval1 = 0; h->cdata = NULL; h->distance = 0; h->c7 = newCell(S7, h); } - for(int j=0; j<7; j++) { - h->move[rv(j)] = allh[connections[i*7+j]/7]; - h->setspin(rv(j), rv(connections[i*7+j]%7)); + for(int j=0; jmove[rv(j)] = allh[connections[i*S7+j]/S7]; + h->setspin(rv(j), rv(connections[i*S7+j]%S7)); } } diff --git a/classes.h b/classes.h index bd02408c..fc01a0fa 100644 --- a/classes.h +++ b/classes.h @@ -196,7 +196,7 @@ struct geometryinfo { int vertex; int quotientstyle; int cclass; // 0-hyperbolic, 1-Euclidean, 2-spherical - int distlimit[2]; // truncated, non-truncated + array distlimit; // truncated, non-truncated }; static const int qZEBRA = 1; diff --git a/fieldpattern.cpp b/fieldpattern.cpp index 9191bf90..3a0e2868 100644 --- a/fieldpattern.cpp +++ b/fieldpattern.cpp @@ -695,7 +695,12 @@ void info() { printf("cases found = %d (%d hard)\n", cases, hard); } +fpattern current_quotient_field(0); +bool quotient_field_changed; + fpattern& getcurrfp() { + if(quotient == 2 && quotient_field_changed) + return current_quotient_field; if(S7 == 8 && S3 == 3) { static fpattern fp(17); return fp; diff --git a/geom-exp.cpp b/geom-exp.cpp index d05aff00..3c0516e7 100644 --- a/geom-exp.cpp +++ b/geom-exp.cpp @@ -29,13 +29,125 @@ string euchelp = int ewhichscreen = 2; -void showQuotientConfig() {} +// extra information for field quotient extra configuration + +struct primeinfo { + int p; + int cells; + bool squared; + }; + +struct fgeomextra { + eGeometry base; + vector primes; + int current_prime_id; + fgeomextra(eGeometry b, int i) : base(b), current_prime_id(i) {} + }; + +vector fgeomextras = { + fgeomextra(gNormal, 3), + fgeomextra(gOctagon, 1), + fgeomextra(g45, 0), + fgeomextra(g46, 3), + fgeomextra(g47, 0) + }; + +int current_extra = 0; + +void nextPrime(fgeomextra& ex) { + dynamicval g(geometry, ex.base); + int nextprime; + if(size(ex.primes)) + nextprime = ex.primes.back().p + 1; + else + nextprime = 2; + while(true) { + fieldpattern::fpattern fp(0); + fp.Prime = nextprime; + if(fp.solve() == 0) { + fp.build(); + ex.primes.emplace_back(primeinfo{nextprime, size(fp.matrices) / S7, fp.wsquare}); + break; + } + nextprime++; + } + } + +void nextPrimes(fgeomextra& ex) { + while(size(ex.primes) < 4) + nextPrime(ex); + } + +void enableFieldChange() { + fgeomextra& gxcur = fgeomextras[current_extra]; + fieldpattern::quotient_field_changed = true; + nextPrimes(gxcur); + dynamicval g(geometry, gQuotient2); + ginf[geometry].sides = ginf[gxcur.base].sides; + ginf[geometry].vertex = ginf[gxcur.base].vertex; + ginf[geometry].distlimit = ginf[gxcur.base].distlimit; + fieldpattern::current_quotient_field.init(gxcur.primes[gxcur.current_prime_id].p); + } + +void showQuotientConfig() { + gamescreen(2); + dialog::init(XLAT("advanced configuration")); + fgeomextra& gxcur = fgeomextras[current_extra]; + for(int i=0; i= 'a' && uni < 'a' + size(fgeomextras)) + current_extra = uni - 'a'; + else if(uni >= 'A' && uni < 'A' + size(gxcur.primes)) + gxcur.current_prime_id = uni - 'A'; + else if(uni == 'p') + nextPrime(gxcur); + else if(uni == 'x' || uni == '\n') { + targetgeometry = gxcur.base; restartGame('g'); + enableFieldChange(); + targetgeometry = gQuotient2; restartGame('g'); + } + else if(uni == 'c') { + targetgeometry = gEuclid; restartGame('g'); + fieldpattern::quotient_field_changed = false; + targetgeometry = gQuotient2; restartGame('g'); + } + else if(doexiton(sym, uni)) + popScreen(); + }; + + dialog::display(); + } void showTorusConfig() { cmode = sm::SIDE | sm::TORUSCONFIG; gamescreen(2); - dialog::init(XLAT("advanced concfiguration")); + dialog::init(XLAT("advanced configuration")); dialog::addSelItem(XLAT("number of cells (n)"), its(torusconfig::newqty), 'n'); dialog::addSelItem(XLAT("cell bottom-right from 0 (d)"), its(torusconfig::newdy), 'd'); diff --git a/langen.cpp b/langen.cpp index f293f458..0145d57a 100644 --- a/langen.cpp +++ b/langen.cpp @@ -217,6 +217,7 @@ int main() { allchars.insert("δ"); allchars.insert("∞"); allchars.insert("½"); + allchars.insert("²"); langPL(); langCZ(); langRU(); langTR(); langDE(); langPT();