From f65e1724b82e677c3bdcf3a8cafba221386b865c Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 2 Dec 2018 03:02:51 +0100 Subject: [PATCH] crystal:: implemented altdist, and some lands using it --- crystal.cpp | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 119 insertions(+), 3 deletions(-) diff --git a/crystal.cpp b/crystal.cpp index e6ea7613..a2f366da 100644 --- a/crystal.cpp +++ b/crystal.cpp @@ -18,8 +18,8 @@ typedef array ldcoord; static const ldcoord ldc0 = {}; ldcoord told(coord c) { ldcoord a; for(int i=0; imaster->c7 == c) { @@ -536,6 +541,94 @@ int dist_relative(cell *c) { } } +struct ddbuilder { + map data; + static const int Modval = 64; + int Xmod, cycle; + int zeroshift; + int coordid; + + coord long_representant(cell *c) { + auto co = roundcoord(get_coord(c) * Modval/4); + for(int s=0; s full_data; + manual_celllister cl; + + for(int i=0; i<(1<>j)&1) * 2; + cell *cc = get_heptagon_at(co, cs.dir)->c7; + cl.add(cc); + } + + map stepat; + + int steps = 0, nextstep = isize(cl.lst); + + cycle = 0; + int incycle = 0; + int needcycle = 16 + nextstep; + int elongcycle = 0; + + Xmod = Modval; + + int modmul = 1; + + for(int i=0; i needcycle * modmul) break; + if(i == nextstep) steps++, nextstep = isize(cl.lst); + cell *c = cl.lst[i]; + + auto co = long_representant(c); + if(co[coordid] < -Modval) continue; + if(full_data.count(co)) continue; + full_data[co] = steps; + + auto co1 = co; co1[coordid] -= Xmod; + auto co2 = co; co2[coordid] = gmod(co2[coordid], Xmod); + + if(full_data.count(co1)) { + int ncycle = steps - full_data[co1]; + if(ncycle != cycle) incycle = 1, cycle = ncycle; + else incycle++; + int dd = gdiv(co[coordid], Xmod); + // println(hlog, co, " set data at ", co2, " from ", data[co2], " to ", steps - dd * cycle, " at step ", steps); + data[co2] = steps - dd * cycle; + elongcycle++; + if(elongcycle > 2 * needcycle * modmul) Xmod += Modval, elongcycle = 0, modmul++; + } + else incycle = 0, needcycle++, elongcycle = 0; + forCellCM(c1, c) cl.add(c1); + } + + zeroshift = 0; + zeroshift = -get_level(cl.lst[0]); + + println(hlog, "cycle found: ", cycle, " Xmod = ", Xmod, " on list: ", isize(cl.lst), " zeroshift: ", zeroshift); + } + + }; + +ddbuilder ddb; + + int dist_alt(cell *c) { if(specialland == laCamelot && camelot_center) { if(PURE && !add_bitruncation) @@ -543,7 +636,10 @@ int dist_alt(cell *c) { if(c == camelot_center) return 0; return 1 + int(space_distance(camelot_center, c)); } - return 1; + else { + if(ddb.data.empty()) ddb.build(1); + return ddb.get_level(c); + } } ld crug_rotation[MAXDIM][MAXDIM]; @@ -654,7 +750,27 @@ void set_land(cell *c) { setland(c, laCrossroads); buildCamelot(c); } + + if(specialland == laTerracotta) { + int v = dist_alt(c); + if(((v&15) == 8) && hrand(100) < 90) + c->wall = waMercury; + } + + if(among(specialland, laOcean, laIvoryTower, laDungeon)) { + int v = dist_alt(c); + if(v == 0) + c->land = laCrossroads4; + else if(v > 0) + c->landparam = v; + else + c->landparam = -v; + } + if(specialland == laWarpCoast) { + if(gmod(cv, 240) >= 120) + c->land = laWarpSea; + } } int readArgs() {