River Connection Algorithm

Jetty, pier, a small structure projecting into (usually) a river for unloading goods from a small ship.

Although, dock, wharf, pier, quay, et al would work as well ;)
 
:woohoo::woohoo::woohoo::woohoo::woohoo:
That's a road connection to Phoenix and then a river connection to New York

City connection icon - tick
Science bonus from the pantheon belief - tick
Gold bonus from the connection - tick
(all three without adding any extra code, so I'm confident that any other bonuses from city connections will also "just work")

<snip>

EDIT: And speed wise, at least within the resolution of Lua's os.clock() function, it doesn't seem too bad
Code:
OnCityConnected: Map scan took 0.212 seconds for 6656 plots finding 30 rivers with a total of 402 segments
OnCityConnected: Washington to Santa Monica took 0.002 seconds
OnCityConnected: Washington to Cleveland took 0.003 seconds
OnCityConnected: Washington to Phoenix took 0.000 seconds
OnCityConnected: Washington to New York took 0.000 seconds
OnCityConnected: Santa Monica to Cleveland took 0.003 seconds
OnCityConnected: Santa Monica to Phoenix took 0.000 seconds
OnCityConnected: Santa Monica to New York took 0.000 seconds
OnCityConnected: Cleveland to Phoenix took 0.000 seconds
OnCityConnected: Cleveland to New York took 0.000 seconds
OnCityConnected: Phoenix to New York took 0.0001 seconds

That performance hit happens each time a city is built/removed?
 
That performance hit happens each time a city is built/removed?

If you mean the map scan, that only happens if you terraform the map (ie add/remove rivers/lakes)
 
Slightly off-topic from the original subject line, but the same DLL events used by the river connection Lua code can also be used to create air routes between (say) two cities with airports - in much that same way that water routes are formed between cities with harbours. This would allow a land-locked civ to form an air-route to a remote city
 
what is the update time like when a city is added/removed?

Not relevant. The DLL recalculates all city connections every turn (see posts #32 to #36 above and the code in CvCityConnections.cpp) as they change dynamically (roads built/removed/pillaged, zoc changes, cities founded/razed/traded/captured, etc, etc, etc)
 
From my latest test game - Rome to Washington
Road from Rome to Mediolanum
River to San Antonio
Road past Phoenix to Monterey
Finally river to Washington
 

Attachments

  • RomeToWashington.jpg
    RomeToWashington.jpg
    283.3 KB · Views: 78
Does it work with sea connections?
Let's say capital is coastal, city connected via harbor, third city connected to second via river...

Not tried it, but it should do. The river connections are actually treated as a type of harbour to harbour connection, but on a river.

River connections are adding an interesting twist to the game play in that you still need roads to move troops around efficiently and at some point I'll need to connect everything up with railways.
 
Not tried it, but it should do. The river connections are actually treated as a type of harbour to harbour connection, but on a river.

River connections are adding an interesting twist to the game play in that you still need roads to move troops around efficiently and at some point I'll need to connect everything up with railways.

Yes, this adds that historical something, I love to play long games, building a road in ancient eras takes time, connecting cities with rivers will just be something else ;)
 
But river travel worked for moving warbands around too. Now that this groundwork has been laid, it'll be much easier to add river travel for units in some way too.

A simple method might be something like an airlift between cities on the same river. Although the coolest way, I think, would be a river-embark mission that is only avaliable at docks (though perhaps you can disembark at any point), with different speeds upriver and downriver.

[I'm not suggesting you ought to do this, whoward69; I'm just musing, as I am wont to do.]

...and you'd have to figure out what happens if you're attacked on the river...
 
Does it work with sea connections?
Let's say capital is coastal, city connected via harbor, third city connected to second via river...

Yes (city -> river -> road -> harbour -> river -> capital working in test game)
 
I agree this has interesting influence on game. One benefit will be that it will give you some early gold which is often needed and which will help you fund city connections by road while you're working on them instead of as now you'll only get the gold once the connection is completely finished.
But river travel worked for moving warbands around too. Now that this groundwork has been laid, it'll be much easier to add river travel for units in some way too.
Doesn't the belgium unique trait from SFA scenario allow you faster moves when moving along rivers as part of its benefits? Perhaps it would be possible to grab the effect from there.
 
Doesn't the belgium unique trait from SFA scenario allow you faster moves when moving along rivers as part of its benefits? Perhaps it would be possible to grab the effect from there.

See posts #21 to #26 in this thread
 
Back
Top Bottom