Tools for computational world building


License
GPL-3.0
Install
pip install worldbuild==0.0.9

Documentation

World Build

Tools for computational world building (work in progress)

Overview

Worldbuild contains tools to build worlds and store the metadata around that, including objects, history, animals, vegetation.

You provide a map of your world and annotate it via a YAML file to define towns with locations - the wiki tool extracts subset of the image to for each town.

You can add additional information to build a rich history around your world.

Quick Start

Copy your map file (JPG) or scan a hand drawn map.

./doc/map_sample.jpg

Create a YAML file with the following sections

wiki: Yes
world_name: Alrona
contents:
    - races
    - settlements
maps: [alrona-pen-coloured.jpg]

You need to have a root section for each element in contents, and there needs to be a name and desc element at the minimum.

settlements:
  - name: Draeton
    continent: Sharnia
    coords_x_y: [66,58]
    desc: >
        This is the largest city on the East side of Sharnia. 3,000 men live in this strongly
        defended city
  - name: Ambyle
    continent: Sharnia
    coords_x_y: [64,58]
    desc: >
        Farming town East of Draeton, known for their famous weekend markets selling exotic produce grown in the warm regions north of the Eastern Desert

Then modify the params and run the wiki.py program to generate the HTML version of your world.

The main page looks like

./doc/web_index.jpg

The settlements page shows the description from the yaml file, and also a section of the map based on the coords_x_y parameter

./doc/web_settlements.jpg

You can extend the wiki with as many sections as you like and each entry can include a file section to import a text (or html) file to be included in that page.

Random Grid Generation

Create a random grid as follows

pip install worldbuild
build_random_grid.py

./doc/Screenshot_test_world_txt.png

You can convert this grid to a Tiled TMX file for manual editing

convert_grid_to_tiled_map.py

./doc/Tiled_example_test_world.png

Dungeon Map Generator

Create a rogue like dungeon grid by running dungeon_generator.py to produce a random map

