Connectivity and resources

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Ignatus
Hardened
Posts: 258
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Connectivity and resources

Postby Ignatus » Sun Jul 14, 2019 5:58 pm

Connecting to strategic resources (henceforth luxuries included) and to other cities is a central topic of Civ3 that was enough good to be includet into consequent commercial games. Here are ideas how to bring it into Freeciv.

1. In terrain.ruleset, to the [resource_*] sections we append "strategic" boolean option. Maybe we want to get some "Fuel" from just "Woods" terrain, then we put into the "extra" property some really never generated extra just for graphics and name, and fill a table sources={"terrain", "extra"} (may work independent for real extras). Ability to collect resources from an owned tile not occupied by a hostile unit is enabled by "Tile_Resource_Amount" effect that can get resource extra in "Extra" requirement; effect value of each present resource (probably we don't put too much of them in one place) appears there, you should append extra visibility_reqs to block invisible ones' effects. We can also generate a resource in cities by "City_Resource_Amount" effect , something like Civ4 "Great Hits" that are produced just by a wonder in a city. Maybe in future development we'll add a way to put random numbers on such tiles that signify how reach or poor is this specific mine.

2. Some unit types get "CityConnector" role. The connectors are virtual units (I don't like the idea of Civ5 traders that creep the map automatically and you have to guard these dumb robots) that are used to find the path from a city that fits their build reqs to a resource tile or another city, in commercial games ownership of tiles and cities on the way is ignored for this purpose. A city can manage all possible types of connectors in one turn but each one path observes only one, without ability to load in a boat and then continue by a continent. If the path is found, tiles are connected. Airport connection may be checked by ability to airlift such units between cities (but without further movement), airlift counters ignored. Cities of the same player that are connected one to another into a connected graph form a connectivity cluster and can use any unit of the stategic resources connected to any of them. Maybe we should furtherly think of a way to prohibit transporting certain resources by certain connectors (e.g. coal by planes).

3. There is a requirement range "Connected" that tests for resources in the cluster of the target city and allows to introduce various effects. We can use it also for goods (but can't we drop them with this system?) and wonders requirements, e.g. we can reduce corruption for cities connected to our capital. A unit or a building may either require a resource for being built (then one resource enables any number of them, Civ3 style) or consume it (a unit of the resource is no longer available to the cluster until the unit or building exists, and it is destroyed or weakened if the source is lost). Some Civ4 buildings can consume resources optionally and convert a unit of them to some output each turn.

4. Connection clusters of different players may trade to foreign one by a treaty if a city tile of one is in connected area of the another, thus a unit or more of the resource disappears at one side and appears on the another (in Civ3 treaties enabled trade agreements only between clusters of capitals).

Ignatus
Hardened
Posts: 258
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Connectivity and resources

Postby Ignatus » Mon Jul 15, 2019 7:16 pm

5. An amendment should be made to require Harbor in both coastal cities. Either we require that both connectors must reach another end or for the required building introduce some flag "ConnectorDestRequired".
6. With this system we can have some different trade route concept for routes between cities mostly resembling Civ5 system (but with less dependence on automoving). A city can found a trade route to another one (some ruleset-defined conditions met) if any connectors (here better named "traders") from it can reach the target. Establishing a route may cost some gold proportional to the distance in steps. After establishing, the establised civ gets some advantage (mostly fast expiring) but if the dest city has an appropriate trader it also gets benefits (Civ4 unidirectional routes are possible but boring). Each turn the path is recalculated through accessible tiles (probably, for advanced traderoutes we should turn on diplomatical obstacles; in Civ5 there is "blocade" naval mission to block some sea around from traders); only if there is no open path left the route is blocked. The traderoute may be expirable in certain number of passes of the connector back and forth.
7. For the basic traderoute value, we need population, distance, trade tile/building output, goods (they are necessary here because spread luxury and strategic resources this way would be too much) etc., mostly like now. Per turn one gets only part of the value proportional to part of the path that the trader can pass(so longer routes expire slower but give not much more, maybe the distance effect should be adjustable to 0). The total number of traderoutes for a city can be also limited like now, but in commercial games the capital supports very many (and indirect) traderoutes, that is better done by some connectivity cluster mechanism.
8. I suggest to make city traders a bit more real units behaving much like city defenders but not actually placed in the city unit list or on the map, just you see your and opposite end traders on a special city pad. They also are numbered by two effects, get veteranship from veteran_build or activity (mostly for just trading a long time with small work vet.chance but see below). You should make some citizens to work merchants to produce effect points for more traders that are distributed by existing trade routes (trader type maybe auto-selected) automatically by CMA or manually. Let the traderoute produce a specific maximal outcome that is distributed between the sides proportionally to move points/path length invested, but not more than 100%. If the cities give more points, they start to concur for the path's tiles with "Trading_Strength" effect and veteranship bonuses (maybe random winning for each tiles but why not a stable share); the trader moves lost in concurrence go to the opposite side as gold and/or happiness. You may also enter a trade war against another civ: on trade routes between your cities your traders will attack foreign ones destroying or damaging them, so they get less move points (but so may you; in mutual trade war attack or defense priority will be random). In this war traders may get hardened.

Ignatus
Hardened
Posts: 258
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Connectivity and resources

Postby Ignatus » Tue Oct 15, 2019 8:18 pm

Or maybe we leave trade routes just for strategical resources (or introduce cap-to-cap trade mechanism but I don't like it) and introduce a simpler and in some aspects more realistic system for other things - moving caravans is probably not the biggest fun in the game and you have a lot of other aspects to work on. Just let connected city clusters of different nations, if diplomatic agreements allow it, exchange some trade points and some luxuries to more or less mutual benefit. Firstly, basic trade for i-th cluster T_0i is just sum of trade outputs of all its cities. Then, each nation has protectionistic policy effect from 0 to 100% (probably a multiplying slider involved) that tells what share of a bonus from mutual trade is the nation going to leave for itself, let its value normalized into [0;1] be p_i. Then additional trade for i-th cluster from trading with foreign j-th one
T_ij = F * T_0j/(T_0i+T_0j) * (f_ij*T_0i*(1-p_j) + f_ji*T_0j*p_i) * B(c_{i+j}),
where B(c_{i+j}) is a bonus function of number of continents where one or both of the clusters have a city, F is a bonus coefficiency for foreign trade and f_ij, f_ji are shares of foreign trade that each cluster sends to the another that is proportional to the expected profit from a trade unit,
f_ij = (1-p_j)B(c_{i+j}) / ( B(c_i)/F + sum[k~i] (T_0k/(T_0i+T_0k) * (1-p_k) * B(c_{i+k})) )
and the full trade of a cluster is
T_i = sum[j~i] T_ij + (1-sum[j~i] f_ij) T_0i B(c_i)
and this value is shared proportionally between all the cluster's cities. As it can be seen, there is no route length here, just bigger clusters on different continents mean bigger distances. And for luxury trade, we just make a treaty that for N happiness points supplied from any of our clusters having the resource to any of the partner's connected clusters, a gold is paid to us; so we avoid the dumb rule that a tile with Spices will make happier either a nation of 1 city or a nation with 100 cities, but you need another such tile to supply both. To balance the game from making a luxury resource tile an endless cash cow, AIs shuld be taught to make alliances on terms "if one conquers this tile from these scroodges, he must set prices at maximum M".

Ignatus
Hardened
Posts: 258
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Connectivity and resources

Postby Ignatus » Sun Dec 01, 2019 11:01 am

A minimal ruleset data format that can support at least Civ2 traderoute bonuses should look somehow like this:

Code: Select all

[connectivity_raiload]
;/*TRANS: city A connected to city B by what */
name = _("by railroad")
city_reqs = {"type", "name", "range"
 "Tech", "Railroad", "Player"}
tile_reqs = {"type", "name", "range"
 "Extra", "Railroad", "Local"}
traderoute_bonus_pct = 50
; goods = list of possible goods (all by default)

For traderoutes, the connectivity must be direct, but for just "Connected" req all connectivities work. For the requirement that from a coal tile we need not just a road but a railroad we need also a line that specifies possible resources (all by default but for "by road" and "by airline" we specify only light enough ones). That though means we won't be able just to make a struct connectivity object that stores all the resources and is referred by several cities.
Also, we'll need a way city advisors (maybe autosettlers, maybe AI only) should direct workers to build trade routes and settlers to make pinch point cities, and AI should be smart enough to send military units to defend the working parties from captuing and the routes from pillaging.