<<

Bridges 2017 Conference Proceedings

HyperRogue: Playing with Hyperbolic

Eryk Kopczynski´ Dorota Celinska´ Marek Ctrnˇ act´ University of Warsaw, Poland University of Warsaw, Poland [email protected] [email protected] [email protected]

Abstract HyperRogue is a computer game whose action takes place in the hyperbolic plane. We discuss how HyperRogue is relevant for mathematicians, artists, teachers, and game designers interested in .

Introduction a) b) c) d)

Figure 1 : Example lands in HyperRogue: (a) Crossroads II, (b) Galapagos,´ (c) Windy Plains, (d) Reptiles.

Hyperbolic geometry and tesselations of the hyperbolic plane have been of great interest to mathematical artists [16], most notably M.C. Escher and his Circle Limit series [4]. Yet, there were almost no attempts to bring more complexity and life to the hyperbolic plane. This is what our game, HyperRogue, sets out to do. We believe that it is relevant to mathematical artists for several reasons. First, fans of Escher’s art, or the famous Hofstadter’s book Godel,¨ Escher, Bach: an Eternal Golden Braid [10], will find many things appealing to them. The graphical style of HyperRogue is directly inspired by Escher’s tesselations, some of the music is based on Shepherd tones and crab canons if the gameplay in the given area is based on similar principles. As for Godel,¨ there is also one game mechanic reminding of a logical paradox: magical Orbs normally lose their power each turn, but Orb of Time prevents this, as long as the given Orb had no effect. Does Orb of Time lose its power if it is the only Orb you have? Second, we believe that exploring the world of HyperRogue is one of the best ways to understand hyperbolic geometry. In typical courses one would learn that, for example, the sum of angles of a hyperbolic is less than 180◦, but it is not clear how this could be applicable, or what would be the effects for people living in the hyperbolic world; even in other existing hyperbolic games and VRs [8, 13, 17] the world is periodic and sterile. In HyperRogue, players are led to gain intuitions about hyperbolic geometry, and to pose questions about how things known from our world would work there. For example, the design of the Hive, one of the lands in HyperRogue, incorporates studying war strategies, like army formations, that are meaningful in wars taking place in hyperbolic plane.

9 Kopczy´nski,Celi´nska and Ctrn´actˇ

Third, we believe that game design, or creating interesting maps and rule systems for games, is also a kind of art. The first version of HyperRogue had very simple rules: take Chess, but replace the “chessboard” with a tiling of the hyperbolic plane, and give just one piece to the player (player character, or PC); in your turn you can wait, move to an adjacent tile if it is not blocked by a wall, or attack an enemy on an adjacent tile (destroying it); after your move, each enemy moves (with similar choices). Enemies do not act very intelligently—they just try to get to the PC using the shortest possible route and do not avoid being attacked—but they can appear in large numbers. That would not be very interesting in a Euclidean tiling, but hyperbolic geometry makes it fun—not only because it feels very different, but also because it is possible to use the hyperbolic properties tactically, to deal with large groups of enemies. On the other hand, many of the traditional game design techniques would not make sense in a virtually infinite world. No Mans Sky is praised for having 1019 stars in its universe—our game has more space in 200 tiles around the starting point because of using hyperbolic geometry, and one would usually go further during the game. HyperRogue explores how hyperbolic geometry could be used for interesting gameplay, and how to deal with infinity. The basic game is grid-based and turn-based, but a shmup mode exists to explore gameplay with continuous hyperbolic space and time. HyperRogue takes much from roguelikes, a genre of computer games that is relatively unknown to the mainstream gamers [5].Roguelikes are often viewed as a subgenre of computer role-playing games (CRPGs), however, they have evolved separately from the mainstream; with their focus on gameplay requiring player skill and positioning instead of following a pre-written story, we view them as sharing more with board games such as Chess than with (typically very easy) CRPGs. HyperRogue follows the roguelike tradition of permanent failure: when one loses the game, they have to start a new one—from the beginning, except from the fact that they have learnt from their failure, and this knowledge stays with them. Some players might feel that their game ends when too many enemies are generated at the same time, which is a random event not under the control. While it is definitely possible to fail due to bad luck, the best players complete the difficult Hyperstone Quest, which involves getting 10 treasures in every land, with high probability, in roughly two hours. It may take you many tries to win the game, but then that is because you enjoy the gameplay (otherwise you would not be playing), but you have to learn, and learning is fun. This could be seen as a metaphor of how we learn mathematics—as shown by the famous quotes of Euclid himself (There is no royal road to geometry) and Gauss (The enchanting charms of this sublime science reveal themselves in all their beauty only to those who have the courage to go deeply into it.), we have to learn the basic stuff first, then proceed to more complicated topics. 1

