raystuttgart
Civ4Col Modder
Hi guys,
I have started to write a "technical concept" (pseudo code) for an algorithm to generate "Large Rivers" by a DLL method called from MapScripts.
My main problem, the algorithm heavily relies that it finds
the closest Ocean Plot (as potential end point of a "Large River")
to a given Land Plot (as potential starting point of a "Large River").
And since I need to do this many many times to find the ideal places to generate "Large Rivers", it needs to be very performant.
@f1rpo @Nightinggale @devolution
So any suggestions?
Basic explanation why that is needed:
(It is a bit more complicated than that but the spoiler should give the general idea.)
Comments to the rest of the algorithm:
(It is a bit more complicated than that but the spoiler should give the general idea.)
@devolution:
Please let me know if you already implemented something like that so I do not waste my time.
@community:
Please leave this discussion to people that understand programming DLL logic for Civ4BTS / Civ4Col.
I have started to write a "technical concept" (pseudo code) for an algorithm to generate "Large Rivers" by a DLL method called from MapScripts.
My main problem, the algorithm heavily relies that it finds
the closest Ocean Plot (as potential end point of a "Large River")
to a given Land Plot (as potential starting point of a "Large River").
And since I need to do this many many times to find the ideal places to generate "Large Rivers", it needs to be very performant.
@f1rpo @Nightinggale @devolution
So any suggestions?
Basic explanation why that is needed:
(It is a bit more complicated than that but the spoiler should give the general idea.)
Spoiler :
Basically it first checks if the Plot itself is "Flat Land" first, before it does the search for the "closest Ocean Plot" as described above.
(Only then it tries to find that Ocean Plot.)
After it found the "Ocean Plot" it checks it checks the distance to the closest Ocean Plot is too short or too long.
(These are new setting in the "MapSize xml".)
Also the loop to generate "Large Rivers" will end once it has generated the "max number of Large Rivers".
(That is also an new setting in the "MapSize xml".)
Once it looped all Plots it will of of course also end even if it could not generate "enough" Large Rivers as defined in "MapSize xml".)
(There may be Island Map Scripst like "Caribean" that can hardly generate Large Rivers.)
(Only then it tries to find that Ocean Plot.)
After it found the "Ocean Plot" it checks it checks the distance to the closest Ocean Plot is too short or too long.
(These are new setting in the "MapSize xml".)
Also the loop to generate "Large Rivers" will end once it has generated the "max number of Large Rivers".
(That is also an new setting in the "MapSize xml".)
Once it looped all Plots it will of of course also end even if it could not generate "enough" Large Rivers as defined in "MapSize xml".)
(There may be Island Map Scripst like "Caribean" that can hardly generate Large Rivers.)
Comments to the rest of the algorithm:
(It is a bit more complicated than that but the spoiler should give the general idea.)
Spoiler :
Everything else in my algorithm is more or less a piece of cake considering implementation.
(I would know how to implement all of that but I would of course give it to other experienced modder to further optimize its performance.)
The rest is basically a (partially randomized) "weighting system" to check in which cardinal direction it should move to create the next "river section".
It considers for "weighting" mostly previous move direction (relative to "end Ocean Plot"), "Mountain Plots", "Hill Plots" and "Water Plots" of adjacent plots to figure out if an adjecent plot could become the next "river section".
(It may find "Lakes" or even other "Large Rivers" but the only "Ocean Plot" it should find in the process is the "end point" we found above though.)
Once I know how to find the "closest Ocean Plot" I can also find the "closest Large River Plot".
(I will try to implement a min-distance between 2 Large Rivers. Also as a setting in "MapSize xml".)
Large Rivers will be generated before any Small Rivers, Terrain Features, Villages, Goodies, ... are placed.
(Thus all of that stuff does not need to be considered in the algorithm.)
(I would know how to implement all of that but I would of course give it to other experienced modder to further optimize its performance.)
The rest is basically a (partially randomized) "weighting system" to check in which cardinal direction it should move to create the next "river section".
It considers for "weighting" mostly previous move direction (relative to "end Ocean Plot"), "Mountain Plots", "Hill Plots" and "Water Plots" of adjacent plots to figure out if an adjecent plot could become the next "river section".
(It may find "Lakes" or even other "Large Rivers" but the only "Ocean Plot" it should find in the process is the "end point" we found above though.)
Once I know how to find the "closest Ocean Plot" I can also find the "closest Large River Plot".
(I will try to implement a min-distance between 2 Large Rivers. Also as a setting in "MapSize xml".)
Large Rivers will be generated before any Small Rivers, Terrain Features, Villages, Goodies, ... are placed.
(Thus all of that stuff does not need to be considered in the algorithm.)
@devolution:
Please let me know if you already implemented something like that so I do not waste my time.
@community:
Please leave this discussion to people that understand programming DLL logic for Civ4BTS / Civ4Col.
Last edited: