more special cases fixed

This commit is contained in:
Zeno Rogue 2017-10-30 22:47:07 +01:00
parent ccbe7feb96
commit f860554c9f
4 changed files with 66 additions and 37 deletions

View File

@ -33,6 +33,9 @@ int roundTableRadius(cell *c) {
}
int celldistAltRelative(cell *c) {
if(sphere || quotient) {
return celldist(c) - 3;
}
if(tactic::on) return getAnthraxData(c, false);
return celldistAlt(c) - roundTableRadius(c);
}
@ -81,7 +84,7 @@ cell *findcompass(cell *c) {
}
bool grailWasFound(cell *c) {
if(euclid) return items[itHolyGrail];
if(euclid || quotient || sphere) return items[itHolyGrail];
return c->master->alt->alt->emeraldval & GRAIL_FOUND;
}
@ -1079,6 +1082,8 @@ void doOvergenerate() {
int dcs = size(dcal);
for(int i=0; i<dcs; i++) {
cell *c = dcal[i];
if(weirdhyperbolic && (c->land == laCaribbean)) continue;
if(weirdhyperbolic && (c->land == laStorms || c->land == laCamelot || c->land == laTemple || c->land == laOcean)) continue;
if(c->cpdist <= sightrange-6) setdist(c, 1, NULL);
}
}
@ -1099,7 +1104,7 @@ void moreBigStuff(cell *c) {
}
if(c->land == laStorms)
if(!euclid) {
if(!euclid && !quotient && !sphere) {
if(c->master->alt && c->master->alt->distance <= 2) {
generateAlts(c->master);
preventbarriers(c);

View File

@ -810,9 +810,12 @@ int celldistAlt(cell *c) {
decodeMaster(c->master, x, y);
return euclidAlt(x, y);
}
if(sphere || quotient) {
return celldist(c) - 3;
}
if(!c->master->alt) return 0;
if(ctof(c)) return c->master->alt->distance;
int dx[MAX_S3];
int dx[MAX_S3]; dx[0] = 0;
for(int u=0; u<S3; u++) if(createMov(c, u+u)->master->alt == NULL)
return ALTDIST_UNKNOWN;
for(int u=0; u<S3; u++)
@ -1414,15 +1417,18 @@ int celldistance(cell *c1, cell *c2) {
cell *cl1=c1, *cr1=c1, *cl2=c2, *cr2=c2;
while(true) {
/* if(cl1 == cl2) return d;
if(cl1 == cr2) return d;
if(cr1 == cl2) return d;
if(cr1 == cr2) return d; */
//if(isNeighbor(cl1, cl2)) return d+1;
//if(isNeighbor(cl1, cr2)) return d+1;
//if(isNeighbor(cr1, cl2)) return d+1;
//if(isNeighbor(cr1, cr2)) return d+1;
if(weirdhyperbolic) {
if(cl1 == cl2) return d;
if(cl1 == cr2) return d;
if(cr1 == cl2) return d;
if(cr1 == cr2) return d;
if(isNeighbor(cl1, cl2)) return d+1;
if(isNeighbor(cl1, cr2)) return d+1;
if(isNeighbor(cr1, cl2)) return d+1;
if(isNeighbor(cr1, cr2)) return d+1;
}
if(d1 == d2) for(int u=0; u<2; u++) {
cell *ac0 = u ? cr1 : cr2, *ac = ac0;
@ -1445,11 +1451,16 @@ int celldistance(cell *c1, cell *c2) {
}
}
/* forCellEx(c, cl2) if(isNeighbor(c, cr1)) return d+2;
forCellEx(c, cl1) if(isNeighbor(c, cr2)) return d+2;
if(weirdhyperbolic) {
forCellEx(c, cl2) if(isNeighbor(c, cr1)) return d+2;
forCellEx(c, cl1) if(isNeighbor(c, cr2)) return d+2;
forCellEx(ca, cl2) forCellEx(cb, cr1) if(isNeighbor(ca, cb)) return d+3;
forCellEx(ca, cl1) forCellEx(cb, cr2) if(isNeighbor(ca, cb)) return d+3; */
forCellEx(ca, cl2) forCellEx(cb, cr1) if(isNeighbor(ca, cb)) return d+3;
forCellEx(ca, cl1) forCellEx(cb, cr2) if(isNeighbor(ca, cb)) return d+3;
forCellEx(ca, cl2) forCellEx(cb, cr1) forCellEx(cc, cb) if(isNeighbor(ca, cc)) return d+4;
forCellEx(ca, cl1) forCellEx(cb, cr2) forCellEx(cc, cb) if(isNeighbor(ca, cc)) return d+4;
}
if(d1 >= d2) {
cl1 = chosenDown(cl1, -1, 0, celldist);

View File

@ -508,7 +508,7 @@ namespace princess {
}
info *getPrisonInfo(cell *c) {
if(euclid) return NULL;
if(euclid || quotient || sphere) return NULL;
if(c->land != laPalace) return NULL;
if(!c->master->alt) return NULL;
int ev = c->master->alt->alt->emeraldval; // NEWYEARFIX
@ -734,50 +734,54 @@ namespace clearing {
std::map<heptagon*, clearingdata> bpdata;
int plantdir(cell *c) {
generateAlts(c->master);
for(int i=0; i<7; i++)
generateAlts(c->master->move[i]);
if(!quotient) {
generateAlts(c->master);
for(int i=0; i<S7; i++)
generateAlts(c->master->move[i]);
}
int d = celldistAlt(c);
if(nontruncated) {
for(int i=0; i<7; i++) {
for(int i=0; i<S7; i++) {
cell *c2 = createMov(c, i);
if(!pseudohept(c2) && celldistAlt(c2) == d-1)
return i;
}
for(int i=0; i<7; i++) {
for(int i=0; i<S7; i++) {
cell *c2 = createMov(c, i);
if(celldistAlt(c2) == d-1)
return (i+1) % 7;
return (i+1) % S7;
}
}
for(int i=1; i<6; i+=2) {
for(int i=1; i<S6; i+=2) {
cell *c2 = createMov(c, i);
if(celldistAlt(c2) == d-1)
return i;
}
int quseful = 0, tuseful = 0;
for(int i=1; i<6; i+=2) {
int quseful = 0, tuseful = 0, tuseful2 = 0;
for(int i=1; i<S6; i+=2) {
cell *c2 = c->mov[i];
if(celldistAlt(c2) == d) {
bool useful = false;
for(int j=1; j<6; j++) {
for(int j=1; j<S6; j++) {
cell *c3 = createMov(c2, j);
if(celldistAlt(c3) == d-1)
useful = true;
}
if(useful) quseful++, tuseful += i;
if(useful) quseful++, tuseful += (1<<i), tuseful2 = i;
}
}
if(quseful == 1) return tuseful;
if(quseful == 1) return tuseful2;
if(quseful == 2) {
int i;
if(tuseful == 3+5) i = 3;
if(tuseful == 5+1) i = 5;
if(tuseful == 1+3) i = 1;
if((d & 7) < 4) i = (i+2) % 6;
if(tuseful == (1<<3)+(1<<5)) i = 3;
if(tuseful == (1<<5)+(1<<1)) i = 5;
if(tuseful == (1<<1)+(1<<3)) i = 1;
if(tuseful == (1<<5)+(1<<7)) i = 5;
if(tuseful == (1<<7)+(1<<1)) i = 7;
if((d & 7) < 4) i = (i+2) % S6;
return i;
}
printf("error in plantdir\n");
@ -791,6 +795,8 @@ namespace clearing {
void generate(cell *c) {
if(buggyplant) return;
if(sphere) return;
if(euclid) {
if(torus) return;
if(pseudohept(c)) return;
@ -822,11 +828,17 @@ namespace clearing {
int ds;
int stepcount = 0;
while(true) {
if(c == bd.root) {ds = bd.dist; break; }
// printf("R %4d C %4d\n", celldistAlt(bd.root), celldistAlt(c));
if(celldistAlt(c) > celldistAlt(bd.root)) {
stepcount++;
if(stepcount > 1000) {
printf("buggy #1\n");
return;
}
if(c->mpdist <= 6) {
if(c->monst != moMutant) return; // already cut!
@ -853,7 +865,7 @@ namespace clearing {
}
rpath.push_back(bd.root);
// printf("r [%4d] %p -> %p\n", celldistAlt(bd.root), bd.root, bd.root->mov[plantdir(bd.root)]);
bd.root = bd.root->mov[plantdir(bd.root)];
bd.root = createMov(bd.root, plantdir(bd.root));
}
}
@ -3363,6 +3375,7 @@ namespace dungeon {
*/
if(euclid) {
if(torus) return;
eucoord x, y;
decodeMaster(c->master, x, y);
string tab[] = {

View File

@ -633,7 +633,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
havewhat |= HF_DRAGON;
// printf("dragon generated with dchance = %d\n", dchance);
vector<int> possi;
for(int t=0; t<6; t++) if(c->mov[t]->mpdist > c->mpdist) possi.push_back(t);
for(int t=0; t<c->type; t++) if(c->mov[t]->mpdist > c->mpdist) possi.push_back(t);
if(size(possi)) {
int i = possi[hrand(size(possi))];
int dragonlength = 6 + items[itDragon] / 2;
@ -1565,7 +1565,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
}
else if(items[itHunting] < 10) {
vector<cell*> next;
forCellEx(c2, c) if(c2->mpdist > 7 && c2->type == 6) next.push_back(c2);
forCellEx(c2, c) if(c2->mpdist > 7 && (nontruncated || !ctof(c2))) next.push_back(c2);
if(size(next)) {
c->item = itHunting;
cell *c3 = next[hrand(size(next))];
@ -2066,7 +2066,7 @@ void setdist(cell *c, int d, cell *from) {
if(d >= BARLEV) {
if(!c->land && from->land != laElementalWall && from->land != laHauntedWall && from->land != laOceanWall &&
if(!c->land && from && from->land != laElementalWall && from->land != laHauntedWall && from->land != laOceanWall &&
from->land != laBarrier) {
if(!hasbardir(c)) setland(c, from->land);
}