Geometry of HyperRogue

HyperRogue uses the order-7 truncated triangular tiling of the hyperbolic plane, also known as the hyperbolic soccerball tiling. One advantage of this tiling is that it it is similar in spirit to the hex tiling commonly used in tactical games. This advantage is shared by the more regular order-3 heptagonal tiling; however, the in that tiling are very big, and less appropriate for a game. HyperRogue allows experimenting with other curvatures—switching to the heptagonal tiling effectively increases the curvature, while replacing the heptagons with leads to the normal Euclidean hex grid, and if we go further by replacing them with pentagons, we get the positive curvature of the truncated (i.e., the usual spherical soccerball) or . The distinction between hexagons and heptagons is important in gameplay—in some sense, the hyper- bolic effects are concentrated on the heptagons. Suppose that the player character (PC) and two enemies are standing on the vertices of a triangle in the hex grid, as in Figure 2d. We cannot attack any of the enemies,

1 The in-game tutorial serves as an introduction to hyperbolic geometry, with the challenge removed.

10 HyperRogue: Playing with Hyperbolic Geometry

a) b) c) d)

Figure 2 : Tilings. (a) truncated triangular tiling, (b) heptagonal tiling, (c) triheptagonal tiling used in the Warped Coast, (d) Euclidean hex grid. because the other one would attack us then. We could escape, but then the enemies move parallel to us, thus recreating the same configuration. However, if we were actually standing on a in the hyperbolic grid, one of the possible moves will make the enemies unable to recreate the configuration, and allow us to attack them one by one. (For completeness: on a dodecahedron the enemies will capture us quickly, and on the soccerball, the only way to avoid capture is to consistently avoid the pentagons; thus, the smaller the curvature, the easier our situation is.) This is not caused by using our particular tiling, but a general fact of hyperbolic geometry—there is one shortest path between two points, and if one is forced to avoid that path, they must use another one, which will be an equidistant curve rather than a straight line, and thus it will be longer by a linear factor, rather than an additive constant, as would happen in Euclidean geometry. This is especially visible in the Land of Eternal Motion, where the tiles fall after someone moves on them, so even a single pursuer has to take another path, and thus is completely unable to pursue the PC, even though moving with the same speed.

a) b) c) d)

Figure 3 : Curves: (a) straight lines in Vineyard, (b) circles in Hive, (c) equidistants in Ivory Tower, (d) horocycles in Temple of Cthulhu.

The well known hyperbolic curves have their discrete analogs in our tiling. The distance between two tiles is the length of the shortest path between them. A straight line, also called geodesic, is a path p such that the distance between tiles pa and pb is always exactly |a − b|. A circle is a cycle consisting of all tiles in distance (radius) r from the given point, called the center of the cycle. An equidistant is a curve consisting of tiles in distance r from the given straight line. A horocycle is a limit circle of infinite radius—a curve such that every segment of it is a segment of a circle, with larger segments corresponding to greater radii (the discrete approximation allows us to give a slightly simpler definition of the horocycle than the usual one). Two curves p and q are concentric if the distance from q is the same for each point in p.

Let ad be the numbers of tiles in distance d from some heptagon in our tiling i.e., the perimeter of a circle of radius d. We believe this sequence has not been previously studied. The initial values of this sequence are 1, 7, 14, 28, 49, 84, 147, 252, 434, 749... and for d ≥ 5, the following recursive formula holds:

11 Kopczy´nski,Celi´nska and Ctrn´actˇ √ √ √ √ d 1+ 13+ 2 13−2 ad+4 = ad+3 + ad+2 + ad+1 − ad, and thus ad = Θ(γ ), where γ = 4 ≈ 1.72208 ≈ 3. This γ is the fundamental constant of our tiling, as the same recursive formula eventually holds when we start from a , or include the whole area of the circle, instead of just the boundary, and thus all these sequences are asymptotically Θ(γd); γd is also the ratio of lengths of corresponding segments of concentric horocycles in distance d, and the limit of the similar ratio for circles and equidistants, as r → ∞. In the heptagonal tiling the respective value of γ is φ + 1 = φ2 = 2.618..., i.e., the sequence grows exactly twice as fast as the Fibonacci sequence.

What Can We Learn, or How Does Hyperbolic Geometry Affect the Gameplay

