Text Mapper

Text Mapper is a web app to quickly generate a map based on a textual description of the map. The result is an SVG file and therefore scalable.

There’s a Mastodon bot posting maps: @textmapper!

The source is available.

2020-10-10 Adding rivers to the post-apocalyptic maps

Still unsure about the colour of rivers but there are now rivers in the post-apocalyptic maps. As this map algorithm doesn’t have an underlying height model (unlike the Alpine maps), the river flow is much more random:

  • every mountain is a source, every swamp is a sink (this is where all rivers end)
  • no rivers flow into mountains or into deserts
  • rivers merge if they run into each other
  • rivers never flow off the map

For such a simplistic algorithm, it doesn’t even look so bad!

Image 1


Add Comment

2020-08-28 New Text Mapper feature: map size adjustments

Eric Scheid sent me some feedback regarding Text Mapper and we ended up talking about a new feature to add or trim rows and columns to the map. Until now, adding rows at the top and columns at the left was a problem: you had to do some clever search and replace operations using your text editor if you wanted to do it.

Now, there are more options available to you: below the “Generate Map” button there’s now the following

Add (or remove if negative) rows or columns: top ___ left ___ right ___ bottom ___ add empty [ ]

And it seems to work! We’re still testing it, but if you notice something amiss, let me know.

Some strange things that I’m aware of:

  • if you add or remove an odd number of columns on the left, you’re going to change how the columns stack – not too much of a problem, I think, but probably surprising!
  • if you remove rows or columns containing “lines” (rivers, trails, roads), then those stay if they’re not entirely outside the map – meaning that they can now potentially extend beyond the edges of the map if you trimmed some of the regions these passed through and you’ll have to trim them yourself

Feel free to share links to your maps in the comments. I always love to see them.

If you don’t know what Text Mapper can be used for, check out the @textmapper bot. It posts a new map every week.

Add Comment

2020-05-01 Island map generator and Text Mapper

OK, I’ve added code to my J program to print the map in Text Mapper format to stdout so that I can start taking a look at it. I added printing of a Text Mapper compatible output to my script... And I know how to generate the SVG from the command line... OK, let’s try!

The file I’m working on in JQt can be run from a terminal emulator.

jconsole '~user/temp/2.ijs'

To URL-encode the output, more or less:

jconsole '~user/temp/2.ijs'
| perl -p -e 's/ +$//ge;' -e 's/([^a-zA-Z0-9_.!~()-])/sprintf("%%%02X",ord($1))/ge'

So let’s store that in a variable:

map=$( \
  jconsole '~user/temp/2.ijs' \
  | perl -p -e 's/ +$//ge;' \
            -e 's/([^a-zA-Z0-9_.!~()-])/sprintf("%%%02X",ord($1))/ge')

This is what the viewer shows us:

Image 1

And now to call Text Mapper from the command line:

perl src/hex-mapping/text-mapper.pl get \
  --header 'Content-Type:application/x-www-form-urlencoded' \
  --method POST --content "map=$map&type=square" /render \
  2>/dev/null \
  > test.svg

Convert the SVG to PNG:

inkscape --without-gui --file=test.svg --export-png=test.png

There you go:

Image 2

Looks like the J preview does not use quite the same colours. Perhaps because of auto-scaling?

Also, hex maps. Different, of course, but still islands. Strangely familiar, but also … wrong … I think? In some weird way? If you don’t know the map using squares, it’s OK. But now that you do, it’s hard to think of this as some sort of torn land. Was there an earth quake that split of this little island on the right?

Image 3

I think what I can also say right now is that I need to work on the colour palette.

Here’s an image of the Galapagos, thanks to the visible earth project at NASA).


Here’s an image of Hawaii, thanks to the visible earth project at NASA).


I’m not sure I want to use these colours but clearly my impression on the ground on Seymore, where I felt everything was black or brown or rusty red does not match these green images from space.

I need to think about this some more.

Source Code

I really need to put it into a repository. 🙂

mx =: 30
my =: 20

NB. a table of complex numbers
c =: (i. my) j./ i. mx

NB. starting position of the hotspot
hr =: 5
hy =: >. hr % 2
hx =: <. 0.5 + (my % 3) + ? <. 0.5 + my % 3
hc =: hx j. hy

