Saturday, June 5, 2021

Hyperbolic text

I think about non-Euclidean space sometimes. Hyperbolic space in particular -- space with negative curvature. Parallel lines bend away from each other and are lost in infinity.
I've watched videos and played with math toys. Hypernom is pretty good. (Let it go full-screen, then move around with arrow keys, or touch the screen and use orientation on a mobile device. Or see other links at Henry Segerman's VR page.)
My favorite game to get a feel for hyperbolic space remains HyperRogue. This game has been around for a while (and I've never linked to it? Jeez). Give it a shot if you haven't. The author just added a VR option...
Now, I'm not talking about "wrapped" spaces like Manifold Garden. Those can hurt the head, but they're basically Euclidean -- parallel lines stay parallel. (A portal or two doesn't change the basic metric.) "Nested" spaces are more interesting; that's repeating infinitely at smaller and smaller scales, or larger if you go outwards. (Maquette, or that scene in The Room 4: Old Sins.) Again, nifty! But this post is about space which distorts with every step you take through it.
(HyperRogue is the best-known example, but other games are picking up on the idea. Hyperbolica looks like it could be good.)
When you wander around HyperRogue, you can tell there's more space than there should be. Whatever direction you go, you can get lost in a wilderness. You spot a small island in the distance, but as you approach, you realize its perimeter is a straight line -- there's just as much territory "inside" as "outside". And there are lots of these "islands"!
If this makes no sense, then you didn't give it a try when I told you too. Or just watch the video, okay? It's hard to describe! Which bothers me! I'm a text guy. Can we get this experience of hyperbolic space into a text game? Does that make sense?

Text adventures have always had one foot in the non-Euclidean. Wumpus takes place in a dodecahedral maze (maybe icosahedral, depending on how you look at it). That's a spherical geometry, which is non-Euclidean -- it has positive curvature. Or it would if the passages weren't all twisty.
Compass directions simplify the world, or maybe crucify it. Parser IF loves its rectilinear grid; then it loves to break that grid for your bemusement and delight. It would be quite easy to replicate the HyperRogue experience on that compass grid. Look at the {4,5} hyperbolic tiling -- every room is square, but there are five rooms around every corner-post. Inside any one room, you can't tell:
You are standing in a dusty drawing room, a niche in the House Unbounded. A ballroom is to the north, a decaying library to the east, the Silk Hall is to the south, and a denuded closet is west.
[Footnote 1: You can see why I think about these geometries, right? They practically ooze out of every weird house I've ever read, played, or implemented.]
A voice booooms out: "Seems normal enough? Let's go around the block!"
This is a rotting library. The shelves have all been chewed bare. A dusty drawing room is west; a disused pantry is north; to the east, a dull hall; and south is a cramped conservatory.
You have found a cramped conservatory, thick with dust and raddled scales. You see a library to the north, a plain hall east, an atelier to the south, and a scorched kitchen to the west.
This kitchen has been burnt to the baseboards. You can make out the Silk Hall to the north, a tiny conservatory to the east, an empty corridor to the south, and the Echo Chamber to the west.
You have found the Silk Hall. Moth-eaten swags of fabric hang all around. Peering between them, you see a flooded corridor north, a dusty drawing room to the east, a scorched kitchen south, and a sculpture gallery west.
You are standing in a dusty drawing room, a niche in the House Unbounded. A denuded closet is north, a ballroom is to the east, a decaying library to the south, and the Silk Hall is to the west.
It took five moves to get back where we started, and... what happened to the compass? Everything has rotated! This trick is sometimes called "parallel transport". We tried to keep the compass needle pointed in a consistent direction, but it just doesn't work out that way in non-Euclidean space. IF players hate that.
(A real compass doesn't point in a consistent direction, of course -- it points at a consistent point. We could try to replicate this in our game, but I think the point has been made. Besides, the House Unbounded has no edge and no center. It would be blasphemous to try to select one.)
The fact that "absolute" directions shift around may remind you of Hunter, in Darkness. That game has no compass directions at all. I implemented an "infinite" number of rooms there, too. But I wasn't thinking of hyperbolic geometry when I did it. It's more like a torus, which means it's roughly equivalent to a flat grid -- wrapped Euclidean after all.

The transcript above is disorienting. If I tricked it out with pseudo-infinite rooms of generated text, like Hunter, it would convey something of the hyperbolic experience.
But the parser experience is necessarily a bit fussy and focused on your immediate surroundings. Nothing in my prose expresses infinity. You're left to infer it. Maybe that's the way to go. Maybe other authors have done it better! Let's do a quick survey of the literature.
The most explicit use of hyperbolic geometry I know in fiction is Christopher Priest's The Inverted World. This was an early novel, much before he got hype for The Prestige. It concerns a mobile city crawling across a strange planet -- not a spherical planet, but a pseudosphere, a shape like a disc with two tapering spires.
The pseudosphere has a constant negative curvature. It's sort of the opposite of a sphere, which has constant positive curvature. Of course the pseudosphere has those unsatisfying seams at the equator and poles, but you can't make a model without breaking a few eggs.
The Inverted World is fascinated with its distortion of space-time -- but this is expressed entirely in terms of scale and time-flow. As the protagonist travels "south" from the city, the world stretches horizontally. Buildings and people are shorter and wider. Or (we discover) the protagonist becomes taller and thinner; perception is relative. The city moves to follow the Optimum Point where its metric locally matches the world around it.
This is heady stuff, but, as with much of the British New Wave, it's grounded more in metaphor than in mathematical precision. (The sun appears as another pseudosphere in the sky. I don't remember if the protagonist ever kicks a football, or if so, what shape that is.) And the story's theme is confinement, not expansiveness. The only travel is "north" and "south" along the City tracks, towards or away from the pole. There is no sense that our finite, spherical world has been inverted into infinite explorable area.
(Mind you, it's been decades since I read The Inverted World! Feel free to correct me.)

An earlier example of non-Euclidean space, perhaps the first I encountered, is Poul Anderson's Operation Chaos.
Steve Matuchek is a werewolf for the US Army. His wife Virginia is a combat witch. Together, they fight... lots of things, since the book is a fix-up of several short stories written from 1956 to 1969. But in "Operation Changeling", they have to go to Hell.
This presents a problem. Their usual repertoire of spells are designed for our universe. But the hell universe is different:
"Nickelsohn's hypothesis [...] That space-time in that cosmos is non-Euclidean, violently so compared to ours, and the geometry changes from place to place."
"You can't have a full description of the hell universe -- why, we don't even have that even for this cosmos -- and you absolutely can't predict what crazy ways the metric there varies from point to point."
No mortal could do the real-time computation needed to work magic reliably in the Low Realms. But, as Virginia notes, the greatest geometers are dead. So they summon up the spirits of János Bolyai and Nikolai Ivanovich Lobachevsky to help them.
(This isn't meant as a diss to 20th-century mathematicians, mind you. The idea is that, freed of matter and closer to God, great souls are able to continue their work in the higher realms.) (And before you ask: yes, the author sneaks in a Tom Lehrer joke. Speaking of the 20th century.)
Indeed, after their transit to Hell, the protagonists find they can't even fly their broomsticks straight:
Suddenly my love receded. She whirled from me like a blown leaf. I tried to follow, straight into the blast that lashed tears from my eyes. The more rudder I gave the broom, the faster our courses split apart.
[...] We'd hit a saddle point back yonder, Ginny passing to one side of it, I to the other. Our courses diverged because the curvatures of space did. My attempt to intercept her was worse than useless; in the region where I found myself, a line aimed her way quickly bent in a different direction. I blundered from geometry to geometry, through a tuck in space that bypassed enormous reaches, toward my doom.
No mortal could have avoided it. But Bolyai was mortal no longer...
Exactly the experience I've been describing! To be sure, this isn't a consistently hyperbolic space. The whole point is that Hell is chaotic. So this is just one incident in a, er, harrowing adventure. But it fits.

My favorite example, however, is from a less-remembered fantasy novel: Rats and Gargoyles by Mary Gentle.
It's a weird, chewy, glorious sprawl of a novel, set in a nameless and sprawling city known only as the "heart of the world". It's got aristocratic rat-lords, airships, Cardinals, Masonic geometers, a University of Crime, queer snarky catgirls, and thirty-six god-daemons who pursue their incomprehensible interests and don't seem to give a rat-lord's ass about anything that happens in the city they rule. It stinks of rot, roses, oil, sweat, and Hermetic magia. It should be a lot better known than it is.
But, my point: among the many strange facets of the heart of the world, we find five cardinal directions.
‘Lucas, just listen to this question: “The Five Points of the Compass lie upon a circle of 360 degrees, each one at a ninety-degree angle from the next... Draw a compass rose, and enter North, West, East, South and Aust at the appropriate positions.”’
Lucas shifted into a patch of morning sun, knowing he would be grateful later for shade. He gestured for Rafi to continue. The other dark-haired student propped the book up on its spine.
‘“Now draw the following quadrilateral triangle...”’
A city square has five sides. Each of the thirty-six Districts has five quarters. We hear about the north quarter of the Fourteenth, or the aust quarter of the Nineteeth, or so on. (The austerly side of each District is bounded by the Fane of the Thirty-Six. All the same Fane.)
"Ouest" is the opposite of "east" in French, but "Osten" is the opposite of "west" in German, which makes "Aust" (however spelled) the perfect name for an ambiguous compass point. It's always been there; you just never noticed it. Right?
In any case, this is quite precisely the description of the {5,4} hyperbolic tiling -- the dual of the map I described at the start of the post. It's what you get if you tile an infinite (non-)plane with pentagons.
The city is not boundless; it has wharfs and docks; people arrive by boat. (As well as by airship and railway.) But we never see beyond its boundaries. We never see its boundaries. Our view is always within, the urban horizon always battered in by walls and towers and the black heights of the Fane. Every District is always under construction by laborers allowed no rest. The city is as infinite as we allow it to be.
(Thirty-six Districts, but 181 quarters in total, not that this is ever remarked on. For that matter, nobody comments on "five ninety-degree angles" in a 360-degree circle. Each of the thirty-six Decans is a Lord of Ten Degrees, too. Mind you, they're foreign beings; they arrived at some point in the city's history. Are the god-daemons intrusions from a Euclidean cosmos, or are they hyperbolic beings imposing their curvature on our "normal" reality? It's beyond mortal understanding, unless we can conceive of their departure...)

One more, although I'm departing from the strict definition of hyperbolic geometry. This is the metric which repeats-at-scale forever. (I mentioned Maquette earlier.) Listen:
In a darkened library, deep in Special Collections, a young man cracks open a glass case. Inside is the Book of All Hours: a description of all reality. With bleeding hands he lifts the book open.
The first page is a map: a precise diagram of the room in which he stands. The second page shows the whole floor of the library. The third shows a section of campus. Each successive map has a larger scale: the city, the district, a part of the country. More of the Earth on every page, until he turns a page and sees the familiar Mercator projection of the whole world. Antarctica unrolled along the bottom edge; Greenland stretched huge in the Arctic Sea.
Then he turns the page again.
The coastline of a greater world lay before my eyes. It was a world where Antarctica was only the tip of a much larger southern continent. It was a world where Greenland was an island in a river's mouth, where Baffin Bay on one side and the Greenland Sea on the other stretched north, fused as an enormous estuary. Asia and the Americas were mere... promontories, headlands on a Hyperborean expanse, and the Arctic "River" that divided them had its source far north and off the edge of the map.
To east and west the story was the same, a whole new unfamiliar terrain; the western seaboard of America extended up well past Alaska, north and west, while Antarctica continued round and down; the eastern coast of China curved round to a gulf the size of the Baltic where the Bering Strait should be, another massive "river" running north from here. An entirely different landmass jutted in from the east, out at the far edge of -- I wasn't even sure if I should call it the Pacific now -- the Eastern Pacific, perhaps, the Western being, on this map, an entirely different body of water. I turned another page.
Again the scale moved out and, on this map, the world I knew could have taken up no more than a sixteenth of the area shown. The northeast coastline of that Greater Antarctica curved up to meet the strange land in the east, which itself carried on to meet the coast that curved around and down from China; pincered by its own Gibraltar Strait formed by the tip of South America, the bump of Antarctica, this Eastern Pacific was no more than a landlocked sea here, like a larger Mediterranean, dwarfed by the lands surrounding it on three sides. Hyperborea to the north, I thought, the Subantarctic to the south, and an Orient beyond the farthest Orient we've ever known.
Another page, and another, and the world I knew was only a minuscule part of an impossibly vast landscape.
This is the introduction to Hal Duncan's Vellum, the first of a duology about the Book of All Hours. It's not one of my favorites, truth told. It's difficult and dense, told in a set of braided threads which don't try to fit together. It's in that uncomfortable valley between fantasy and literary writing.
But that opening image, man, with the maps. That's gold. One day I'm going to commission a set of prints of those maps.


  1. I've always thought that the Chinese xianxia webnovels could be a good candidate for hyperbolic world. The authors of these books often conjure impossibly large worlds, and eventually move to gigantic conglomerates of worlds, but a simple hyperbolic plane would allow them to have all the space they want, while the distances and travel times would still be "ordinary".

    One interesting thing is that, in order to have a big hyperbolic world, it seems we must have to make some compromises on time. You can't have a fully hyperbolic spacetime where rest is indistinguishable from motion in a straight line, as per Galilean relativity -- or, better said, you *can*, but it won't be a good world to live in. An expansive force would try to tear everything apart, so very large structures (and if the world is to be truly perceived as hyperbolic, "very large" wouldn't be at all large) couldn't exist. The most interesting option seems to use H3xE for spacetime, which would allow for stable largescale structures in space at the cost of having no relativity -- you could always distinguish whether you are at rest or not simply by checking whether you feel an expansive force.

    But if we move to other possible non-Euclidean realms... may I interest you in Sol geometry? HyperRogue has it as an option, and it's fairly intuitive, yet utterly fascinating, reminding of The Inverted World, in a way:
    1. Start with a regular Euclidean plane (it won't *look* like one due to distortion, but that's its underlying geometry).
    2. When you go above this plane, distances in north-south direction contract, but distances in east-west direction expand. For example, let's say that the "doubling distance" is 1 km. You go 3 km up, 1 km north, 3 km back down, and you end up at a place 8 (2^3) km north from where you started. But if you go *west* instead of north, you will end up just 125 m (1 km / 2^3) from your original spot.
    As you go *below* the plane, though, the situation reverses. Tunnelling can shorten your travel east and west, while giving you more space to explore in north-south direction.
    A world shaped like this, with two dominant races, one flying and one underground, where each of them is master of two cardinal directions, I think that would be interesting.

    1. > I've always thought that the Chinese xianxia webnovels could be a good candidate for hyperbolic world.

      I am not familiar with these books! (This genre?)

      It's true that being *really* mathematically rigorous leads to strange forces like you describe. Also planets not orbiting the sun the way they should, and probably galaxy formation goes totally off track...

      The Sol metric sounds fun. I guess the point is that it's volume-preserving? (It's hard to Google for.) It reminds me of _Dragon's Egg_, where moving north/south was "easy" and east/west was "hard" due to extremely powerful magnetic fields.

  2. Forum folks have referred me to a few more games:

    Sierpiński's Tomb (Twine):

    Sokyokuban (hyperbolic Sokoban):

    1. (Sokyokuban really demonstrates the parallel-transport-rotation thing!)