mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-25 17:40:36 +00:00
self-hiding knot option
This commit is contained in:
parent
cc45b32be1
commit
038d209941
@ -1,3 +1,7 @@
|
|||||||
|
#ifdef NOTKNOT
|
||||||
|
#include "../hyper.cpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../hyper.h"
|
#include "../hyper.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,6 +20,10 @@ nk_margin=2 -noplayer -canvas-random 20 -geo notknot -sight3 0.5 -ray-cells 6000
|
|||||||
https://youtu.be/eb2DhCcGH7U
|
https://youtu.be/eb2DhCcGH7U
|
||||||
nk_margin=4 -noplayer -canvas-random 20 -geo notknot -sight3 0.5 -ray-cells 600000 smooth_scrolling=1 camspd=10 panini_alpha=1 fov=150 -shot-hd ray_exp_decay_poly=30 ray_fixed_map=1 -ray-iter 100 ray_reflect_val=0.30
|
nk_margin=4 -noplayer -canvas-random 20 -geo notknot -sight3 0.5 -ray-cells 600000 smooth_scrolling=1 camspd=10 panini_alpha=1 fov=150 -shot-hd ray_exp_decay_poly=30 ray_fixed_map=1 -ray-iter 100 ray_reflect_val=0.30
|
||||||
|
|
||||||
|
https://youtu.be/vFLZ2NGtuGw
|
||||||
|
selfhide=1 loop=4 nk_margin=4 -noplayer -canvas-random 20 -geo notknot -sight3 0.5 -ray-cells 600000 smooth_scrolling=1 camspd=10 panini_alpha=1 fov=150 -shot-hd ray_exp_decay_poly=30 ray_fixed_map=1 -ray-iter 100 ray_reflect_val=0.30
|
||||||
|
|
||||||
|
|
||||||
The algorithm here is as follows:
|
The algorithm here is as follows:
|
||||||
|
|
||||||
* create the map without portals (this is just the cube with the trifoil knot in it)
|
* create the map without portals (this is just the cube with the trifoil knot in it)
|
||||||
@ -51,6 +59,9 @@ int knotsize = 3;
|
|||||||
|
|
||||||
int terminate_at = 500000000;
|
int terminate_at = 500000000;
|
||||||
|
|
||||||
|
/* make a self-hiding knot */
|
||||||
|
bool self_hiding = false;
|
||||||
|
|
||||||
eGeometry gNotKnot(eGeometry(-1));
|
eGeometry gNotKnot(eGeometry(-1));
|
||||||
|
|
||||||
/** It was easier to generate a program to design the trifoil knot than to generate it manually.
|
/** It was easier to generate a program to design the trifoil knot than to generate it manually.
|
||||||
@ -223,7 +234,7 @@ struct hrmap_notknot : hrmap {
|
|||||||
at(i,j,k)->zebraval = 0;
|
at(i,j,k)->zebraval = 0;
|
||||||
|
|
||||||
for(auto h: trifoil)
|
for(auto h: trifoil)
|
||||||
h->zebraval = 1;
|
h->zebraval = 9;
|
||||||
|
|
||||||
return at(cmax[0], cmax[1], cmax[2]);
|
return at(cmax[0], cmax[1], cmax[2]);
|
||||||
}
|
}
|
||||||
@ -240,23 +251,30 @@ struct hrmap_notknot : hrmap {
|
|||||||
|
|
||||||
all.emplace_back(new ucover(create_trifoil_knot(), 0));
|
all.emplace_back(new ucover(create_trifoil_knot(), 0));
|
||||||
|
|
||||||
|
bool first = true;
|
||||||
|
|
||||||
auto gen_adj = [&] (ucover *u, int d) {
|
auto gen_adj = [&] (ucover *u, int d) {
|
||||||
if(u->ptr[d]) return u->ptr[d];
|
if(u->ptr[d]) return u->ptr[d];
|
||||||
cmov(u->where, d);
|
cmov(u->where, d);
|
||||||
auto x = u->where->move(d);
|
auto x = u->where->move(d);
|
||||||
auto d1 = u->where->c.spin(d);
|
auto d1 = u->where->c.spin(d);
|
||||||
if(x->zebraval > 1) {
|
auto z = x->zebraval;
|
||||||
|
if(z & 6) {
|
||||||
println(hlog, "zebraval failure!");
|
println(hlog, "zebraval failure!");
|
||||||
exit(3);
|
exit(3);
|
||||||
x->zebraval = 0;
|
x->zebraval = 0;
|
||||||
}
|
}
|
||||||
u->ptr[d] = new ucover(x, x->zebraval);
|
if(!first && (z & 8))
|
||||||
|
z &=~ 9;
|
||||||
|
u->ptr[d] = new ucover(x, z);
|
||||||
u->ptr[d]->ptr[d1] = u;
|
u->ptr[d]->ptr[d1] = u;
|
||||||
u->ptr[d]->index = isize(all);
|
u->ptr[d]->index = isize(all);
|
||||||
all.push_back(u->ptr[d]);
|
all.push_back(u->ptr[d]);
|
||||||
return u->ptr[d];
|
return u->ptr[d];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
back:
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
|
||||||
/* handle all known unifications */
|
/* handle all known unifications */
|
||||||
@ -270,6 +288,11 @@ struct hrmap_notknot : hrmap {
|
|||||||
if(!uf || !ut) println(hlog, "null unified");
|
if(!uf || !ut) println(hlog, "null unified");
|
||||||
/* we always keep the one with the lower index */
|
/* we always keep the one with the lower index */
|
||||||
if(uf->index < ut->index) swap(uf, ut);
|
if(uf->index < ut->index) swap(uf, ut);
|
||||||
|
|
||||||
|
/* if a knot is removed, remove the other copy */
|
||||||
|
if((uf->state & 1) && !(ut->state & 1))
|
||||||
|
uf->state &=~ 1;
|
||||||
|
|
||||||
uf->state |= 2; uf->merged_into = ut;
|
uf->state |= 2; uf->merged_into = ut;
|
||||||
if(uf->where != ut->where)
|
if(uf->where != ut->where)
|
||||||
println(hlog, "where confusion");
|
println(hlog, "where confusion");
|
||||||
@ -356,9 +379,9 @@ struct hrmap_notknot : hrmap {
|
|||||||
auto uk = gen_adj(u, k);
|
auto uk = gen_adj(u, k);
|
||||||
if(uk->state != 0) continue;
|
if(uk->state != 0) continue;
|
||||||
auto ul = gen_adj(u, l);
|
auto ul = gen_adj(u, l);
|
||||||
if(ul->state != 1) continue;
|
if(!(ul->state & 1)) continue;
|
||||||
auto ukl = gen_adj(uk, l);
|
auto ukl = gen_adj(uk, l);
|
||||||
if(ukl->state != 1) continue;
|
if(!(ukl->state & 1)) continue;
|
||||||
funion(ul, ukl);
|
funion(ul, ukl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,9 +389,9 @@ struct hrmap_notknot : hrmap {
|
|||||||
for(int k=0; k<6; k++)
|
for(int k=0; k<6; k++)
|
||||||
for(int l=0; l<6; l++) {
|
for(int l=0; l<6; l++) {
|
||||||
auto uk = gen_adj(u, k);
|
auto uk = gen_adj(u, k);
|
||||||
if(uk->state != 1) continue;
|
if(!(uk->state & 1)) continue;
|
||||||
auto ul = gen_adj(u, l);
|
auto ul = gen_adj(u, l);
|
||||||
if(ul->state != 1) continue;
|
if(!(ul->state & 1)) continue;
|
||||||
if(abs(k-l) != 3)
|
if(abs(k-l) != 3)
|
||||||
funion(ul, uk);
|
funion(ul, uk);
|
||||||
}
|
}
|
||||||
@ -379,9 +402,9 @@ struct hrmap_notknot : hrmap {
|
|||||||
|
|
||||||
for(auto v: all) {
|
for(auto v: all) {
|
||||||
if(v->state == 0) lives++;
|
if(v->state == 0) lives++;
|
||||||
if(v->state == 1) walls++;
|
if(v->state & 1) walls++;
|
||||||
if(v->state == 2) merged++;
|
if(v->state & 2) merged++;
|
||||||
if(v->state == 3) overflow++;
|
if(v->state & 4) overflow++;
|
||||||
}
|
}
|
||||||
|
|
||||||
set<heptagon*> wheres;
|
set<heptagon*> wheres;
|
||||||
@ -432,7 +455,8 @@ struct hrmap_notknot : hrmap {
|
|||||||
all[i]->wallcolor = 0;
|
all[i]->wallcolor = 0;
|
||||||
|
|
||||||
for(int i=0; i<isize(all); i++)
|
for(int i=0; i<isize(all); i++)
|
||||||
if(all[i]->state == 1)
|
if(all[i]->state & 1)
|
||||||
|
if(!(all[i]->state & 2))
|
||||||
ufind(all[i])->wallcolor++;
|
ufind(all[i])->wallcolor++;
|
||||||
|
|
||||||
map<int, int> sizes;
|
map<int, int> sizes;
|
||||||
@ -447,6 +471,22 @@ struct hrmap_notknot : hrmap {
|
|||||||
|
|
||||||
println(hlog, "colors_used = ", colors_used);
|
println(hlog, "colors_used = ", colors_used);
|
||||||
|
|
||||||
|
if(first && self_hiding) {
|
||||||
|
ucover *what = nullptr;
|
||||||
|
for(int i=0; i<isize(all); i++)
|
||||||
|
if((all[i]->state & 1) && (all[i]->state & 8) && !(all[i]->state & 2))
|
||||||
|
what = ufind(all[i]);
|
||||||
|
|
||||||
|
for(int i=0; i<isize(all); i++)
|
||||||
|
if((all[i]->state & 1) && ufind(all[i]) == what)
|
||||||
|
all[i]->state &=~ 9;
|
||||||
|
|
||||||
|
println(hlog, "removed one knot!");
|
||||||
|
|
||||||
|
first = false; i = 0;
|
||||||
|
goto back;
|
||||||
|
}
|
||||||
|
|
||||||
for(int i=0; i<isize(all); i++)
|
for(int i=0; i<isize(all); i++)
|
||||||
if((all[i]->state & 1) && ufind(all[i]) == all[i]) {
|
if((all[i]->state & 1) && ufind(all[i]) == all[i]) {
|
||||||
all[i]->wallcolor = hrand(0x1000000) | 0x404040,
|
all[i]->wallcolor = hrand(0x1000000) | 0x404040,
|
||||||
|
Loading…
Reference in New Issue
Block a user