The world of HyperRogue consists currently of about 50 different lands. Each land has a specific theme (treasure to collect, enemies to fight), and specific mechanics displaying different aspects of hyperbolic geometry. Regular straight lines are usually employed as borders between the lands (see Figure 1a), but curves of large radius (circles, equidistants, and horocycles of infinite radius) are used in some cases. For example, Camelot is a large circle without internal markings; players are required to devise an algorithm to reach the center. It is practically impossible to reach the center solely on Euclidean intuitions – by looking at a small part of a large radius curve it is impossible to tell the exact way to the center, what is the radius, nor which kind of curve it is (their curvatures are almost equal). In a large radius curve, moving into a direction which appears promising takes one back to the edge very quickly. In other cases the consecutive concentric horocycles are marked, so that finding the correct direction is easy; for example, in the Temple of Cthulhu every sixth horocycle is marked. Since all horocycles have roughly the same shape, moving towards the center of the Temple gives the players an impression of endless descent, a bit like in Escher’s famous Ascending and Descending. A very important aspect of HyperRogue is that the number of tiles in radius r is exponential. Players quickly learn that it is practically impossible to reach a location they have been before, unless some method of marking the way has been used. Exponential space is not the only reason why this is difficult – the other reason is curvature: if you move from A to B, from B to C, and from C to A, the map will usually be rotated; this happens because the sum of external angles of the triangle ABC is not 360◦. Some time later, they might be surprised about one situation where they do return – going back towards the center of a large radius curve. This commonly happens in the Ivory Tower, where artificial gravity pushes creatures towards the straight line bordering the Tower; after ascending in a random way, and descending back to the borderline, one typically lands very close to their starting point. Each level of the Ivory Tower (levels are marked with alternating colors in Figure 3c) is an equidistant curve, giving insight to how a three-dimensional hyperbolic space with gravity might operate – if one floor is two tiles high, and we have two points A and B on some level in distance d along the equidistant, the distance betwen the corresponding points A0 and B0 on the next floor along their equidistant will be γ2 ≈ 3 times larger. Then, they might be surprised yet again when they find a randomly generated large obstacle on their way to the center of a large radius curve (as happens e.g. in the Princess Quest) – even though it seems that circumventing such obstacles is impossible (trying other routes pushes you back into the obstacle) this can be done with persistence. The Yendor Quest requires one to return to a location 100 steps away, which is practically impossible without devising some method (γ100 possible directions). Yendor Quest and Camelot are examples of quests which would be trivial in Euclidean. On the other hand, in the Galapagos´ one receives a quest which is easy in hyperbolic plane, but hopeless in Euclidean. The player encounters a Baby Tortoise, and has to find an adult of the same species. However, each tile in the Galapagos´ has 21 binary environmental factors, which 21 change smoothly (most of the factors are equal for tiles which are close); and for each of 2 combinations√ of the factors, there is a different species. In the Euclidean world, one would have to travel Ω( 221) tiles to find the adult tortoise matching a random baby – and that is under (definitely false) assumptions that we

12 HyperRogue: Playing with Hyperbolic Geometry know where to go, that each tile contains a tortoise, and environmental factors change quickly. However, in the hyperbolic world, the task can be completed quite easily, simply by moving towards areas where more factors match. Exponential space is also at the core of game design of HyperRogue. The play in roguelikes and similar games progresses from easy to difficult levels; on the easy levels, the player might find some powers or resources (equipment, consumables, XP, etc.), which will be useful on later levels. In this design, unlimited amount of space on each level leads to grinding, i.e., staying on easier levels for long times in order to collect large amounts of resources. Allowing grinding is considered a bad design, since it leads to boring gameplay, and modern well designed roguelikes avoid this, usually by restricting the size of levels. However, HyperRogue has to take a different approach. The player’s progress and score is measured by the number of treasures they have collected; the more treasures they have collected in a given land, the more enemies appear in this land, thus making it harder and harder to collect more treasures. If permanent equipment or consumables did appear on the map, it would be possible to grind; for this reason, there are no permanent or consumable resources to be found, other than treasures and Dead Orbs which have very limited uses. One possible solution which combines permanent and consumable powers with infinity is to give powers only as extra prizes for collecting treasure – since the ability to collect treasures is limited, so are the prizes. The current versions of HyperRogue do not provide consumables in this way, but a permanent effect of collecting many treasures in a given land is access to magical orbs (which appear randomly and provide temporary power-ups of various kinds), and also access to more advanced lands. Even though negative curvature is probably the thing that students remember best about the hyperbolic plane, its effect on the gameplay, or living in the hyperbolic world, appears quite limited, compared to exponential space and its consequences. One land where curvature is featured prominently is the Burial Grounds, where treasures have to be excavated using a magical energy sword. The problem here is that the sword has to be aimed in the specific direction (where the wall is soft), and the PC is unable to rotate their sword, which just floats in the air next to the PC, maintaining its relative angle to the PC’s movement. In a Euclidean world, the sword would always face the same direction, but here, we can use the curvature to rotate the sword. Understanding that the sword will rotate when we go around a loop, and that the angle of its rotation is proportional to the area inside the loop, is essential for excavating treasures efficiently; the players will have to learn this to be successful in the Burial Grounds.

