1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-11-13 04:13:03 +00:00

solution cache in field_quotient_3d

This commit is contained in:
Zeno Rogue
2025-09-29 11:49:36 +02:00
parent 69d63465dd
commit ba3fb00801

View File

@@ -1211,18 +1211,30 @@ EX eGeometry readGeo(const string& ss) {
return gNormal;
}
EX map<unsigned, string> solution_cache;
EX void field_quotient_3d(int p, unsigned hash) {
check_cgi();
cgi.require_basics();
stop_game_and_switch_mode(rg::nothing);
fieldpattern::field_from_current();
set_geometry(gFieldQuotient);
for(;; p++) {
println(hlog, "trying p = ", p);
currfp.Prime = p; currfp.force_hash = hash;
if(!currfp.solve()) break;
auto& cache = solution_cache[hash];
if(cache == "") {
for(;; p++) {
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) {