/--------------------------------------------------------------------------------------------------------------------------------\
|                                                                                                                                |
|                ╔═══════╗                             ╔════════╗╔═════════════════╗ ╔═══════╗╔═══════╗                          |
|  ╔════╗══════╗ ║.......║                             ║........║║.................║ ║.......║║.......║ ╔══════╗                 |
|....║......║ ║.......║                             ║........║║.................║ ║.......║║.......║ ║......|
|...........║ ║.......║               ╔══════╗      ║........╚╝.................╚═╝.......║║.......#═#......║                 |
|  ║..!.+......║ ║....r..║               ║......║      ║..............p...L..............L...║║.......-.+......|
|...........║ ║.......║               ║......║  ╔═══╝....L..................c.............║╝.......#═#...p..║                 |
|...........║ ║.......║               ║......##═╝.........................................##.......#═#......╚═════╗           |
|  ╚═╗...L....╔╝ ╚═══════╝               ║......-+.......................-.+.........F.......-+.......-.+............|
|........║                        ╔═╝...F..##...............p..╔════#═#.............╔═══##.......#═#══╗.........║           |
|........║                        ║........║║....................║     ════╗.................L..╔═════╝.........|
|    ║..═.p...║                        ║........║║......r.............║          ╗...................................║           |
|    ╚╗...r..╔╝           ╔════════╗   ║........║║....................║          ║...............................p...|
|........║           ║........║   ║........║║................c...║          ║..........r........................|
|    ╚╗...═..╔╝═╗         ║........║  ╔╝....p...║╝....................║          ║......................F............|
|.........║         ║........╚══╝.........║╚═════╗..............║          ║.................p.................║           |
|     ╚╗........╚═╗═╗     ║.....................║      ║....p.........║          ║...................................║           |
|..........║.║ ╔═#═╝....................╔╝═══╗  ║..............║          ║...................................║           |
|.....F..╔═╝═╝ ║.+.................c.........║  ║........╔═════╝          ╚═══════╗..................p........║           |
|..........║.║ ║.#..........r................╚══╝........╚═════╗                  ║...c...................p...║           |
|..........║.╚═║.║................................╔═══╗........╚═════╗            ║...........................|
|.........L....║....c.............................║   ║..............║            ║............c..............║           |
|..............║..╔══╗..........╔═══╗...p.........║   ║..............║            ╚═══════╗...................║           |
|..........═.╔═╝.═..........╔═══════#.............║   ║..............#════════════════════#..............╔════╝═══╗       |
|      ╚════╗.........c..-.................+.............║   ║....r.....r...-....................+..............║║.......║       |
|...........F..#═════════════════#.............║   ║..............#══════╗........╔════#........p.....║║.......║       |
|...........#..║                  ════╗....r...#═══#..............╚═#═══#╝...........#═╝...........╔══╝║.......║       |
|...........+..║                      ║........-...+........+.......-...+............-......+......║   ║....r..║       |
|...c.......#══╝                      ╚╗......╔#═══#════════#..........╔#...............╔═══#══════╝   ║.......╚══╗    |
|...........║    ╔═══╗════╗            ║......╚═══╗    ║...............║║...............║              ║..........║    |
|...........║    ║.......╚═╗═╗        ║..........║    ║...............║║....p...F......║              ║..........║    |
|         ╚═══════════╝════╝.........║.║        ║..........║    ║...........r...║║...............║              ╚═══╗......|
|     ╔═══════#══════#.........║......║.╚═══════#╝..........║    ║...............║╝...............#════════════════#═╝......╚══╗ |
|.......-......+.............-...........+.......F...║════╝...............║╚═══╗...........-................+...........║ |
|.......#══════#................═.╔══════╗............║....................║    ║...........#════════════════#...........║ |
|.......║     ╔╝...L...........L║.║      ║....................F..........╔╝    ║.......╔═══                 ║...........║ |
|.......║═════╝.................║.║      ║........╔═══╝................c..║     ║.......║                    ║...........║ |
|....p..#.......................#.╚════╗═╝....F...#═══#....p..............#════#........║                    ║...........║ |
|.......+................p..-...+................-...+...................-....+.....F..║                    ║........?..║ |
|.......#....................╔══#......║..........#═══#..................╔#════#........║                    ║...........║ |
|.......║.........r..........║  ║...............╔     ════╗.............║..............║                    ║...........║ |
|     ╚═══════╝....r........c......║  ║..c..╔╝╗.....╔══          ║...r...╔═════╝..............║                    ║...........║ |
|....................║  ╚══╝...c...F..║            ║.......║     ║............╔═╝                    ║...........║ |
|.......╔═╗......L...║  ║............║            ║.......║     ║............#══════════════════════#...........║ |
|             ╚═══════  ║..........║  ║............║            ╚═══════╝     ║....L.......-......................+...........║ |
|                       ╚═╗........║  ╚══════╝══════╝                          ║........╔═══#══════════════════════#...........║ |
|                          ════════╝                                           ╚════════                            ═══════════╝ |
|                                                                                                                                |
\--------------------------------------------------------------------------------------------------------------------------------/

It also uses the pathfinding package to make a path through the map

