mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-11-13 20:27:10 +00:00
solution cache in field_quotient_3d
This commit is contained in:
22
geom-exp.cpp
22
geom-exp.cpp
@@ -1211,18 +1211,30 @@ EX eGeometry readGeo(const string& ss) {
|
|||||||
return gNormal;
|
return gNormal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EX map<unsigned, string> solution_cache;
|
||||||
|
|
||||||
EX void field_quotient_3d(int p, unsigned hash) {
|
EX void field_quotient_3d(int p, unsigned hash) {
|
||||||
check_cgi();
|
check_cgi();
|
||||||
cgi.require_basics();
|
cgi.require_basics();
|
||||||
stop_game_and_switch_mode(rg::nothing);
|
stop_game_and_switch_mode(rg::nothing);
|
||||||
fieldpattern::field_from_current();
|
fieldpattern::field_from_current();
|
||||||
set_geometry(gFieldQuotient);
|
set_geometry(gFieldQuotient);
|
||||||
for(;; p++) {
|
auto& cache = solution_cache[hash];
|
||||||
println(hlog, "trying p = ", p);
|
if(cache == "") {
|
||||||
currfp.Prime = p; currfp.force_hash = hash;
|
for(;; p++) {
|
||||||
if(!currfp.solve()) break;
|
println(hlog, "trying p = ", p);
|
||||||
|
currfp.Prime = p; currfp.force_hash = hash;
|
||||||
|
if(!currfp.solve()) break;
|
||||||
|
}
|
||||||
|
shstream outs;
|
||||||
|
hwrite_fpattern(outs, currfp);
|
||||||
|
cache = outs.s;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
println(hlog, "using the cached solution");
|
||||||
|
shstream ins(cache);
|
||||||
|
hread_fpattern(ins, currfp);
|
||||||
}
|
}
|
||||||
println(hlog, "set prime = ", currfp.Prime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EX void field_quotient_3d(string code) {
|
EX void field_quotient_3d(string code) {
|
||||||
|
|||||||
Reference in New Issue
Block a user