Procedural World Generation?

Has anyone had any luck with procedural world generation?
I am currently working on taking a semi-generated world heightmap, and turning it into a auto-generating game-world - according to the map provided.

The theory of it would be that the heightmap information contributes to the detecting the biome type. Once you get the biome type, you get a rough idea of what sort of area should exist in that specific cell- Coast, Grasslands, forest, mountains, swamps etc
In order to keep things fresh looking, each biome would have maybe 10-20 different variation of area templates to choose from. Different placeable placements, caves, trees etc
Every area would use a trigger to go north, south, east and west - taking the player into the next area according to the height map information. Each trigger would generate the next area in the world as per the design.
Eg: If you are in area - 50,34 - going north to 50,33 : this would cause nwscript to generate that next area on demand.

Iā€™ve worked out an algorithm that accurately enough detects coast lines etc - so it should be possible to make it determine which way the coast line is facing etc.

The CreateArea function from nwscript would be the main facilitator of this system.

Just wondering if anyone has tried anything like this already?
Below is an example heightmap - each square representing roughly one nwn area - sandy brown = coast, blue = water, grey = height map elevation.

2 Likes

Have you seen Universe of Arlandia? See my post, itā€™s built on the original NWN using the old NWNX:

https://neverwintervault.org/forums/neverwinter-nights-1/nwn1-modules/i-have-server-ontario-if-someone-wants-run-module-or-pw

I can set it up if youā€™d like to see. Iā€™m no programmer, but was hoping to update it to EE and the new NWNX, but it is a long shot.

It uses template areas, which are claimed by the system, which creates a limit to how many areas of a particular type can be used. I was hoping to migrate it to the newer area clone feature thatā€™s been around for some time.

EDIT: HAH, it was youā€¦ never mind. Iā€™d be very interested in what people are doingā€¦
See also this post on someone elseā€™s thoughts: https://neverwintervault.org/forums/neverwinter-nights-1/nwn1-scripting/organically-spawned-areasrandom-maps-etc

1 Like

So just an update.
Iā€™ve create some .Net Core code that takes images
HeightMap + BiomeMap
And then produces a collection of ā€˜cellsā€™ with corresponding data.
Eg:
{
ā€œxā€:0,
ā€œyā€:5,
ā€œTerrainā€:4,
ā€œBiomeā€:2
}

So by making each area in nwn, the equivalent of a 5px x 5px rectangle on the image - it can result in around 71000 area definitions being created.
Note - this is also including water tiles - which are not explorable, so once you remove those - the count will be significantly less.

So I uploaded all this data into a database -
Created some nwn nss code that would be attached to a trigger.
When it detects we are the Eastern Trigger, it knows to take our X coordinate and add +5 to it, in order to get the desired X,Y coordinate of the next connecting area - it then connects to the db, to find out what terrain type and biome type it should be connecting to.
It then querys the database for my list of terrain templates that match that terrain type and biome type.
Eg: It might be looking for flatground, grasslands or it could be rocky terrain, tropical rainforest, or mountain, glacier etc

The query used for the sql uses order by Rand() limit 1; to get a random area resref that matches the criteria.
It then spawns that area, sets its tag to be the x,y coordinate - so we can get the area again in the future easily.
It locates the waypoint for the western spawn point in that area - and then connects the eastern trigger in the current area, to the western wp in the new area.
Once it is all done - the player is ported to the waypoint.
When they try to go back to the area they just came from - the system will check for the existence of an area that has the correct x,y tag- if it exists - it uses that as the destination area instead of trying to make a new one.
It then knows that if you are going West, you need to connect to an Eastern WP.
Another property I have on the area templates is
connect_west
connect_east
connect_south
connect_north

With these integers, I am able to make areas that have 0-4 connectable sides.
This way, I can make it possible for some paths to be blocked off while allowing an area to always find an area that has the appropriate connections.
Eg: select from table where connect_south = 1 and biome = ? and terrain =? order rand limit 1;

This way a northern connection will always find an area that has at least a southern connection - as well as any other connection it may have - but at the very least, it must have a southern connection - because that is what the player is entering via.

The other thing to be aware of is - Once a player has explored an area - I donā€™t want the area to be randomly generated at that stage.
Eg: After resets
So I would track in a db, x + y coordinates against the resref of that explored area - this resref would be used for re-generation, instead of the randomized query. (Yet to do this bit)

1 Like

Some images of what it looks like:
This is a height map for a proposed gameworld

Imgur

Then I came up with a rough biome map - by choosing colors to represent biome types

Eg: Red = volcanic , white = glacier, various greens = tropical/temperate rainforests, orange = desert, yellow = savana etc

