1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 17:10:36 +00:00

more fixes to Warped Coast

This commit is contained in:
Zeno Rogue 2018-04-04 17:59:24 +02:00
parent 1abca6d08e
commit 5ea2a52f3f
4 changed files with 55 additions and 34 deletions

View File

@ -58,17 +58,22 @@ bool checkBarriersBack(cellwalker bb, int q, bool cross) {
return checkBarriersFront(bb, q);
}
// warp coasts use a different algorithm when has_nice_dual() is on
bool warped_version(eLand l1, eLand l2) {
return has_nice_dual() && (l1 == laWarpCoast || l1 == laWarpSea || l2 == laWarpSea || l2 == laWarpCoast);
}
bool checkBarriersNowall(cellwalker bb, int q, int dir, eLand l1=laNone, eLand l2=laNone) {
if(bb.c->mpdist < BARLEV && l1 == laNone) return false;
if(bb.c->bardir != NODIR && l1 == laNone) return false;
if(bb.c->mpdist < BARLEV && l1 == l2) return false;
if(bb.c->bardir != NODIR && l1 == l2) return false;
// if(bb.c->mov[dir] && bb.c->mov[dir]->bardir != NODIR && l1 == laNone) return false;
// if(bb.c->mov[dir] && bb.c->mov[dir]->mpdist < BARLEV && l1 == laNone) return false;
if(l1 != laNone) {
if(l1 != l2) {
bb.c->bardir = bb.spin; bb.c->barright = l2; bb.c->barleft = NOWALLSEP;
setland(bb.c, l1);
}
if(q > 10) return true;
if(q > 20) return true;
if(l1 == laNone) for(int i=0; i<bb.c->type; i++) {
cell *c1 = bb.c->mov[i];
@ -84,14 +89,14 @@ bool checkBarriersNowall(cellwalker bb, int q, int dir, eLand l1=laNone, eLand l
}
}
if(nonbitrunc && S3==4) {
if(warped_version(l1, l2)) {
bb = bb + wstep + (2*dir) + wstep + dir;
}
else if(S3==4) {
bb = bb + dir + wstep + dir;
}
else if(nonbitrunc) {
bb = bb + (dir>0?3:4) + wstep - (dir>0?3:4);
}
else {
bb = bb + wstep + (2*dir) + wstep + dir;
bb = bb + (dir>0?3:4) + wstep - (dir>0?3:4);
}
return checkBarriersNowall(bb, q+1, -dir, l2, l1);
}
@ -242,12 +247,13 @@ void extendNowall(cell *c) {
c->barleft = NOWALLSEP_USED;
cellwalker cw(c, c->bardir);
if(!nonbitrunc) {
bool warpv = warped_version(c->land, c->barright);
if(warpv) {
cw += wstep;
setland(cw.c, c->barright);
}
if(nonbitrunc && S3 == 4) {
else if(S3 == 4) {
auto cw2 = cw + wstep;
setland(cw2.c, c->barright);
cw2.c->barleft = NOWALLSEP_USED;
@ -257,16 +263,16 @@ void extendNowall(cell *c) {
for(int i=-1; i<2; i+=2) {
cellwalker cw0;
if(nonbitrunc && S3==4) {
if(warpv) {
cw0 = cw + (2*i) + wstep;
}
else if(S3==4) {
cw0 = cw + i + wstep + i;
}
else if(nonbitrunc) {
else {
cw0 = cw + (i>0?3:4) + wstep - (i>0?3:4);
//cw0 = cw + (3*i) + wstep - (3*i);
}
else {
cw0 = cw + (2*i) + wstep;
}
if(cw0.c->barleft != NOWALLSEP_USED) {
cw0.c->barleft = NOWALLSEP;
if(S3 == 4 && nonbitrunc) {
@ -281,9 +287,9 @@ void extendNowall(cell *c) {
printf("barright\n");
}// NONEDEBUG
setland(cw0.c, c->barright);
if(!nonbitrunc) cw0 += i;
if(warpv) cw0 += i;
cw0.c->bardir = cw0.spin;
if(!nonbitrunc) cw0 -= i;
if(warpv) cw0 -= i;
}
extendcheck(cw0.c);
extendBarrier(cw0.c);
@ -722,20 +728,33 @@ void buildCrossroads2(cell *c) {
bool buildBarrierNowall(cell *c, eLand l2, bool force) {
int dtab[3] = {0,1,6};
if(c->land == laNone) {
printf("barrier nowall! [%p]\n", c);
raiseBuggyGeneration(c, "barrier nowall!");
return false;
}
for(int i=0; i<3; i++) {
int d = (S3>3 && nonbitrunc) ? (2+(i&1)) : dtab[i];
bool warpv = warped_version(c->land, l2);
if(warpv && !pseudohept(c)) return false;
int ds[8];
for(int i=0; i<c->type; i++) ds[i] = i;
for(int j=0; j<c->type; j++) swap(ds[j], ds[hrand(j+1)]);
for(int i=0; i<c->type; i++) {
int d = ds[i];
/* if(warpv && whirl::whirl) {
d = hrand(c->type); */
if(warpv && c->mov[d] && c->mov[d]->mpdist < c->mpdist) continue;
/* }
else
d = (S3>3 && !warpv) ? (2+(i&1)) : dtab[i]; */
if(force) d=1;
cellwalker cw(c, d);
if(force || (checkBarriersNowall(cw, 0, -1) && checkBarriersNowall(cw, 0, 1))) {
eLand ws = warpv ? laWarpCoast : laNone;
if(force || (checkBarriersNowall(cw, 0, -1, ws, ws) && checkBarriersNowall(cw, 0, 1, ws, ws))) {
eLand l1 = c->land;
checkBarriersNowall(cw, 0, -1, l1, l2);
checkBarriersNowall(cw, 0, 1, l1, l2);

View File

@ -369,7 +369,7 @@ cell *buildAnotherEquidistant(cell *c, int radius) {
if(c2->land != c->land) return NULL;
// else if(ctof(c) && hrand(10000) < 20 && !isCrossroads(c->land) && gold() >= 200)
if(ctof(c2) && gold() >= R200 && hrand(10) < 2 && buildBarrierNowall(c2, laCrossroads4, true)) {
if(pseudohept(c2) && gold() >= R200 && hrand(10) < 2 && buildBarrierNowall(c2, laCrossroads4, true)) {
nowall = true;
// raiseBuggyGeneration(c2, "check");
// return;
@ -986,14 +986,14 @@ void buildBigStuff(cell *c, cell *from) {
// buildgreatwalls
if(celldist(c) < 3) {
if(celldist(c) < 3 && !whirl::whirl) {
if(top_land && c == cwt.c->master->move[3]->c7) {
buildBarrierStrong(c, 6, true, top_land);
}
}
else if(chaosmode) {
if(ctof(c) && hrand(10000) < 9000 && c->land && !inmirror(c) && buildBarrierNowall(c, getNewLand(c->land)))
if(pseudohept(c) && hrand(10000) < 9000 && c->land && !inmirror(c) && buildBarrierNowall(c, getNewLand(c->land)))
{}
else if(ctof(c) && c->land == laMirror && hrand(10000) < 2000 && !weirdhyperbolic) {
int bd = 2 + hrand(2) * 3;
@ -1001,13 +1001,13 @@ void buildBigStuff(cell *c, cell *from) {
}
}
else if(ctof(c) && isWarped(c->land) && hrand(10000) < 3000 && c->land &&
else if(pseudohept(c) && isWarped(c->land) && hrand(10000) < 3000 && c->land &&
buildBarrierNowall(c, eLand(c->land ^ laWarpSea ^ laWarpCoast))) ;
else if(ctof(c) && c->land == laCrossroads4 && hrand(10000) < 7000 && c->land &&
else if(pseudohept(c) && c->land == laCrossroads4 && hrand(10000) < 7000 && c->land &&
buildBarrierNowall(c, getNewLand(laCrossroads4))) ;
else if(ctof(c) && hrand(I10000) < 20 && !generatingEquidistant && !yendor::on && !tactic::on && !isCrossroads(c->land) &&
else if(pseudohept(c) && hrand(I10000) < 20 && !generatingEquidistant && !yendor::on && !tactic::on && !isCrossroads(c->land) &&
gold() >= R200 && !weirdhyperbolic &&
!inmirror(c) && !isSealand(c->land) && !isHaunted(c->land) && !isGravityLand(c->land) &&
(c->land != laRlyeh || rlyehComplete()) &&
@ -1018,7 +1018,7 @@ void buildBigStuff(cell *c, cell *from) {
buildBarrierNowall(c, laCrossroads4) ;
}
else if(weirdhyperbolic && specialland == laCrossroads4 && ctof(c) && hrand(I10000/4) < wallchance(c, deepOcean)) {
else if(weirdhyperbolic && specialland == laCrossroads4 && /*pseudohept(c) &&*/ hrand(I10000/4) < wallchance(c, deepOcean)) {
buildBarrierNowall(c, getNewLand(c->land));
}

View File

@ -708,6 +708,8 @@ namespace patterns {
si.symmetries = ctof(c) ? 1 : 2;
}
}
if(whirl::whirl && has_nice_dual() && !ishept(c) && ishex1(c)) si.dir = fix6(si.dir+3);
}
char whichPattern = 0;
@ -967,7 +969,7 @@ int pattern_threecolor(cell *c) {
// in the 'pure heptagonal' tiling, returns true for a set of cells
// which roughly corresponds to the heptagons in the normal tiling
bool pseudohept(cell *c) {
if(whirl::whirl) return whirl::pseudohept(c);
if(whirl::whirl) return whirl::pseudohept_val(c) == 0;
return pattern_threecolor(c) == 0;
}

View File

@ -59,9 +59,9 @@ namespace whirl {
return at;
}
bool pseudohept(cell *c) {
int pseudohept_val(cell *c) {
loc v = get_coord(c);
return (v.first - v.second)%3 == 0;
return (v.first - v.second + MODFIXER)%3;
}
whirlmap_t whirlmap[20][20];