From fac3866d7ec5168cddb19ecc989aeee96b0768fe Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 2 Aug 2019 18:54:57 +0200 Subject: [PATCH] provided celldistance_approx for binary4 and kitedart3 --- binary-tiling.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/binary-tiling.cpp b/binary-tiling.cpp index 566e8737..2be97f11 100644 --- a/binary-tiling.cpp +++ b/binary-tiling.cpp @@ -813,13 +813,29 @@ int celldistance3_hex(heptagon *c1, heptagon *c2) { return steps; } +int celldistance3_approx(heptagon *c1, heptagon *c2) { + int d = 0; + while(true) { + if(d > 1000000) return d; /* sanity check */ + if(c1 == c2) return d; + if(neighborId(c1->c7, c2->c7) >= 0) return d + 1; + forCellEx(c3, c1->c7) if(neighborId(c3, c2->c7) >= 0) return d + 2; + if(c1->distance > c2->distance) c1=c1->cmove(updir()), d++; + else c2=c2->cmove(updir()), d++; + } + } + int celldistance3(heptagon *c1, heptagon *c2) { switch(geometry) { case gBinary3: return celldistance3_square(c1, c2); case gHoroTris: return celldistance3_tri(c1, c2); case gHoroRec: return celldistance3_rec(c1, c2); case gHoroHex: return celldistance3_hex(c1, c2); - default: println(hlog, "called celldistance3 for wrong geometry"); return 0; + default: + if(sol || !binarytiling) { + println(hlog, "called celldistance3 for wrong geometry"); return 0; + } + return celldistance3_approx(c1, c2); } }