1
\$\begingroup\$

I wanted to make a procedural dungeon experimenting a new approach, it works nice for random-meaningless content (in example a procedural background to a level), however when I want it to be not-so-random I incur in some conceptual problem: basically I end up with a grid of numeric sector IDs in 2D.

Grid example:

27 |  56  | 74
---+------+----
35 |  31  | 115
---+------+----
14 |  52  | 12

The main problem is how to fix adjacency so that content is generated in a deterministic way:

  • Content of sector "31" should be generated as a function of adjacent sectors (this works)
  • However when I generate content for sector "35", I end up with a different link between sector "35" and "31".

So basically according from which direction I cross a sector I see a different passage each time (while the content of the sector is always the same).

As you see in the following image:

Example of maps with connecting passages between sectors

The passage between 35-31 is different according to which sector is used to start content generation, which is not what I want. I want the same passage arise.

To answer comments:

sector[id].content = generateContent( sector[id].neighboursIds());
\$\endgroup\$
7
  • 1
    \$\begingroup\$ I don't get the question... what do these numbers mean? \$\endgroup\$
    – Ali1S232
    Jan 6, 2016 at 13:26
  • 1
    \$\begingroup\$ Could you explain in detail how you are generating the passages between sectors? Then we might be able to give a suggestion how it can be made deterministic no matter which order the sectors are in. \$\endgroup\$
    – Philipp
    Jan 6, 2016 at 13:30
  • 1
    \$\begingroup\$ I think the question needs more details, from what I gather, all you need to use is re-use the existing link between sectors, if there is one there already. \$\endgroup\$
    – jgallant
    Jan 6, 2016 at 14:10
  • \$\begingroup\$ @Ali.S those numbers are just sector ids, think that as to tile ids, in a tilemap they select the tile, in the procedural generator they choose a content type, while numbers of neighbours select additional content and passage to other sectors. \$\endgroup\$ Jan 6, 2016 at 18:55
  • \$\begingroup\$ @Jon you are right! the problem is that links should be only function of 2 adiacent sectors (taken in same order) while actually it is not (function of 9 sectors right now), however that results in boring dungeons maybe I can workaround? \$\endgroup\$ Jan 6, 2016 at 18:56

1 Answer 1

1
\$\begingroup\$

What you can do is seed the passage according to the two sector ids being linked in numeric order.

function CalculateConnectionSeed ( sectorA, sectorB )
  if sectorA < sectorB
    return sectorA + sectorB * 16384
  else
    return sectorB + sectorA * 16384
endfunction

So no matter which way the connection is made the same seed will be used (16384 is just a number I picked to make sure sector 2+3 wont be the same as sectors 1+4 provided there are less than 16384 sector ids).

Or always generate the connection in the same direction: left-to-right or up-to-down.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks, basically my error was using as part of the function the neighbours, though it produces interesting content, it is ureliable because changing neighbours => change the content. I'll revert to "link based solution" even if it provides less interesting content. \$\endgroup\$ Feb 8, 2016 at 9:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .