River movement mechanics
River movement mechanics
In back channels I got some interesting complaints (and ideas) about how rivers could be improved, and some ideas from other 4X games.
I try to reduce the complaints into two generalised areas:
1. If a move bonus on a river is presumably because some infrastructural transport is assumed to be there (like a boat), then why would a horsemen on a boat go twice the distance?
2. Rivers historically have marked borders because they are a natural barrier. As in, they are a barrier to movement when crossing, even if a convenience to movement when boating down the river.
The ideas to improve rivers are basically the same as above, but putting in a mechanic to address those points.
FCW is currently working on making rivers a more exciting and meaningful part of freeciv, so, before finalising anything, we welcome all ideas, discussion, and input you may have for rivers, and references to other 4X games you think have good mechanics to learn from.
I try to reduce the complaints into two generalised areas:
1. If a move bonus on a river is presumably because some infrastructural transport is assumed to be there (like a boat), then why would a horsemen on a boat go twice the distance?
2. Rivers historically have marked borders because they are a natural barrier. As in, they are a barrier to movement when crossing, even if a convenience to movement when boating down the river.
The ideas to improve rivers are basically the same as above, but putting in a mechanic to address those points.
FCW is currently working on making rivers a more exciting and meaningful part of freeciv, so, before finalising anything, we welcome all ideas, discussion, and input you may have for rivers, and references to other 4X games you think have good mechanics to learn from.
Re: River movement mechanics
I thought about rivers as they are in Civ3, and other obstacles like walls. An obstacle is an entity that exists between two adjacent tiles, they can be technically done with a special group of 4 extras (e.g. north-western border of a tile is stored within its extra while south-eastern is in the tile at south-east for which it is north-western). If we keep river streaming in the middle of tiles, there can be some uncertainity about when a unit crosses the river, or some other counter-intuitive effects; they can get used to though.
The same can be said about railroads. Trains with tanks don't go faster than trains with infantry. If we want to get a bit of realism into the game, some types of roads should get constant speed for units that can't pass the same way faster without the road. It's not obvious though what is "speed" in move points conception, but here we can mostly well use the equationwhy would a horsemen on a boat go twice the distance?
Code: Select all
(move fragments spent) = ceil[(road move cost) * (unit move rate) / (train or boat move rate)].
Re: River movement mechanics
On autogames, calculating the move cost between two tiles is one of the functions taking most of the overall CPU time. Very small changes there can have huge impact on performance (a lot of effort has gone to optimize it, short of writing that part in assembler, for the functionality we currently have).
Re: River movement mechanics
This is useful to know. I assume you refer to tile_move_cost_ptrs() in map.c.
Re: River movement mechanics
Putting between tiles, I thought of it but got scared it's too radical or difficult. But I hadn't thought of the 4 different extras, that would work for this. Good idea!Ignatus wrote: ↑Fri Nov 25, 2022 8:28 pm I thought about rivers as they are in Civ3, and other obstacles like walls. An obstacle is an entity that exists between two adjacent tiles, they can be technically done with a special group of 4 extras (e.g. north-western border of a tile is stored within its extra while south-eastern is in the tile at south-east for which it is north-western). If we keep river streaming in the middle of tiles, there can be some uncertainity about when a unit crosses the river, or some other counter-intuitive effects; they can get used to though.
But it raises lots of compatibility issues for things like tile trade bonus and movement system, so we're keeping the legacy system of one tile, one river extra. For forseeable future, but who knows?
Also feel free to look at the EXTRA_WALL tile_extra in MP2D, which performs something similar to what you say but as single extra on single tile. This uses RF_REVERSE_RESTRICT_INFRA flag. Similar to restrictinfra. If you have restrictinfra conditions with the tile owner you lose all moves going onto the tile, otherwise not. https://freeciv.fandom.com/wiki/Terrain ... ain_Walls
FCW already has this for MP2E ruleset. Though this ruleset isn't released until 2023, you can try it at freecivweb.org to see. We use a road flag called RF_PASSIVE_MOVEMENT. For performance reasons (as cazfi mentioned), any road with this flag no longer measures move_cost in frags. Instead, the move_cost defined in terrain.ruleset becomes a divisor instead. For example, if the ruleset defines the move_cost as 6, it means all units using the road use 1/6 of their moves along the road. Like below:Ignatus wrote: ↑Fri Nov 25, 2022 8:28 pm The same can be said about railroads. Trains with tanks don't go faster than trains with infantry. If we want to get a bit of realism into the game, some types of roads should get constant speed for units that can't pass the same way faster without the road. It's not obvious though what is "speed" in move points conception, but here we can mostly well use the equationCode: Select all
(move fragments spent) = ceil[(road move cost) * (unit move rate) / (train or boat move rate)].
Code: Select all
if (road_has_flag(proad, RF_PASSIVE_MOVEMENT)) {
proad_cost = (unit_move_rate) / proad->move_cost;
}
Re: River movement mechanics
Yes, checking road flag is (relatively) fast; just lookup of one bit.Lexxie wrote: ↑Sat Nov 26, 2022 1:00 amCode: Select all
if (road_has_flag(proad, RF_PASSIVE_MOVEMENT)) { proad_cost = (unit_move_rate) / proad->move_cost; }
My comment was directed to ihnatus speculating about bringing effects system, and requirement lookups via it, to play.
Re: River movement mechanics
Well, we have an effect dependent move bonus since some version, I don't think one more effect does really much more (especially if it can be cached once in a turn in a player's table per extra).
Re: River movement mechanics
That's several orders of magnitude cheaper. It just adds to movement points of the unit in the beginning of the turn. Having effect in on the tile move cost side would affect all the path finding considerations -> easily hundreds of tiles, many processed multiple times (if cheaper route to that tile is found), each time path finding is used for a unit, most importantly in the reverse mode where (AI) cities evaluate danger.
Path finding takes about 40% of the CPU time on a typical autogame.
Re: River movement mechanics
I mean "Action_Success_Actor_Move_Cost". We have it for "Unit Move" actions since v.3.1, right? Just, looking at the code, it is considered by pathfinder only for unknown tiles. But yes, move costs are bulk. Actually, looks like worth caching them on the map when possible (something like int[n_directions][N_tiles][N_uclasses], or it's already not enough?)
Re: River movement mechanics
Oh, I wonder if that explains https://osdn.net/projects/freeciv/ticket/42598 . There has been other culprits that I've improved and managed to cut something like 20% - 25% of the autogame execution times from what it was at worst point, but 3.1 is still way slower than 3.0.