1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-23 16:50:27 +00:00
hyperrogue/inforder.cpp

56 lines
1.2 KiB
C++
Raw Normal View History

2019-10-10 11:08:06 +00:00
// Hyperbolic Rogue -- infinite-order tessellations
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
/** \file inforder3.cpp
* \brief infinite-order tessellations
*
* very simple
*/
#include "hyper.h"
namespace hr {
EX namespace inforder {
2020-01-18 23:13:54 +00:00
EX bool in() { return S3 >= OINF; }
EX bool mixed() { return cgflags & qINFMIXED; }
EX int alt_degree;
2019-10-10 11:08:06 +00:00
struct hrmap_inforder : hrmap_hyperbolic {
heptagon *create_step(heptagon *h, int direction) {
2020-01-18 23:13:54 +00:00
int deg = h->type;
if(mixed()) deg = 7 - deg;
auto h1 = tailored_alloc<heptagon> (deg);
2019-10-10 11:08:06 +00:00
bool par = h->s == hsA && direction == 0;
h->c.connect(direction, h1, par ? 1 + hrand(2) : 0, false);
h1->alt = NULL;
h1->s = hsA;
h1->cdata = NULL;
h1->distance = h->distance + (par ? -1 : 1);
2020-01-18 23:13:54 +00:00
h1->c7 = newCell(deg, h1);
2019-10-10 11:08:06 +00:00
return h1;
}
};
EX hrmap* new_map() { return new hrmap_inforder; }
EX int celldistance(cell *c1, cell *c2) {
int d = 0;
while(true) {
if(c1 == c2) return d;
else if(c1->master->distance >= c2->master->distance) c1 = c1->move(0), d++;
else c2 = c2->move(0), d++;
}
}
EX }
}