NB. a function to compute altitude changes based on where the hotspot is
change =: 3 : 0
  h =. hr > {. & *. c - y     NB. hotspot = 1
  u =. 0.8 < ? (my, mx) $ 0  NB. regions atop the hotspot might move up
  d =. 0.9 < ? (my, mx) $ 0  NB. regions off the hotspot might move down
  (u * h) - d * -. h

NB. a biased list of steps to take
d =: _1j1 1j1 0j1 0j1 0j1

NB. a table of altitudes
a =: (my, mx) $ 0

NB. compute the meandering path of the hotspot across the map
NB. compute the change for each step and add it to the altitude
NB. no negative values
3 : 0''
for. i. mx - 2  * hr do.
  hc =: hc+(?#d){d
  a =: 0 & >. a + change hc

NB. print map for text-mapper
colors =: ('ocean', 'water', 'sand', 'dark-soil', 'soil', 'green', 'dark-green',: 'grey')
3 : 0''
for_i. i. my do.
  for_j. i. mx do.
    color =. (j { i { a) { colors
    smoutput (>'r<0>2.d' 8!:0 j) , (>'r<0>2.d' 8!:0 i) , ' ', color
smoutput 'include https://campaignwiki.org/contrib/gnomeyland.txt'

NB. display map for visuals
decimal =:16"_#.'0123456789abcdef'"_ i.]

rgb =: 3 : 0
  n =. decimal }. y     NB. strip leading #
  (<.n % 65536), ((<.n % 256) |~ 256), (n |~ 256)
ocean  =: rgb '#1c86ee' NB. 0
water  =: rgb '#6ebae7' NB. 1
sand   =: rgb '#e3bea3' NB. 2
dry    =: rgb '#c97457' NB. 3
nice   =: rgb '#b0b446' NB. 4
green  =: rgb '#77904c' NB. 5
humid  =: rgb '#2d501a' NB. 6
rocky  =: rgb '#dcddbe' NB. 7
colors =: (ocean, water, sand, dry, nice, green, humid,: rocky)

load 'viewmat'
colors viewmat a
exit 0


Add Comment

2019-10-21 Metainformation for an image

Recently, asked me whether it was possible to get from a dungeon map in Hex Describe to an editable map in Gridmapper. There wasn’t, but I liked the idea and so I started thinking about it. It should be doable in theory even though I am generating the dungeon maps using Text Mapper and all they have in common with Gridmapper maps is that they look similar.

So yesterday I started writing the code that transforms the Text Mapper data into a Gridmapper link. Once I could see it in the log output, I was happy. But what next?

I decided to add a HTTP header with that link, hoping that Hex Describe would be able to extract it, and I told J. Alan Henning that I had these instructions for him:

  1. generate map using Hex Describe
  2. use View Image to look at a dungeon map
  3. use Inspect Element to get to the development tools
  4. switch to the Network tab
  5. click the Reload button
  6. click on the new request line to see details
  7. in the Headers tab, there’s a section called Response headers
  8. in that list there’s a header called X-Link
  9. the value of that header is the Gridmapper link

It was late, I was tired, and I needed to sleep, obviously. 🙂

As the rendered image uses the SVG format, I alread had the input used in a comment at the end. Therefore, the link I just mentioned can be found right there. The X-Link code I had written was unnecessary and I removed it.

The instructions were in fact much simpler!

  1. generate map using Hex Describe
  2. use View Image to look at a dungeon map
  3. use View Page Source to look at the SVG code
  4. scroll to the end until you see the Gridmapper link

But then I realized that I could simply add the information the SVG output as a link! Within Hex Describe it’s hard to spot the link. It’s tiny:

Hex Describe output with link

If you use View Image, however, it gets bigger:

View Image

(If you click the image above, you might get taken to a different image because the seed I used is only guaranteed to work for as long as the code doesn’t change. My guess is that this won’t be stable for long!)

If you click the link in the top left corner, you’re taken to Gridmapper:

Image 3

I also need a way to add nice arrows to images using Gimp. Surely there is a better way!


Comments on 2019-10-21 Metainformation for an image

I was playing with Gridmapper the other day and was wondering about Switch Background and Toggle Floor commands. I couldn’t figure them out. Any hints?

– Ruprecht 2019-10-30 19:02 UTC

The Switch Background command (capital Z) toggles between various background options:

  • grey background (the default)
  • black background
  • white background
  • white background with grid
  • blue

The Toggle Floor command (hold Alt and use the arrow keys to move around) simply toggles the floor on or off. In other words, it’s the equivalent of pressing f and and arrow key repeatedly – it’s simply faster.

– Alex Schroeder 2019-10-30 22:46 UTC

Add Comment

2019-10-09 Ten random dungeons generated

With the random tables of J. Alan Henning and ktrey parker and Text Mapper with the Gridmapper algorithm (which knows how to create five room and seven room dungeons), and Face Generator, we have a funny little thing, now:

There are probably a gazillion things we could still add, but it’s already interesting. 🙂

Talk to us on Diaspora!

If you’re reading this in the future, check my profile for the latest thread called “Hex Describe, Face Generator, Text Mapper, and more” (see this old post for context).


Comments on 2019-10-09 Ten random dungeons generated

I like it! Looks very usable, especially with the yellow highlighting.

Jensan 2019-10-09 12:09 UTC

Thanks! Now that I look at the maps a bit closer I see that many of them are repeats. I need to think about the random number seed a bit more. I fear it’s simply taking the current time and passing it off to the mapp generator, which thus gets the same seed for every map. That’s not cool.

– Alex Schroeder 2019-10-09 13:50 UTC

This is killer Alex

froth 2019-10-15 18:54 UTC

Heh, all thanks to ktrey parker and J. Alan Henning who pushed me towards it because I was quite skeptical, and they wrote the random tables for it. Beautiful!

– Alex Schroeder 2019-10-15 20:36 UTC

This is another amazing resource for randomness – thank you. I use Hex Describe quite a bit to generate random entries for my D&D wilderness treks (using tables I have created from mash ups of existing material/adventures and my own mind) and am wondering how I would add in a chance of generating one of these dungeons? I’ve done a quick search of your wiki, the source file and can’t see anything specific – is it possible?

– VickyR 2020-01-07 20:27 UTC

It depends on what you want. If you’re already writing your own random tables, then it’s easy to simply add [dungeon] and it’ll add one to your entry.

  • the dungeon table (the tables below that show how the images with the maps are included)
  • the forest-hill table (the last entry uses the [dungeon] table)

– Alex Schroeder 2020-01-07 20:59 UTC

Thanks for this. Looking through the tables it’s an amazing piece of work by you and ktrey parker and J. Alan Henning. Much more complex that I usually create, but full of interesting ways of using code you’ve written. Thanks again.

– VickyR 2020-01-09 06:44 UTC

Thanks. 🙂

– Alex Schroeder 2020-01-09 06:48 UTC

Add Comment

2019-09-20 Ocean Hexes

I’m not interested in ocean hexes, I think. But Hex Describe would treat all water hexes the same: as a lake. And so you’d get the most useless hex descriptions for the open sea. The real problem was of course that Text Mapper would just generate water hexes and not differentiate between big lakes, coastal areas and the ocean. Well, one of these issues has been resolved, now: ocean hexes. And since no such table exists for Hex Describe (at least not in the “Schroeder” tables), this means that no description should get generated. At least I hope that’s what it means. 🙂

And visually:

Map with open ocean

I still have a little bit of a problem picking just the right hue of darker blue. If you have opinions, please comment with a color code. The existing Gnomeyland colours, if I remember correctly, are based on old Russian maps.

To generate maps with more water, set the bottom parameter to some number single digit number, e.g. 6.


Comments on 2019-09-20 Ocean Hexes

I actually really like the colors, and the more vibrant blues are pretty in contrast to the more neutral greens. The yellow on the hills has the same kind of enjoyable contrast.

I’d need to print it on a black-and-white printer to be sure, but it looks like you would be able to tell the hexes apart by tone even if you had trouble distinguishing the shade.

Anne 2019-09-21 04:20 UTC

Thanks for the feedback. 🙂

– Alex Schroeder 2019-09-21 15:24 UTC

Add Comment

2019-08-23 Gridmapper inside Text Mapper

Gridmapper is an interactive web application. You can use it to draw multi-level dungeon maps. The drawback is that you cannot use it to generate images in order to use them elsewhere.

A while ago I wrote a Megadungeon Generator which generates a random dungeon and allows you to open it in Gridmapper. That’s pretty cool, but I was still unhappy. The preview images I generated as part of it seemed to be on the right track: these were images, but much to small, and they didn’t use the Gridmapper tiles.

Recently, I added the ability to generate square maps within Text Mapper. Now all I was missing was the Gridmapper tiles and some encouragement.

The last few days, as I was talking with Brian Green, J. Alan Henning, and ktrey parker on Diaspora the topic turned to mapping again. ktrey parker suggested using the Face Generator or something similar for dungeon maps. Something smaller, combining geomorphs, something like the five room dungeon, not something big like Dave’s Mapper. Robin Green linked to The Nine Forms of the Five Room Dungeon | Gnome Stew, and started drawing sketches of the kinds of geomorphs we could use, how they’d fit together, and so on.

And suddenly... that was the kind of social enthusiasm I needed and I started writing code...

This is a new mapping algorithm for Text Mapper based on all of the above. It doesn’t do the special rooms Brian had sketched, yet; and it doesn’t always place the initial stairs correctly; and there are no “extras” such as pillars, chests, pits, and so on. But all of this can still be added.

As always with these algorithms, you can use them to generate a new text description for you to edit, or you can just keep reloading this link.


Add Comment

2019-08-06 Hex Describe, Face Generator, Text Mapper, and more

If you’re wondering where the discussion regarding Hex Describe, Face Generator, and Text Mapper actually happens, the answer might surprise you: it happens on the Diaspora network!

There, I create new threads every now and then for people who want to talk to me about these applications. They allow people to generate a mini-setting including a map, a key, and NPCs, with but one click, powered by the greatest collection of random tables I know. 😅

I keep creating these threads whenever the previous thread reaches about 100 comments because it starts being unwieldy.

Here’s a list if you want to explore:

You get the idea. 🙂


Add Comment

2019-07-08 Square Traveller

OK, square maps instead of hex maps, for Traveller, right?

This is the sort of map the Traveller Subsector Generator creates. It’s pretty good, I like it.

Original map

If you use the same data and rewrite it somewhat, you can use Text Mapper to generate the same map, but now with rounded communication and trade lines:

Hex map

And since Text Mapper recently got the ability of creating square maps instead of hex maps, all I had to do was fiddle a bit with the data, move the black frame around, move the labels into the correct positions, and we’re nearly there:

Square map

There are still so many things wrong: the symbols overlap the coordinates and the labels; the lines intersect the labels, so basically everything is terrible and unreadable at a second glance. But it will have to do for the moment. Perhaps if square Traveller maps make a breakthrough one day! 🤪

The map generated uses a separate map, Which in turn uses a separate library. If you want to regenerate, you need to put the following in the text area:

include https://campaignwiki.org/contrib/traveller-square-example.txt


Or take a look at the map and modify to taste.


Add Comment

2019-06-17 Text Mapper with Squares

I’ve been trying to see whether I could get Text Mapper to create a square grid instead of a hex grid. Preliminary results aren’t too bad!

This is the traditional example hex map:

Hex Map

And this is the result when you feed the same text into a square grid mapper:

Square Map

It already looks like magic!

The goal I have in mind is to generate square-based Alpine maps.

And maybe I could change my Megadungeon Generator wanna-be to use it as the output instead of Gridmapper. Once I have that, I can generate images using web services without relying on a browser rendering the Gridmapper Javascript code.

OK. Alpine maps. I mean, the algorithm often uses loops over the six neighbouring directions in order to create the textual description of the map, so that surely needs fixing.

Then again, once the textual description has been generated, the code no longer cares about hexes and squares, as seen above. It just looks – different.

Let’s give it a try.

Random Alpine hex map:

Alpine Hex Map

Same data, but using squares:

Alpine Square Map


It is in fact recognisable! Like some weird projection from a strange fantasy cartographer. Uncanny.

I’m not even sure I want to change anything at this point! A quick scan at this point just shows that cliffs don’t look too good (because the icon library still uses six different cliff icons).

Well, a bit more studying also reveals that some spatial relationships are disrupted, like the swamp for 0102–0201. Or the river that flows from 1204–1105 now makes a detour through the mountains of 1104.


Comments on 2019-06-17 Text Mapper with Squares

Those pesky fantasy rivers 😝

Ynas Midgard 2019-06-17 13:02 UTC

I love some of the U-turns these rivers are making. 🙄

– Alex Schroeder 2019-06-17 18:18 UTC

I’d love to see Text Mapper with squares evolve into a tool you could map a dungeon from a text source. This would be awesome. The hex based map is one of the best campaign building tools, I’ve ever come across, particularly when combined with Hex Describe to populate the Hexes. It would be great to expand on this by having a tool to generate dungeon maps based on a square grid.

– Stephen Peto 2019-06-17 18:21 UTC

Did you give Megadungeon a try? Reload it a few times until you get close to 100 steps and click on the last one. You’re sent to Gridmapper. Here’s an example I got after a bunch of reloads, three levels deep.

Gridmapper would make a pretty good tool for interactively making a dungeon, and Megadungeon could be improved as well. But unfortunately we cannot embed Gridmapper into Hex Describe. If we want to generate dungeon maps for Hex Describe, we’ll have to enable this via Text Mapper.

So in short: yes! This idea excites me!

Perhaps one day we’ll need a way to import Text Mapper maps into Gridmapper such that we can edit it there, and then export it back from Gridmapper to Text Mapper. That would be very cool.

– Alex Schroeder 2019-06-17 18:30 UTC

At last, the Alpine algorithm can deal with a square grid and hopefully all the river anomalies have been resolved, now!

Rivers work, now

Next: extracting the SVG for the Gridmapper icons and making them available for Text Mapper...

– Alex Schroeder 2019-06-17 20:17 UTC

Add Comment



Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Just say HELLO