File: inforder.cpp

package info (click to toggle)
hyperrogue 12.1q-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 73,972 kB
  • sloc: cpp: 166,609; makefile: 145; sh: 10
file content (54 lines) | stat: -rw-r--r-- 1,206 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 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 {

  EX bool in() { return S3 >= OINF; }

  EX bool mixed() { return cgflags & qINFMIXED; }
  
  EX int alt_degree;

  struct hrmap_inforder : hrmap_hyperbolic {

    heptagon *create_step(heptagon *h, int direction) override {
      int deg = h->type;
      if(mixed()) deg = 7 - deg;
      auto h1 = init_heptagon(deg);
      bool par = h->s == hsA && direction == 0;
      h->c.connect(direction, h1, par ? 1 + hrand(2) : 0, false);

      h1->s = hsA;
      h1->distance = h->distance + (par ? -1 : 1);
      h1->c7 = newCell(deg, h1);

      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 }


}