Imgur

This biome map was done very roughly with gimp - all I did was paint in a big square brush the rough biome mapping.
My .Net program then combines the heightmap and the biomemap + applies a 5x5 pixel cell effect - to generate the map of the gameworld.
While it does this - it saves the cell definition to a json object - so I can build the game world in nwn.
Imgur

2 Likes

I got my copy of that Arlandia server running, click the Arland link in the upper right to check out the map (as I have explored it). I just realized itā€™s a new DB, Iā€™ll have to import my explored DB so you can see each area is mapped as players explore (fixed with real player DB). The DM are can view the whole map, but Iā€™m still updating it to a newer version of PHP and itā€™s apparently brokenā€¦ Hereā€™s the direct link, Iā€™ll get everything working soon. :flushed:

EDIT: See below for the new IP

Each world is generated as you discover new systems I think. Arland and the initial system are default and generated on module load I think.

Iā€™m hoping to move this to the area clone method instead of reusing the same template areas, as that limits the number of people that can be in a particular biom at once.

Are you creating template areas manually then using copies?

This Arlandia setup uses premade areas, and they are repetitive. Iā€™m thinking of removing the infinite worlds aspect and using it to randomly lay out a bunch or larger more carefully crafted areas throughout the world. This would make it more random, and allow me to craft adventures or something more structured for player activities. Still thinking on how to do this.

Part of this that the original author uses placeables to create new building layouts within a basic biom type of area. So I have (in-game) built a Domain where Iā€™m given a 3x3 grid of plots to build whatever buildings id like. Central square with fountain and bench, training barracks for guards for my area, a training tower for players to gain XP, sawmill to generate lumber (must be in a forest to build but wood is one of the building resources you need to build other structures), etcā€¦

So I am creating a number of template areas that fit certain criteria.

  1. The Biome Type (Glacier, Tundra, Temperate Forest, Tropical, Savana, Desert, Volcanic)

  2. The Terrain type (Beach, Flat, Forested, Rocky, Mountains)

  3. Connections per area: North, South, East and West.

The repetitive nature can occur if the amount of area templates is somewhat low- they way I have my module setup is that any area in the module that has the local int value : WB_TEMPLATE = 1, will have its resref, connection info, biome and terrain type put into a DB Table.
This way- the system is somewhat extensible.
I can build new areas and just keep adding them to the system to give more diversity. The query against the dB table includes order rand() limit 1; to bring back a random resref that matches all the required criteria.
This is also how I am handling the beaches.
Getting the system to accurately detect and handle coast lines is challenging- but I seem to be able to get it to determine what coastal template to use based on whether or not the adjacent cells are water or not.
Eg : if water is to the east, then the system needs to return a coastal area that has ā€˜connection_eastā€™ set to 0, while other connections are set to 1.

Also - another feature I am adding in is to group the cell data in the database by a world identifier- so I can generate many height maps- add them to the system and allow travelling to far and distance realms etc.

1 Like

Because it might be something useful, and Iā€™m trying to fully update it to NWNXEE (it IS running on NWNXEE now), here is Universe of Arlandia. Itā€™s not ready to announce, Iā€™m hoping to fix a few things, and clarify what to expect and how to craft, etc, but if you want to see any of it, there are links to download the haks and module, and it just requires PHP 5 / MySQLif you want to run it. If you want me to give you a tour or invulnerability to freely examine or explore it lemme know.

I removed the password, which I hadnā€™t realized Iā€™d left on. so you can actually get in now. And the haks are downloadable again, since they were pointing at nwvault.ign.com (HAH!).

http://uoa.homeip.net/

For a map of what Iā€™ve explored of the world so far as displayed by the PHP based map from the MySQL DB:
http://uoa.homeip.net/galaxy.php?planet=Arland&login=

I can share the DM login for the page, that letā€™s you view the whole map of every world or star system currently created. PM me for that.

I donā€™t really know PHP, and some of the reporting from NWN is gone or changed or I donā€™t understand the PHP. Anyway, it is running on NWNXEE on an Ubuntu server, and I should have NWSync working in a couple days. The haks are hella old, though. So I might just see if I can update everything to CEP 2.65 (CEP 2.2 since it was built in 2011 or earlier).
It does work fine with CEP 2.65, BTW. So you donā€™t NEED 2.2.

Also, PHP 7.1 doesnā€™t seem to work right as far as Iā€™ve gotten. Though it looks like itā€™s getting data form the DB fine, the PHP just isnā€™t processing the data correctly, and thatā€™s probably something Iā€™ll need to update for PHP7, not a bug since it works fine in PHP 5 (as you can see).

