The Backstory
This July I was lucky enough to be a participant of the Wolfram Summer School. My project was to develop a function that would generate tessellations of space and assign a value to each cell- all of this so that I could visualize higher-dimensional CAs. I can proudly say that I was somewhat successful and the end result of my work can be found here. You may be wondering why on earth do I bring this up. Well, on the flight back home I was thinking about how I could further develop my code, and I realized that with only a few minor tweaks I could make something REALLY useful. Something that I'm sure many people who frequent these forums would be happy to use. Something to play tabletop RPGs.
The Big Idea
One of the things my TesselationPlot function could do is generate a hexagonal grid- a tabletop map waiting to happen! I got rid of a lot of unnecessary code, added some quality of life improvements, and came up with the following:
Options[TableTop]:={"CellSize"->100};
TableTop[terrain_,basis_List:{{1,0},{1/2,Sqrt[3]/2}},OptionsPattern[TableTop]]:=
Graphics[
Module[
{terrainColors=Association[
grass->Import["C:/GitHub/TableTop/Graphics/grass.png"],
ocean->Import["C:/GitHub/TableTop/Graphics/ocean.png"],
desert->Import["C:/GitHub/TableTop/Graphics/desert.png"],
mountains->Import["C:/GitHub/TableTop/Graphics/mountains.png"],
volcano->Import["C:/GitHub/TableTop/Graphics/volcano.png"],
swamp->Import["C:/GitHub/TableTop/Graphics/swamp.png"],
ice->Import["C:/GitHub/TableTop/Graphics/ice.png"],
lake->Import["C:/GitHub/TableTop/Graphics/lake.png"],
forest->Import["C:/GitHub/TableTop/Graphics/forest.png"]
(*"XXX"->Import["https://github.com/JHeimrath/TableTop/blob/master/Graphics/XXX.png","Images"][[2]]*)
],
d1=Dimensions[terrain][[1]],
d2=Dimensions[terrain][[2]],
b1=basis[[1]],
b2=basis[[2]],
hexagon={{0,0},basis[[1]],basis[[1]]+basis[[2]],2*basis[[2]],2*basis[[2]]-basis[[1]],basis[[2]]-basis[[1]]}
},
Table[
{EdgeForm[Black],
Texture[terrainColors[terrain[[i+1,j+1]]]],
Translate[
Polygon[
hexagon,
VertexTextureCoordinates->Automatic
],
i*(b1-2*b2)+If[EvenQ[j],(3*j/2)*b1,(3*j/2-1/2)*b1+b2]
]
},
{i,0,d1-1},{j,0,d2-1}]
],
ImageSize->Max[Dimensions[terrain]]*OptionValue["CellSize"]
];
The input is a matrix, where the entry in each cell is the type of land you want in that place on your map. So, for example, running:
smallWorld = {{grass, grass, mountains}, {grass, forest,
mountains}, {grass, forest, forest}};
TableTop[smallWorld]
would generate the the following map:
The Images
The terrain graphics were hand-painted for this project by my talented fiancée, Maria Czarnecka. Currently there are 9 terrain types: grass, ocean, desert, mountains, volcano, swamp, ice, lake, and forest. We plan to add at least a few more (city, village, road, river, ravine). All of them are available for you to download from my GitHub. You can also make as many new ones as you like yourself- feel free to share ideas and images in the comments! However, you can create some pretty nice maps using just what's available at the moment:
Some Final Thoughts
When I have some time this week I plan to add auto-padding to the code, so the input won't have to be a full rectangular array. It might also be a good idea to add a "space" terrain tile to create nice world boundaries. Let me know in the comments if you have any other suggestions or ideas!