Procedural Generation in the Hyperbolic Plane

22 43 32 27 21 16 27 21 43 19 27 22 39 43 41 24 41 17 37 32 22 39 19 38 33 15 27 25 34 42 12 15 34 35 33 23 35 42 12 15 27 40 10 9 21 35 14 20 20 39 34 9 23 18 36 11 25 37 13 38 35 15 9 36 32 25 16 40 8 36 36 40 28 21 35 26 8 37 39 10 7 13 43 33 26 13 34 11 26 27 36 30 24 34 37 14 26 8 37 13 5 12 34 22 39 8 32 20 35 6 19 10 27 39 34 34 9 19 6 36 33 22 29 9 8 33 38 16 43 34 23 25 16 8 15 29 42 20 40 25 18 32 42 26 22 33 39 35 21 20 14 22 14 38 12 42 43 22 10 24 35 20 26 32 35 40 32 28 31 33 30 9 23 10 32 41 28 23 13 38 30 27 43 32 8 8 7 5 20 22 31 37 19 7 17 8 24 13 11 34 11 4 40 12 24 11 27 14 4 29 18 10 4 38 30 32 22 35 28 22 32 35 25 33 37 41 16 24 18 21 42 33 33 42 40 26 32 17 16 30 34 8 12 39 31 17 32 31 31 22 31 18 6 4 42 22 10 34 30 25 5 21 22 41 19 10 4 28 16 30 26 36 17 16 20 23 6 20 29 8 40 26 5 7 9 40 25 29 36 15 41 41 6 15 20 18 36 20 30 40 31 42 34 34 30 28 12 24 14 15 21 17 23 40 18 16 24 33 41 28 33 16 6 9 10 6 17 27 37 23 43 11 6 27 21 14 27 26 31 23 32 4 16 40 35 11 5 38 9 37 39 12 43 30 24 8 35 22 5 18 43 42 7 28 32 33 18 14 6 42 24 18 22 31 22 40 24 4 4 25 38 13 18 19 5 34 29 16 17 42 19 6 28 7 30 8 28 4 41 29 29 39 30 10 36 31 16 7 10 16 30 25 39 38 29 29 38 32 28 35 28 22 39 4 37 25 16 34 30 19 10 6 20 31 13 6 25 18 15 8 41 23 40 40 7 20 20 13 19 40 12 24 37 42 18 12 33 39 26 31 25 27 10 16 5 11 28 5 19 38 43 21 4 18 24 14 26 19 32 22 38 23 33 43 13 41 13 39 21 42 34 12 15 24 35 27 19 22 8 9 37 17 25 10 36 13 35 34 27 37 21 32 15 39 36 35 8 26 36 9 26 27 12 9 33 31 38 13 23 22 25 39 16 41 42 12 14 30 7 43 21 19 18 28 14 4 24 23 11 31 29 34 18 41 40 6 36 20 24 38 10 15 28 25 37 32 5 7 13 16 30 27 35 34 8 22 9 17 19 43 26 41 33 32 36 38 7 25 40 35 39 27 29 39 42 23 37 13 33 6 21 11 4 31 36 37 12 5 15 36 38 39 5 41 37 26 17 25 13 27 35 8 14 18 9 24 43 23 23 34 20 43 11 30 19 17 11 33 28 25 10 21 28 7 5 31 31 18 35 40 7 16 34 32 10 42 20 4 14 37 29 30 8 22 32 36 26 6 33 39 22 35 16 32 38 16 28 10 34 12 42 22 20 14 8 42 24 10 24 20 29 38 40 6 42 22 17 40 26 12 18 32 4 18 16 13 39 25 28 4 15 7 4 22 36 41 41 30 19 31 6 30 15 35 11 17 14 21 34 33 34 33 23 41 18 24 9 41 9 28 37 27 23 17 25 21 5 31 a) 39 29 b) c) d) 15 16 43 43 30 40 26 36 27 5 24 20 35 6 37 18 40 14 38 29 22 6 4 16 28 19 31 28 24 19 30 4 18 23 29 38 13 13 22 19 32 42 31 35 42 5 9 43 21 34 8 12 7 35 10 27 9 16 20 26 17 23 34 7 5 40 6 40 39 25 33 10 16 18 42 25 24 22 36 42 26 14 12 32 12 43 39 26 37 41 36 11 27 8 21 38 20 40 15 39 16 41 17 37 35 10 22 31 25 34 7 32 28 8 6 15 17 21 21 13 33 16 29 19 11 41 19 4 30 41 29 28 7 29 9 28 31 17 19 15 42 23 7 5 27 31 4 22 25 43 16 15 41 17 21 40 30 27 36 24 21 5 6 9 26 27 18 23 22 43 16 34 11 29 4 20 35 28 21 30 26 31 19 12 8 23 34 5 43 19 18 42 32 28 9 23 17 33 7 33 31 4 22 11 32 5 19 37 30 11 7 29 35 31 16 41 28 33 4 25 13 23 6 10 21 9 42 18 26 11 33 36 43 12 40 34 19 15 24 27 39 25 25

19 35 38 15 13 43 13 39 9 26 9 20 35 20 42 27 37 12 11 21 37 14 38 39 18 17 31 41 29 28 24 7 15 29 6 38 30 5 14 19 25 23 36 36 43 16 9 40 14 22 21 27 39 41 13 25 26 32 15 39 37 10 12 36 8 33 23 38 42 20 26 33 43 8 34 14 32 9 27 34 20 12 26 33 21 32 10 8 40 24 35 35 22 42 12 17 18 16 11 4 42 8 23 28 27 7 31 21 41 32 9 17 30 18 33 11 6 35 33 23 34 22 9 5 8 42 43 24 27 42 29 26 37 20 19 10 36 38 13 22 22 37 12 32 14 39 28 10 36 25 40 38 40 37 36

15 24 12 26 27 7 16 42 9 21 41 18 34 16 35 34 4 8 4 18 6 30 22 32 28 31 16 11 40 10 17 31 17 20 33 41 34 4 7 8 29 32 30 35 23 25 11 9 39 41 21 19 38 25 10 13 15 27 37 36 26 43 27 20 37 5 14 43 40 30 5 21 24 38 18 16 35 42 13 9 12 31 26 34 39 20 14 36 19 23 38 40 37 28 33 13 25 10 16 43 27 15 23 22 33 9 6 32 17 21 29 34 26 35 41 8 8 20 22 11 32 35 10 11 34

34 33 7 33

35 9 23 17 16 9 23 21 27 37 43 41 43 38 13 8 25 27 25 19 5 41 31 7 13 39 17 7 28 6 22 31 29 38 30 37 16 28 40 4 30 15 40 42 18 26 20 14 36 12 6 20 39 36 38 24 29 35 25 26 37 8 32

36 14 40 16 22 26 42 42 4 30 20 22 39 4 8 31 32 12 18 28 35 34 21 10 29

27 9 18 30 6 43 33 24 22 16 23 5 38 40 31 32 17 19 32 10 7 11 33 34 25 41 20 39

36 15 14 30 32 21 42 8 37 35 13 22 27 26 13 24 42 19 43 37 9 18 5 8 23 36 17 12 24 41 33 34 11 38 35 39 37 34 32 20 8 27 26 13 22 10 42 20 43 18 15 26 25 19 28 27 4 16 31 30 43 5 40 7 28 19 29 6 41 7 12 31 28 31 17 29 30 18 5 16 4 24 21 19 22 14 42 5 23 43 8 11 20 26 12 9 21 14 33 35 36 38 34 37 36 14 20 27 39 4 15 26 35 32 10 21 40 41 9 25 37 16 17 42 22 31 7 13 31 28 19 4 29 28 38 42 30 8 18

31 5 43 27 23 34 12 38 17 26 41 23 39