Finding path..... Seed was: 5529128865878819600
pathfind.py start, end =  [5, 5] [123, 38]
operations: 3459 path length: 168
/--------------------------------------------------------------------------------------------------------------------------------\
|                                                                                                                                |
|                ╔═══════╗                             ╔════════╗╔═════════════════╗ ╔═══════╗╔═══════╗                          |
|  ╔════╗══════╗ ║.......║                             ║........║║.................║ ║.......║║.......║ ╔══════╗                 |
|....║......║ ║.......║                             ║........║║.................║ ║.......║║.......║ ║......|
|...........║ ║.......║               ╔══════╗      ║........╚╝.................╚═╝.......║║.......#═#......║                 |
|  ║..xx+......║ ║....r..║               ║......║      ║..............p...L..............L...║║.......-.+......|
|...xx......║ ║.......║               ║......║  ╔═══╝....L..................c.............║╝.......#═#...p..║                 |
|....x......║ ║.......║               ║......##═╝.........................................##.......#═#......╚═════╗           |
|  ╚═╗..xL....╔╝ ╚═══════╝               ║......-+.......................-.+.........F.......-+.......-.+............|
|    ║..xx....║                        ╔═╝...F..##...............p..╔════#═#.............╔═══##.......#═#══╗.........║           |
|...x....║                        ║........║║....................║     ════╗.................L..╔═════╝.........|
|    ║..═xp...║                        ║........║║......r.............║          ╗...................................║           |
|    ╚╗..xr..╔╝           ╔════════╗   ║........║║....................║          ║...............................p...|
|...x....║           ║........║   ║........║║................c...║          ║..........r........................|
|    ╚╗..x═..╔╝═╗         ║........║  ╔╝....p...║╝....................║          ║......................F............|
|     ║..x......║         ║........╚══╝.........║╚═════╗..............║          ║.................p.................║           |
|     ╚╗.x......╚═╗═╗     ║.....................║      ║....p.........║          ║...................................║           |
|      ║.x........║.║ ╔═#═╝....................╔╝═══╗  ║..............║          ║...................................║           |
|      ║.x...F..╔═╝═╝ ║.+.................c.........║  ║........╔═════╝          ╚═══════╗..................p........║           |
|      ║.xx.......║.║ ║.#..........r................╚══╝xxxxxxxx╚═════╗                  ║...c...................p...║           |
|      ║..xxxx....║.╚═║.║...............................x╔═══╗.xxxxxxx╚═════╗            ║...........................|
|.....x...L....║....c..........xxxxxxxxxxxxxxxxxxx║   ║.......xxxx...║            ║............c..............║           |
|.....xxxx.....║..╔══╗.....xxxxx╔═══╗...p.........║   ║..........x...║            ╚═══════╗...................║           |
|........x.═.╔═╝.═.........x╔═══════#.............║   ║..........xxxx#════════════════════#..............╔════╝═══╗       |
|      ╚════╗...xx....c.xxxxxxxxxxx........+.............║   ║....r.....r..xxxxxxxxxx............+..............║║.......║       |
|......x....F.x#═════════════════#.............║   ║..............#══════╗x.......╔════#........p.....║║.......║       |
|......x....#.x║                  ════╗....r...#═══#..............╚═#═══#╝x..........#═╝...........╔══╝║.......║       |
|......xxxxxxxx║                      ║........-...+........+.......-...+.x..........-......+......║   ║....r..║       |
|...c.......#══╝                      ╚╗......╔#═══#════════#..........╔#.xxxxxxxxxx....╔═══#══════╝   ║.......╚══╗    |
|...........║    ╔═══╗════╗            ║......╚═══╗    ║...............║║..........x....║              ║..........║    |
|...........║    ║.......╚═╗═╗        ║..........║    ║...............║║....p...F.xx...║              ║..........║    |
|         ╚═══════════╝════╝.........║.║        ║..........║    ║...........r...║║...........xxx.║              ╚═══╗......|
|     ╔═══════#══════#.........║......║.╚═══════#╝..........║    ║...............║╝.............xx#════════════════#═╝......╚══╗ |
|.......-......+.............-...........+.......F...║════╝...............║╚═══╗..........xxxxxxxxxxxxxxxxxxxx..........║ |
|.......#══════#................═.╔══════╗............║....................║    ║...........#════════════════#x..........║ |
|.......║     ╔╝...L...........L║.║      ║....................F..........╔╝    ║.......╔═══                 ║x..........║ |
|.......║═════╝.................║.║      ║........╔═══╝................c..║     ║.......║                    ║x..........║ |
|....p..#.......................#.╚════╗═╝....F...#═══#....p..............#════#........║                    ║xxxxxxxxx..║ |
|.......+................p..-...+................-...+...................-....+.....F..║                    ║........x..║ |
|.......#....................╔══#......║..........#═══#..................╔#════#........║                    ║...........║ |
|.......║.........r..........║  ║...............╔     ════╗.............║..............║                    ║...........║ |
|     ╚═══════╝....r........c......║  ║..c..╔╝╗.....╔══          ║...r...╔═════╝..............║                    ║...........║ |
|....................║  ╚══╝...c...F..║            ║.......║     ║............╔═╝                    ║...........║ |
|.......╔═╗......L...║  ║............║            ║.......║     ║............#══════════════════════#...........║ |
|             ╚═══════  ║..........║  ║............║            ╚═══════╝     ║....L.......-......................+...........║ |
|                       ╚═╗........║  ╚══════╝══════╝                          ║........╔═══#══════════════════════#...........║ |
|                          ════════╝                                           ╚════════                            ═══════════╝ |
|                                                                                                                                |
\--------------------------------------------------------------------------------------------------------------------------------/

Optionally, you can uncomment the line to save it as a TMX file for use in Tiled. Doing this will allow you to use the above grid with a tileset to get better graphics.

./worldbuild/samples/dungeon_resized_in_Tiled.png

Coming soon - better example of tileset graphics