Otherwise itā€™s really a gather resources and build stuff module. Iā€™m trying to figure out how to add a story to it, and maybe more structure that players will care about. for now itā€™s build a Domain, mines/sawmills, build a spaceport and head off to new worlds that supposedly are created on the fly in the SQL DB. Iā€™ve tested the space exploration, but havenā€™t been outside of the current solar system.

My only issue is I want to have creatures actually be able to travel from area to area, and the method used in UoA uses edge transitions, which NPCs donā€™t understand. When Iā€™ve hired guards they are henchmen, so travel with me fineā€¦ But not NPC enemies chasing me. Maybe thereā€™s a limitation of how it is implemented or the scripts used by the AI.

This may or may not be an issue for me too- as I use edge triggers.
If the npc steps into it- all well and good- but making them recognise that they need to step on it is another matter.
Theoretically - their ai could be adjusted to keep a lock on the player they are chasing and if the area XY of the player changes to be 1 away from the NPCā€™s XY coordinate then it would tell the npc which trigger to walk into.
I believe there are methods to get trigger geometry- if you can get the vectors of all the points of a trigger- getting the average of the points will then get you the middle point of the trigger- a destination for the npc to jump to or run to.

Iā€™m in the process of porting my world builder system to .Net to get it running via the DotNet core plugin. Should give me new capabilities - since I can use real C programming and static objects to keep objects in memory etc.

so iā€™ve managed to get my server up and running and started working on dynamic building and spawning systems.
Video here shows the dynamic build system - at least an early version of it.
The final version wonā€™t use a build feat/spell - it will use an onItemActivated - which will be attached to purchasable plans/blueprints.
The entrance to the building has since been changed to be the more subtle ā€˜blueā€™ area transition effect from nwn2 - which is much more discreet.

A live map view of the world, as well as players has been added to http://aeoria.com

The world itself has random ambient life spawns - so badgers, wolves, bores, winter wolves etc - they all spawn in the appropriate biomes - while the more powerful spawns appear in ā€˜roamingā€™ events that appear on the map in a red circle.
eg: A red dragon has been spotted in the area
or Bandits are attacking people in the woods etc

These events spawn every 10-25 minutes etc.

Also got myself a QA Server sorted, so my on-going development doesnā€™t interfere with anyone wanting to play or explore etc.
Happy to answer questions or more etc on discord.
aeoria.com:5121 to join
https://discord.gg/2WYR2CD

1 Like

Very cool! Iā€™ll check it out at lunch, if I get one.

I was ready to release Universe of Arlandia here, but a Hak issues in NWNEE (and DB issue) is keeping me from sharing it. Otherwise itā€™s just a lot of correcting English, since that was not the authors first language. Whelp, weā€™ll see if I can fix it by the weekend.

I might run it too, but itā€™s kinda boring. Trying to do what you are, having events occur where players can party up and take care of it. Maybe throw in some custom areas with actual adventures.

I also would like to use the CopyArea features instead of needing extra areas, since that limits the number of people who can go to a given biom. (4 forest area, but the 5th player entering another Forest canā€™t, not even sure what happens right now).

Oh, and if you want another server or something let me know. If you teach my how to set up NWsync I can host the files separate from your server. I need to figure this out for UoA to run it more openly. I have bandwidth, but my servers donā€™t have fast storage. (NM, looks like you have that covered)

Which and how many haks are you using? I still have 5.8 GB to download.

Iā€™ve got all of CEP2.6 + Lord of Worms tiles + 130mb of custom music
Didnā€™t realise it was 5.8 - figured it would be around 2-3 gb with the compression etc

Iā€™ve got an early stage event system in place:
http://aeoria.com/

You can see where certain events are going to occur on the world map.
When players enter the circle- any of the areas has a chance to start the event, and then the players can tackle the monsters that spawn as part of the event.

The events spawn regularly and are anchored to a certain root location on the map.
In this case they spawn randomly within 60 cells of the starter city -
Centered on swamp for undead, Forest for Bandits and Grass land for Red Dragon attack.

The idea is that I will have dozens or more of these events appearing over the landscape, some of them will even be taken from Book of Vile Evil dnd book -
Things like ā€™ Lingering Evilā€™
An area could be marked as ā€˜Eerie Presenceā€™ affecting lighting, colors, weather
Other areas could be a darkness never known before - causing a large area around a temple to become a hotspot for demons and undead etc.

1 Like

What does your NWN dev pipeline look like? I see your Discord mentions some automated tests. Iā€™m looking at nwn-devbase. Are you using that? Iā€™d like to get the whole module efficiently in Git. Right now itā€™s dirty with me copying files manually to the Git directory for checkin.