21 39 11 20 36 32 33 9 37 22 15 14 16 10 38 40 34 20 21 33 24 26 35 31 40 8 42 18 22 10 32 6 28 16 40 10 11 16 29 20 33 41 30 34 35 25 9 31 21 23 17 22 4 27 32 28 43 17 13 18 25 19 5 42 24 7 29 28 31 12 38 18 11 30 6 39 24 7 26 40 8 36 16 13 37 10 22 4 32 14 28 35 20 38 8 42 19 24 26 18 40 36 12 36 34 39 29 16 38 24 10 37 6 22 36 14 40 26 32 20 33 34 16 21 10 30 33 9 21 32 11 22 41 8 23 41 42 4 5 26 43 18 28 17 12 18 31 24 28 43 5 40 6 27 30 16 27 30 29 12 19 29 5 7 17 7 19 31 43 7 23 17 13 25 25 41 13 41 39 15 36 15 15 37 39 27 37 21 36 27 11 38 26 43 12 9 42 23 35 25 33 9 24 18 34 32 36 14 6 29 20 8 40 30 16 26 15 42 22 20 10 32 18 26 39 33 34 28 4 10 21 16 34 30 8 35 29 42 32 6 40 22 28 39 12 20 24 35 16 19 4 18 30 38 14 29 31 26 38 28 36 8 24 6 39 13 12 30 38 42 16 24 40 18 22 32 14 10 32 28 4 20 24 37 33 34 31 11 41 6 30 16 26 8 32 29 36 6 10 42 22 28 40 33 27 12 18 24 25 43 38 24 14 20 39 38 37 38 34 15 26 13 42 8 25 27 23 43 22 35 17 19 32 21 41 9 7 33 5 11 21 28 23 17 31 41 27 43 9 11 25 15 35 23 39 37 30 23 33 13 5 32 38 7 19 34 22 25 31 8 33 42 41 7 29 20 26 17 13 30 28 17 10 19 40 40 6 18 28 31 32 16 24 16 16 11 22 40 4 42 20 10 22 29 35 8 34 26 32 42 18 41 21 34 20 35 8 14 37 9 34 20 26 23 12 6 27 43 36 24 43 7 15 39 38 30 4 25 37 40 36 37 14 5 28 39 36 16 26 20 27 19 10 29 13 34 37 33 22 31 32 4 22 43 27 35 8 42 23 18 5 34 20 26 18 28 17 10 30 36 12 6 17 39 24 36 31 6 7 42 40 29 16 16 30 9 4 19 41 24 31 5 40 18 17 25 26 22 42 43 11 13 33 27 21 15 10 39 37 15 21 12 20 33 36 14 34 27 35 32 32 38 34 26 26 43 9 8 36 34 37 23 34 35 33 39 8 22 10 36 20 33 13 26 42 25 43 16 20 41 39 20 19 18 4 40 15 28 30 8 35 14 37 6 8 21 27 29 11 25 34 24 32 28 14 26 12 40 38 38 24 37 36 42 22 42 12 39 33 11 10 38 18 17 16 4 16 10 33 28 23 35 21 9 22 31 23 32 40 9 34 7 38 20 9 19 13 41 27 35 43 5 31 18 22 17 43 21 32 27 24 19 30 28 29 15 29 21 43 25 4 43 37 27 5 7 39 36 16 18 27 31 22 6 30 5 4 11 28 24 14 19 30 29 40 16 31 23 28 29 17 9 40 16 10 33 41 13 21 36 6 15 37 33 15 34 35 26 17 38 39 41 20 31 30 23 25 39 16 29 40 34 25 12 10 30 20 7 39 38 42 8 34 7 6 9 31 24 43 5 22 22 17 29 35 28 29 33 32 4 19 5 24 32 31 5 8 27 19 30 25 41 14 26 21 29 42 23 28 18 18 17 43 19 32 23 43 38 42 37 22

Figure 4 : (a) Zebra pattern, (b) Zebra, (c) Emerald Mine, (d) Dragon Chasms.

The infinite world of HyperRogue is procedurally generated on the fly. In this section we describe the methods used to place terrain features such as walls, trees, or chasms.

13 Kopczy´nski,Celi´nska and Ctrn´actˇ

Random patterns. The easiest method is to place terrain features randomly: each tile independently be- comes a wall with probability, say, 50%, thus creating a maze. This method yields much more satisfactory results than in Euclidean geometry (dead ends are rare) due to the tree-like nature of the hyperbolic plane. This method can be further differentiated by altering the probability, refining the results using a cellular automaton (the Living Cave), or by placing large obstacles with smaller probabilities. Periodic patterns. Figure 4a depicts a periodic encoding, which we call the Zebra pattern. The hyperbolic plane has been tiled in a regular way with a “triangle” consisting of 7 hexagons and 3 heptagons. have been colored into four colors, and for each colored triangle, ten codes have been given to its tiles, a different set of ten codes for each color. The coding is periodic, i.e., there is a subgroup HZ of the group G of isometries of our tiling such that the set of tiles with the same code are exactly its orbits. The code for each cell can be computed algorithmically. A single periodic encoding can be used to create many different periodic patterns. Even though the Zebra (Figure 4b) and the Windy Plains (Figure 1b) look completely different at the first glance, they are both invariant under HZ (i.e. isometries which map the encoding into itself also map these patterns into itself) and thus both can be obtained simply by assigning colors to codes from the encoding above. The random pattern mode can be used to try random invariant patterns. The Palace is based on another regular encoding derived from tiling a hyperbolic plane with circles of radius 2 (50·4 codes), and several other lands are based on the Emerald pattern consisting of 40 · 4 codes. The most basic ”unit” that can tile a plane would be a triangle connecting centers of three cells at a single vertex; such a triangle is formed by two 1/6s of a hexagon and one 1/7 of a heptagon, so the ratio of hexagons to heptagons is 7:3. Any pattern that tiles the whole plane must preserve the same ratio, and therefore the number of cells in the pattern must be a multiple of 10. Hyperbolic periodic patterns typically create beautiful tree-like structures. Effects of using a similar process in Euclidean geometry are much more trivial – we can only get a kind of checkered or striped pattern. Fractal landscapes. The diamond-square algorithm [7] can be used to generate realistic looking Euclidean landscapes; they could be viewed as a two-dimensional generalization of random walk, where we smoothly assign a random value to each point in the grid {0, n}2. Ideally, the fractal landscape should be a random function f :Ω × T → R, where Ω is the probabilistic space and T is the set of all tiles, such that for each −1 isometry i of the hyperbolic plane, fi given by fi(ω, t) = f(ω, i(t))−f(ω, i (t0)) has the same distribution 2 as f. As far as we know, the diamond-square algorithm cannot be easily extended to the whole plane Z ; however, we have found an efficient algorithm working on a hyperbolic tiling [19]. Fractal landscapes are used to generate chasms in the Dragon chasms, and environmental factors in the Galapagos´ (Figure 1c) are also generated based on a slightly modified version of this algorithm. Combinations. All these three methods can be combined – in Reptiles (see Figure 1d) a fractal landscape is used to generate the chasms, Zebra pattern is used as a base for the tesselation, and it is randomly decided which of the reptile-shaped floor tiles are actually sleeping reptiles.

Models of Hyperbolic Geometry

The game displays its world in the Poincare´ model by default. However, it is also possible to experiment with many other models. p The Minkowski hyperboloid is the set of points (x, y, z) such that z = 1 + x2 + y2; equipped with the Minkowski metric, it is the model of hyperbolic geometry used internally by HyperRogue [19]. Poincare,´ Beltrami-Klein and Gans models can all be obtained from the Minkowski hyperboloid model by viewing the Minkowski hyperboloid from (0, 0, −p), where p = 0 for Klein-Beltrami, p = 1 for Poincare,´ and p → ∞

14 HyperRogue: Playing with Hyperbolic Geometry a) b) c) d)

Figure 5 : (a) Band model, (b) conformal square [6], (c) the Hypersian Rug model, (d) conformal spiral.

for Gans. If we assume that the HyperRogue world is actually a three-dimensional hyperbolic space, the ground level is an equidistant surface c units under some plane, and we are viewing it from a point g units tanh g above the plane, this corresponds to p = tanh c . Thus, HyperRogue’s standard 3D display, using the Poincare´ model for the ground level and intermediate values of p for tops of walls and other levels, accurately shows how the situation would look from the bird’s eye, assuming g = c = 1. One counterintuitive property of hyperbolic geometry is that, even though it may seem that you change your movement direction a lot during the game, your path is actually very close to a straight line, except the parts where you were backtracking to a previous location (as happens in the Ivory Tower or during the Yendor Quest, for example). The band model [2] is a lesser-known conformal model, corresponding to the Mercator projection of a sphere. In this model, a fixed straight line L is mapped isometrically to a Euclidean straight line. By picking the line L to be the line passing through the starting and ending locations in the given game, the player can view their whole path as a single straight band. Another effect can be achieved with the Poincare´ half-plane model – if L is mapped to a vertical line in the half-plane model, the whole game can be seen by zooming the model in or out. The Hypersian Rug model can be used to play the game on an approximate isometric embedding of 3 hyperbolic plane in R , similar to what you get from hyperbolic crocheting [9]. This gives a good insight into the curved nature of HyperRogue’s world, and how the points close to the edge of the Poincare´ disk are actually much further away from each other than it appears. Such embedding is shown on Figure 5c, although a static image does not do it justice – it is much better to rotate the model in HyperRogue, and even better to touch a real crocheting or paper model.

Applications, or More than a Game

We believe that HyperRogue is one of the best ways to teach or learn about hyperbolic geometry. Even though it does not teach you any mathematical formulas, a very good intuitive grasp of hyperbolic geometry will be necessary to achieve success in the game, as we have argued in the previous sections. Other than the game itself, the built-in map and vector graphics editor could be used by mathematicians and artists, e.g., to find new periodic patterns or new tesselations; this is however currently limited only to tesselations and patterns derived from the order-3 heptagonal tiling in some way. It is worth to mention that HyperRogue has potential applications outside of education and art. Hyper- bolic geometry has gained interest in the data visualization and network science communities. Exponential amount of space allows to easily fit very big trees [12, 14, 11]. Hyperbolic geometry is also intrinsic in scale- free networks [15, 1]. The publicly available source code of HyperRogue contains a very rich set of powerful tools for representing, visualizing, navigating, and performing computations in the hyperbolic plane, both continuous and based on the order-3 heptagonal tiling. These tools are very useful not only for games, but also could be used as a basis of hyperbolic graph visualization software [3] or efficient implementations of algorithms based on hyperbolic geometry.

