1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-03-30 07:17:03 +00:00

brownian:: changed the maturing rule

This commit is contained in:
Zeno Rogue 2019-01-20 12:46:05 +01:00
parent 9cc9a881a7
commit bf979609b5

@ -10,7 +10,7 @@ namespace hr {
namespace brownian { namespace brownian {
map<cell*, vector<pair<cell*, bool >> > futures; map<cell*, vector<pair<cell*, int >> > futures;
int centersteps = 0; int centersteps = 0;
int totalsteps = 0; int totalsteps = 0;
@ -35,11 +35,15 @@ namespace brownian {
c->landparam += val; c->landparam += val;
} }
void recurse(cell *c, bool fat, cell *fatten_close = NULL) { static const int FAT = (-100); // less than 0
void recurse(cell *c, int fatten_from) {
int dl = getDistLimit(); int dl = getDistLimit();
while(true) { while(true) {
int cd = celldist(c);
bool fat = cd > fatten_from;
totalsteps++; totalsteps++;
if(!fatten_close && celldist(c) >= dl * (fat ? 4 : ISMOBILE ? 2 : 3) + celldist(cwt.at)) { if(cd >= dl * (fat ? 4 : ISMOBILE ? 2 : 3) + celldist(cwt.at)) {
cell *c1 = c; cell *c1 = c;
while(true) { while(true) {
cell *c2 = ts::left_parent(c1, celldist); cell *c2 = ts::left_parent(c1, celldist);
@ -47,20 +51,20 @@ namespace brownian {
setdist(c2, BARLEV, c1); setdist(c2, BARLEV, c1);
c1 = c2; c1 = c2;
} }
futures[c1].emplace_back(c, fat); futures[c1].emplace_back(c, fatten_from);
return; return;
} }
if(c->mpdist <= 7 || !among(c->land, laNone, laOcean, laBrownian) || (c->land != laBrownian && c->bardir != NODIR)) { if(c->mpdist <= 7 || !among(c->land, laNone, laOcean, laBrownian) || (c->land != laBrownian && c->bardir != NODIR)) {
centersteps++; return; centersteps++; return;
} }
cell *c2 = c->cmove(hrand(c->type)); cell *c2 = c->cmove(hrand(c->type));
int cd2 = celldist(c2);
// while(hrand(1000) < 1000 * chance) recurse(c); // while(hrand(1000) < 1000 * chance) recurse(c);
if(fat) recurse(c, false); if(!fat && (cd2 > fatten_from || hrand(100000) == 0)) {
if(!fat && ((fatten_close && celldistance(c, fatten_close) >= dl * 2) || hrand(20000) == 0)) { recurse(c, FAT);
recurse(c, true); fatten_from = FAT;
fat = true;
fatten_close = NULL;
} }
else if(fat) recurse(c, cd + dl * 6);
rise(c, fat ? 256 : 1); rise(c, fat ? 256 : 1);
c = c2; c = c2;
} }
@ -94,11 +98,12 @@ namespace brownian {
} }
void init(cell *c) { void init(cell *c) {
recurse(c, true); recurse(c, FAT);
recurse(c, true); recurse(c, FAT);
} }
void init_further(cell *c) { void init_further(cell *c) {
int dl = getDistLimit();
dynamicval<bool> be(generatingEquidistant, true); dynamicval<bool> be(generatingEquidistant, true);
int gdir = -1; int gdir = -1;
for(int i=0; i<c->type; i++) { for(int i=0; i<c->type; i++) {
@ -118,8 +123,8 @@ namespace brownian {
println(hlog, "brownian::init ", cw.at, " in distance ", celldistance(cw.at, cwt.at)); println(hlog, "brownian::init ", cw.at, " in distance ", celldistance(cw.at, cwt.at));
recurse(cw.at, false, cw.at); recurse(cw.at, celldist(c) + dl * 3);
recurse(cw.at, false); recurse(cw.at, celldist(c) + dl * 3);
cell *c2 = c; cell *c2 = c;
while(c2->mpdist > 7) { while(c2->mpdist > 7) {
@ -134,7 +139,7 @@ namespace brownian {
if(futures.count(c)) { if(futures.count(c)) {
auto m = move(futures[c]); auto m = move(futures[c]);
futures.erase(c); futures.erase(c);
for(pair <cell*, bool> p: m) for(auto p: m)
recurse(p.first, p.second); recurse(p.first, p.second);
futures.erase(c); futures.erase(c);
printf("centersteps = %d futures = %d totalsteps = %d\n", centersteps, isize(futures), totalsteps); printf("centersteps = %d futures = %d totalsteps = %d\n", centersteps, isize(futures), totalsteps);