Connection and Distance to Capitol (or Regional Government) [ACCEPTED]

Does the concept sound interesting?


  • Total voters
    22
It's just a question which numbers you want to display in red and which in green.
I want to display it exactly like this:
  • Malus of -X for missing connection
  • Bonus of +X for existing connection
And yes, it is also for "psychological reasons". :thumbsup:

The player should also understand that he is missing something.
(Because without the malus displayed in red, he might not know it because it would not be visualized.)

-----

But most importantly:

Messing with the basic balancing (Units / Professions / Improvements / Terrains ...) is always a really really bad idea.
Because that will again impact all other features. (And I am not going to mess up the complete mod, when I add a new feature.)

-----

I can just repeat:
The concept above is what I offer. :)
Simply let me know if you want to have it: Vote "yes" or "no". :thumbsup:
Take it or refuse it.
 
Last edited:
Maybe this could be expanded with bigger 'Regional' warehouses for inland colonies.
(maybe should be capable to store the same amount of Goods as Custom Houses.)

Surrounding colonies deliver raw materials and pick goods in return.
Regional Governments colonies (States?) send excess goods to capital and bring back
goods not available in the colonies (e.g. Luxury Goods) which had been bought overseas.
 
@f1rpo, @devolution, @Nightinggale

Is there already a good algorithm in one of the Civ4BTS mods, that can check something like this:
City is connected to another City by Road or Water Route?

Methods like these would be great:
bool CvCity::isConnectedByRoad(int iCityID) const
bool CvCity::isConnectedByWaterRoute(int iCityID) const
int CvCity::getPlotDistanceViaRoad(int iCityID) const
int CvCity::getPlotDistanceViaWaterRoute(int iCityID) const

If it already exist, please point me to where I can find it. :thumbsup:
(If not and one of you would like to program such an algorithm it would really be great.)

I have ideas how I could program it, but my solution would simply not be performant.
(Currently I can only imagine some kind of Dijkstra Algorithm.)

-------------------

Also I do currently not know how I could handle "indirect" connection.
e.g.

A<- connected by Road ->B
and
B<- connected by Ocean / Harbours ->C

Thus also
A<- indirectly connected by Ocean / Harbours ->C

-------------------

Also I am pretty sure that those CityIDs are not truly globally unique.
To my knowledge they are always relative to the Player / Empire.

For my current concept that should not matter though ... but for the future ... :hmm:
(I would currently only want to check connections within a single Empire.)

-------------------

I really wonder if the Pathfinding logic may already have some solution to this. :think:
(But I have never properly checked that logic so I simply do not know.)
 
Last edited:
No such thing in BtS, probably not in your codebase either unless your team added it.

BtS has the CvPlotGroup class for keeping track of plots with mutual trade connectivity. But this treats all types of trade connection (river, route, terrain) the same and no distances are calculated. It's also pretty intricate to keep the plot groups up to date. Caching that sort of info is generally a headache, I think, so you'd arguably have to run a graph algorithm on the fly. If that isn't fast enough – you may well be right about that –, then I'd look for a more abstract game rule. (Or maybe rather less abstract – Col's approach to transportation seems to be to let the player actually move cargo units on the map, whereas BtS only checks whether a path exists and doesn't even care how long it is.) Edit: I've reached this thread through a notification; hadn't even realized that there are posts above Ray's last post. I'll read the whole thread now to understand the context. Edit2: I see that Nightinggale had already covered the CvPlotGroup approach.

For shortest path lengths, A* should be used. Dijkstra would be more efficient only if distances from one source to several destinations are needed. And, even then, probably not much more efficient because A* can (and our available implementations do) reuse temporary results from previous searches. Firaxis's FAStar pathfinder is pretty flexible; see its various uses in CvMap::setup. The global functions provided as parameters are defined in CvGameCoreUtils. Would have to define some new functions that allow only moves along roads, only along rivers and coast or both (for mixed paths). The more efficient K-Mod pathfinder was only intended for moves of (existing) units, but iirc @devolution has added code for creating a temporary dummy unit. I guess one could restrict the moves of such a unit to roads etc.

A somewhat related question in the BtS Quick Questions thread: checking if two cities share a river

Also I am pretty sure that those CityIDs are not truly globally unique.
To my knowledge they are always relative to the Player / Empire.
There's the IDInfo struct for identifying cities globally. That's a pair of a player ID and a per-player city ID. I'd use IDInfo only when dealing with serialization or the Python interface though; otherwise one can simply use a CvCity pointer or reference. There's only ever one instance of a city, so the memory address will be unique. Could also use a CvPlot handle (pointer, reference, coordinates or CvMap::m_pMapPlots index). The A* implementations support non-city source and destination plots.
 
Last edited:
@f1rpo
Thanks for the feedback. :)
(And the good hints on implementation)

Being able to figure out performantly if Cities are connected could allow many small but still interesting new features in our mod.
(e.g. Influencing Happines or higher Domestic Market Demand or reducing Upkeep or being a build condition for Buildings or ...)

But I guess, I will wait until @Nightinggale is back to active modding again. :thumbsup:
(He already had an idea how to implement this and is a much better programmer than myself.)

If something like this had exited already in Civ4BTS I would have adapted it to WTP to build this feature.
But since it does not, I rather continue working on other features and prototypes I already started.

----

I guess it could also be a cool functionality for some fo the Civ4BTS mods as well.
So maybe one day either we WTP modders or the Civ4BTS modders may implement it.
 
Last edited:
Top Bottom