Azgaar / Fantasy-Map-Generator

Web application generating interactive and highly customizable maps

Home Page:https://azgaar.github.io/Fantasy-Map-Generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cycle errors in religion tree generator

carrotSteelfounderson opened this issue · comments

When generating a map with more than a small number of religions, the religion tree will not generate, claiming a "Hierarchy data issue. Error: cycle". This happens consistently with 18 religions or more, and can happen with fewer.

Steps to reproduce

  1. Load the website https://azgaar.github.io/Fantasy-Map-Generator/
  2. Click on the arrow in the upper left hand corner
  3. Click on the options tab
  4. Go to the slider labelled religions, and set it to 18 or higher
  5. Click "New Map"
  6. Click "Tools"
  7. Under the section labelled "Click to configure:" click "Religions"
  8. Looking at the set of buttons at the bottom of the newly opened window, click the fifth from the left
  9. Observe the red bar at the bottom, containing the error message.
  10. repeat to note that this is a consistent behaviour

Expected behavior
Either that the program would not generate patterns of religions with such relations, or that it would be equipped to display them in this way.

commented

Thanks for the report! We have recent changes to the religions code. @CanisArtorus, do you have time to take a look?

Overlooked consequence of switching from a for loop to .map() while generating the origins list.

Most similar fix is also simplest:
religions-generator.js line 600 in getReligionsInRadius(...)
600 if (neibReligion && neibReligion !== religionId) foundReligions.add(neibReligion);
to
600 if (neibReligion && neibReligion < religionId) foundReligions.add(neibReligion);

and line 744 in add(...)
744 const influences = getReligionsInRadius(cells.c, center, cells.religion, 0, 25, 3, 0);
to
744 const influences = getReligionsInRadius(cells.c, center, cells.religion, 32767 , 25, 3, 0); // index not assigned yet

commented

Overlooked consequence of switching from a for loop to .map() while generating the origins list.

Most similar fix is also simplest: religions-generator.js line 600 in getReligionsInRadius(...) 600 if (neibReligion && neibReligion !== religionId) foundReligions.add(neibReligion); to 600 if (neibReligion && neibReligion < religionId) foundReligions.add(neibReligion);

and line 744 in add(...) 744 const influences = getReligionsInRadius(cells.c, center, cells.religion, 0, 25, 3, 0); to 744 const influences = getReligionsInRadius(cells.c, center, cells.religion, 32767 , 25, 3, 0); // index not assigned yet

Can you create a pull request with the fix, please? I can do it on my own if you don't want to.

commented

Thanks @CanisArtorus for fixing it. @carrotSteelfounderson, would you please check and confirm whether the issue is fixed?