mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2026-05-08 00:01:24 +00:00
apply 'strict tree maps' automatically
This commit is contained in:
@@ -1707,6 +1707,8 @@ EX void run(string fname) {
|
||||
catch(connection_debug_request& cr) {
|
||||
launch_connection_debugger(g, t, cr.c, cr.id);
|
||||
}
|
||||
if(!t.have_tree) rulegen::rules_known_for = "unknown";
|
||||
if(!t.have_tree) rulegen::convert_if_appropriate();
|
||||
start_game();
|
||||
}
|
||||
|
||||
@@ -2024,6 +2026,7 @@ EX void convert() {
|
||||
auto& ac = arb::current;
|
||||
ac.order++;
|
||||
ac.filename = full_geometry_name();
|
||||
ac.name = "CONVERTED: " + full_geometry_name();
|
||||
ac.comment = "converted from: " + ac.filename;
|
||||
ac.cscale = cgi.scalefactor;
|
||||
ac.boundary_ratio = 1;
|
||||
@@ -2116,6 +2119,14 @@ EX void activate() {
|
||||
}
|
||||
}
|
||||
|
||||
EX void deactivate() {
|
||||
if(in()) {
|
||||
println(hlog, "*** DEACTIVATING");
|
||||
geometry = base_geometry;
|
||||
variation = base_variation;
|
||||
}
|
||||
}
|
||||
|
||||
EX }
|
||||
|
||||
#if CAP_COMMANDLINE
|
||||
|
||||
@@ -14,6 +14,15 @@ EX namespace arcm {
|
||||
|
||||
EX bool in() { return cgflags & qARCHI; }
|
||||
|
||||
EX bool in_or_converted() {
|
||||
if(geometry == gArbitrary) {
|
||||
dynamicval d1(geometry, arb::convert::base_geometry);
|
||||
dynamicval d2(variation, arb::convert::base_variation);
|
||||
return in();
|
||||
}
|
||||
return cgflags & qARCHI;
|
||||
}
|
||||
|
||||
EX ld euclidean_edge_length = .5;
|
||||
|
||||
#if HDR
|
||||
@@ -1050,6 +1059,7 @@ EX bool load_symbol(const string& s, bool switch_geom) {
|
||||
stop_game();
|
||||
set_geometry(gArchimedean);
|
||||
current = at;
|
||||
rulegen::convert_if_appropriate();
|
||||
if(!delayed_start) start_game();
|
||||
return true;
|
||||
}
|
||||
@@ -1264,10 +1274,12 @@ archimedean_tiling edited;
|
||||
bool symbol_editing;
|
||||
|
||||
EX void next_variation() {
|
||||
if(geometry == gArbitrary) { stop_game(); arb::convert::deactivate(); }
|
||||
set_variation(
|
||||
PURE ? eVariation::dual :
|
||||
DUAL ? eVariation::bitruncated :
|
||||
eVariation::pure);
|
||||
rulegen::convert_if_appropriate();
|
||||
start_game();
|
||||
}
|
||||
|
||||
@@ -1297,6 +1309,7 @@ EX void enable(archimedean_tiling& arct) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
rulegen::convert_if_appropriate();
|
||||
start_game();
|
||||
}
|
||||
|
||||
|
||||
16
fake.cpp
16
fake.cpp
@@ -36,7 +36,7 @@ EX namespace fake {
|
||||
if(WDIM == 2 && standard_tiling() && GOLDBERG && S3 == 4 && gp::param.first == 1 && gp::param.second == 1) return true;
|
||||
if(WDIM == 2 && standard_tiling() && UNRECTIFIED && S3 == 4 && gp::param.first == 1 && gp::param.second == 1) return true;
|
||||
if(WDIM == 2 && standard_tiling() && UNTRUNCATED && S3 == 3 && gp::param.first == 1 && gp::param.second == 1) return true;
|
||||
if(arcm::in() && PURE) return true;
|
||||
if(arcm::in_or_converted() && PURE) return true;
|
||||
if(hat::in()) return true;
|
||||
if(WDIM == 2) return false;
|
||||
if(among(geometry, gBitrunc3)) return false;
|
||||
@@ -116,7 +116,7 @@ EX namespace fake {
|
||||
return cgi.emb->base_to_actual(h);
|
||||
}
|
||||
|
||||
if(arcm::in() || hat::in()) {
|
||||
if(arcm::in_or_converted() || hat::in()) {
|
||||
return underlying_map->get_corner(c, cid, cf);
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ EX namespace fake {
|
||||
}
|
||||
|
||||
#if CAP_ARCM
|
||||
if(arcm::in()) {
|
||||
if(arcm::in_or_converted()) {
|
||||
int t = arcm::id_of(c->master);
|
||||
int t2 = arcm::id_of(c->move(d)->master);
|
||||
auto& cof = arcm::current_or_fake();
|
||||
@@ -310,7 +310,7 @@ EX namespace fake {
|
||||
}
|
||||
|
||||
transmatrix relative_matrixc(cell *h2, cell *h1, const hyperpoint& hint) override {
|
||||
if(arcm::in()) return underlying_map->relative_matrix(h2, h1, hint);
|
||||
if(arcm::in_or_converted()) return underlying_map->relative_matrix(h2, h1, hint);
|
||||
if(h1 == h2) return Id;
|
||||
|
||||
for(int a=0; a<h1->type; a++) if(h1->move(a) == h2)
|
||||
@@ -320,7 +320,7 @@ EX namespace fake {
|
||||
}
|
||||
|
||||
transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override {
|
||||
if(arcm::in()) return underlying_map->relative_matrix(h2, h1, hint);
|
||||
if(arcm::in_or_converted()) return underlying_map->relative_matrix(h2, h1, hint);
|
||||
return relative_matrix(h2->c7, h1->c7, hint);
|
||||
}
|
||||
|
||||
@@ -587,7 +587,7 @@ EX ld around;
|
||||
/** @brief the value of 'around' which makes the tiling Euclidean */
|
||||
EX ld compute_euclidean() {
|
||||
#if CAP_ARCM
|
||||
if(arcm::in()) return arcm::current.N * 2 / arcm::current.euclidean_angle_sum;
|
||||
if(arcm::in_or_converted()) return arcm::current.N * 2 / arcm::current.euclidean_angle_sum;
|
||||
#endif
|
||||
if(underlying == gAperiodicHat) return 6;
|
||||
if(WDIM == 2 && BITRUNCATED) return 9 / (4.5 - 3. / S7 - 6. / S6);
|
||||
@@ -612,7 +612,7 @@ EX ld compute_euclidean() {
|
||||
|
||||
EX ld around_orig() {
|
||||
#if CAP_ARCM
|
||||
if(arcm::in())
|
||||
if(arcm::in_or_converted())
|
||||
return arcm::current.N;
|
||||
#endif
|
||||
if(hat::in()) return 6;
|
||||
@@ -669,7 +669,7 @@ EX void compute_scale() {
|
||||
geom3::apply_always3_to(ginf[gFake]);
|
||||
}});
|
||||
|
||||
if(arcm::in()) {
|
||||
if(arcm::in_or_converted()) {
|
||||
ginf[gFake].tiling_name = "(" + ginf[gArchimedean].tiling_name + ")^" + fts(around / around_orig());
|
||||
return;
|
||||
}
|
||||
|
||||
14
geom-exp.cpp
14
geom-exp.cpp
@@ -676,7 +676,7 @@ EX string full_geometry_name() {
|
||||
void action_change_variation() {
|
||||
if(0) ;
|
||||
#if CAP_ARCM
|
||||
else if(arcm::in()) arcm::next_variation();
|
||||
else if(arcm::in_or_converted()) arcm::next_variation();
|
||||
#endif
|
||||
#if MAXMDIM >= 4
|
||||
else if(reg3::in() || geometry == gCubeTiling) reg3::configure_variation();
|
||||
@@ -988,6 +988,16 @@ EX void showEuclideanMenu() {
|
||||
|
||||
dialog::init(XLAT("experiment with geometry"));
|
||||
|
||||
dynamicval d1(geometry, geometry);
|
||||
dynamicval d2(variation, variation);
|
||||
|
||||
bool converted = false;
|
||||
if(arb::convert::in() && rulegen::auto_rulegen) {
|
||||
converted = true;
|
||||
geometry = arb::convert::base_geometry;
|
||||
variation = arb::convert::base_variation;
|
||||
}
|
||||
|
||||
dialog::addSelItem(XLAT("geometry"), geometry_name(), 'd');
|
||||
dialog::add_action([] { pushScreen(ge_select_tiling); pushScreen(ge_select_filter); });
|
||||
|
||||
@@ -1021,7 +1031,7 @@ EX void showEuclideanMenu() {
|
||||
}
|
||||
#endif
|
||||
|
||||
if(fake::available()) {
|
||||
if(fake::available() && !converted) {
|
||||
dialog::addItem(XLAT("fake curvature"), '4');
|
||||
|
||||
dialog::add_action([] {
|
||||
|
||||
21
rulegen.cpp
21
rulegen.cpp
@@ -11,6 +11,8 @@ namespace hr {
|
||||
|
||||
EX namespace rulegen {
|
||||
|
||||
EX bool auto_rulegen = true;
|
||||
|
||||
/* limits */
|
||||
EX int max_retries = 999;
|
||||
EX int max_tcellcount = 1000000;
|
||||
@@ -2554,6 +2556,8 @@ auto hooks_arg =
|
||||
#endif
|
||||
|
||||
auto hooks = addHook(hooks_configfile, 100, [] {
|
||||
param_b(auto_rulegen, "auto_rulegen")
|
||||
->editable("auto-use strict tree maps when appropriate", 'a');
|
||||
param_i(max_retries, "max_retries")
|
||||
->set_reaction(change_rulegen_params);
|
||||
param_i(max_tcellcount, "max_tcellcount")
|
||||
@@ -2714,6 +2718,8 @@ EX void show() {
|
||||
return;
|
||||
}
|
||||
|
||||
add_edit(auto_rulegen);
|
||||
|
||||
dialog::addBoolItem(XLAT("in tes internal format"), arb::in(), 't');
|
||||
dialog::add_action(switch_tes_internal_format);
|
||||
|
||||
@@ -2814,5 +2820,20 @@ int readRuleArgs() {
|
||||
auto hook = addHook(hooks_args, 100, readRuleArgs);
|
||||
#endif
|
||||
|
||||
EX void convert_if_appropriate() {
|
||||
println(hlog, "*** CONVERT TO RULEGEN");
|
||||
if(!auto_rulegen) return;
|
||||
if(!hyperbolic) return;
|
||||
println(hlog, "converting");
|
||||
if(geometry != gArbitrary)
|
||||
arb::convert::convert();
|
||||
println(hlog, "activating");
|
||||
arb::convert::activate();
|
||||
println(hlog, "preparing rules");
|
||||
|
||||
if(!prepare_rules()) return;
|
||||
println(hlog, "success");
|
||||
}
|
||||
|
||||
EX }
|
||||
}
|
||||
|
||||
@@ -1614,6 +1614,7 @@ EX void set_variation(eVariation target) {
|
||||
if(target != eVariation::pure) {
|
||||
if(bt::in() || sol || aperiodic || WDIM == 3) if(!mproduct) geometry = gNormal;
|
||||
}
|
||||
arb::convert::deactivate();
|
||||
auto& cd = ginf[gCrystal];
|
||||
if(target == eVariation::bitruncated && cryst && cd.sides == 8 && cd.vertex == 4) {
|
||||
cd.vertex = 3;
|
||||
|
||||
Reference in New Issue
Block a user