15 Kopczy´nski,Celi´nska and Ctrn´actˇ

Acknowledgments

HyperRogue could not achieve its current state if not for the help of its players, constantly reporting bugs and coming up with great ideas for new lands or other features. We would like to especially thank Shawn Parrotte for making the music, tricosahedron and wonderfullizardofoz on Steam for many great discussions and ideas, and Tristan Parker (Sprite Guard) for making a long series of videos about HyperRogue. The full list of significant contributors can be found in the in-game credits and on the HyperRogue website [18]. This work is partially supported by the National Science Centre, Poland, grant DEC-2016/21/N/HS4/02100.

References

[1] Thomas Blasius,¨ Tobias Friedrich, Anton Krohmer, and Soren¨ Laue. Efficient embedding of scale-free graphs in the hyperbolic plane. In European Symposium on Algorithms (ESA), pages 16:1–16:18, 2016. [2] Vladimir Bulatov. Conformal models of the hyperbolic geometry, 2010. Available online at http: //bulatov.org/math/1001/index.html (as of Jan 20, 2017). [3] Dorota Celinska´ and Eryk Kopczynski.´ Programming languages in GitHub: a visualization in hyper- bolic plane. In Proceedings of ICWSM 2017, Montreal, Canada, May 16-18, 2017. To appear. [4] H. S. M. Coxeter. The non-Euclidean symmetry of Escher’s picture Circle Limit III. Leonardo, 12:19– 25, 1979. [5] David L. Craddock. Dungeon Hacks: How NetHack, Angband, and Other Roguelikes Changed the Course of Video Games. Press Start Press, 1st edition, 2015. [6] Chamberlain Fong. The conformal hyperbolic square and its ilk. In Proceedings of Bridges 2016: Mathe- matics, Music, Art, Architecture, Education, Culture, pages 179–186. Publishing. [7] Alain Fournier, Don Fussell, and Loren Carpenter. Computer rendering of stochastic models. Commun. ACM, 25(6):371–384, June 1982. [8] Vi Hart, Andrea Hawksley, Elisabetta A. Matsumoto, and Henry Segerman. Non-euclidean virtual reality I: explorations of H3. In Proceedings of Bridges 2017: Mathematics, Music, Art, Architecture, Culture. Tessellations Publishing, 2017. [9] D. W. Henderson and Daina Tamina. Crocheting the hyperbolic plane. Mathematical Intelligencer, 23(2):17–28, 2001. [10] Douglas R. Hofstadter. Godel, Escher, Bach: An Eternal Golden Braid. Basic Books, Inc., 1979. [11] T. Hughes, Y. Hyun, and D. Liberles. Visualising very large phylogenetic trees in three dimensional hyperbolic space. BMC Bioinformatics, 5:48, Apr 2004. http://www.caida.org/tools/visualization/walrus/gallery1/. [12] John Lamping, Ramana Rao, and Peter Pirolli. A focus+context technique based on hyperbolic ge- ometry for visualizing large hierarchies. In Proceedings of the SIGCHI Conference on Human Factors in Computing Systems, CHI ’95, pages 401–408, New York, NY, USA, 1995. ACM Press/Addison-Wesley Publishing Co. [13] David Madore, 2013. http://www.madore.org/~david/math/hyperbolic-maze.html (Jan 27, 2017). [14] Tamara Munzner. Exploring large graphs in 3d hyperbolic space. IEEE Computer Graphics and Applica- tions, 18(4):18–23, 1998. [15] Fragkiskos Papadopoulos, Maksim Kitsak, M. Angeles Serrano, Marian Bogun˜a,´ and Dmitri Krioukov. Popularity versus Similarity in Growing Networks. Nature, 489:537–540, Sep 2012. [16] Radmila Sazdanovic. Fisheye view of tessellations. In Proceedings of Bridges 2012: Mathematics, Music, Art, Architecture, Culture, pages 361–364, Phoenix, Arizona, USA, 2012. Tessellations Publishing. [17] Jeff Weeks, 2009. http://www.geometrygames.org/HyperbolicGames/ (as of Jan 27, 2017). [18] HyperRogue website. http://www.roguetemple.com/z/hyper/ (as of Jan 27, 2017). [19] HyperRogue: programming. http://www.roguetemple.com/z/hyper/dev.php (as of Jan 27, 2017).

16