|    .  ___  __   __   ___ .  __      __   __        __   __   __      
|    | |__  |__) |__) |__  ' /__`    /__` /  \  /\  |__) |__) /  \ \_/ 
|___ | |___ |  \ |  \ |___   .__/    .__/ \__/ /~~\ |    |__) \__/ / \ 
⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∽⋅∼⋅∽⋅∽⋅∽⋅∽⋅
home

Cairn Realmify log 4

previously (gemlink)
previously (http link)

Abstract

I want to automate the Cairn second edition map creation guide[0] to produce pure text maps, to integrate with my table top role playing game (TTRPG) preparation notes easily.

I've decided to write a python package that automates the procedure I've been exploring in previous logs[1]. In this post are my note from during the setup of the repository, the writing of the preliminary tests and other basic elements.

Log

I've left this project on the side for a while now, because I've been bummed out by something: the map I generate will always look badly aligned on most mobile devices when viewed through standard browsers with https. I'm sorry improbable reader if that's your case. Basically, non standard unicode and mobile http browsers are problematic, no matter which font trick I try in the CSS. I must also say that I am not the best at web tech, so perhaps it's just me. Regardless, I did not find a solution. The text and illustrations looks alright for Gemini in Lagrange and Buran at least, therefore I guess it will be readable for most people.

Learning a bit more about how font rendering worked and basically how much web development is broken kind of made be feel bad. But let's set this aside and finally dedicate some time to the program that has been haunting me for a while!

First things first, I need a place for the code to live in and be versioned. I'll use github[2] which is not a perfect choice, but at least I get M$ to pay for it. CC-BY-SA-4.0 license as Cairn is of course, given that I'll use and transform some of the tables from there as input for the program.

Now it's program drafting time. I'll do things simple. I'll have a dataclass, which will basically be a big char array with some rendering methods. I'll call it the Map.

And I need some way to store the POI, manipulate them without looping on the entire thing and probably have categories for landmarks, dungeons, lairs, settlements,etc... Technically, it will contain all the information needed to create the realm. I'll call that Territory, because the Map is not the Territory (haha).

Then I need something to coordinate all of that, handle the RNG, execute the tables and co. I guess I could do a "cartographer.py" with the appropriate functions.

Let's go test driven to make things concrete. What will be my first test and my way to test it?

First thing would be to:

Super duper dumb. But that means:

Well, that's the logical path. In Test Driven Development (TDD) fashion, let's be naughty. Let's write the test, to get a feel for the API. Then let's cheat in the implementation. Then write the next test, which is meant to circumvent this cheat.

I won't bore with more details. For now at least. Let's get coding. Learned that hyphens in python module names were not a good idea.

Ok, so for this time, we have the bare bones of the territory rendering system as well as the map coloring, but with a little twist: I don't use the four color theorem yet, I just note landmarks as uppercase letters and the territory belonging to it is in lowercase letter. I'll do the coloring in a latter step. And here we go, tests are green and:

from cairn_realmify.cartographer import realmify
from cairn_realmify.territory import generate_territory

if __name__ == "__main__":
    # Emulates the map we did by hand
    width = 20
    height = 11
    config = {
        "A": ("Silver_Face", (4 / height, 1 / width)),
        "B": ("Broken_Sundial", (3 / height, 13 / width)),
        "C": ("Great_Waterwheel", (8 / height, 13 / width)),
    }
    t = generate_territory(config)
    realm = realmify(t, width, height)
    print(realm)
[...]
make
uv run src/cairn_realmify/generate.py
aaaaaaabbbbbbbbbbbbb
aaaaaaabbbbbbbbbbbbb
aaaaaaabbbbbbbbbbbbb
aaaaaaabbbbbbBbbbbbb
aAaaaaaabbbbbbbbbbbb
aaaaaaaabbbbbbbbbbbb
aaaaaaaacccccccccccc
aaaaaaaccccccccccccc
aaaaaaaccccccCcccccc
aaaaaaaccccccccccccc
aaaaaacccccccccccccc

Humble start, but that's a start. We did not need the Map abstraction yet. Maybe we don't need it at all. Onward with improving the rendering, next time.

References

[0] The Setting Seed/Ream creation procedure
[1] the previous dev blog.
[2] the repository in which I publicly store the code
⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∽⋅∼⋅∽⋅∽⋅
home
posts
about