New Terrain Movement Cost System [IMPLEMENTED]

f1rpo

plastics
Joined
May 22, 2014
Messages
1,503
Location
Germany
I am not really getting a hold of the "pathfinding". :think:
Could you give me some hints how to adapt it?
Never really worked on pathfinding in the past. [...]
Since pathAdd is a function that will clearly need adjustments, I think I'd set a debugger breakpoint there to see what exactly is going wrong. Here's the bulk of that function (NB - the K-Mod version on Erik's pathfinder branch looks quite a bit different):
Spoiler :
Code:
if (data == ASNC_INITIALADD)
{
    iMoves = MAX_INT;
    iTurns = 1;
    pUnitNode = pSelectionGroup->headUnitNode();
    while (pUnitNode != NULL)
    {
        pLoopUnit = ::getUnit(pUnitNode->m_data);
        pUnitNode = pSelectionGroup->nextUnitNode(pUnitNode);
        iMoves = std::min(iMoves, pLoopUnit->movesLeft());
    }
}
else
{
    pFromPlot = GC.getMapINLINE().plotSorenINLINE(parent->m_iX, parent->m_iY);
    pToPlot = GC.getMapINLINE().plotSorenINLINE(node->m_iX, node->m_iY);

    iStartMoves = parent->m_iData1;
    iTurns = parent->m_iData2;
    if (iStartMoves == 0)
        iTurns++;
    iMoves = MAX_INT;

    pUnitNode = pSelectionGroup->headUnitNode();
    while (pUnitNode != NULL)
    {
        pLoopUnit = ::getUnit(pUnitNode->m_data);
        pUnitNode = pSelectionGroup->nextUnitNode(pUnitNode);

        iMoves = std::min(iMoves, std::max(0,
                ((iStartMoves > 0) ? iStartMoves :
                pLoopUnit->maxMoves()) - pToPlot->movementCost(pLoopUnit, pFromPlot)));
    }
}
FAssertMsg(iMoves >= 0, "iMoves is expected to be non-negative (invalid Index)");
The INITIALADD branch looks OK: Paths still have at least length 1.
The iStartMoves == 0 conditional (i.e. when movement points are already exhausted before adding the current step to the path) may have to handle iStartMoves < 0 as well. And the min/ max stuff and assertion at the end probably need to be changed too. Further changes may be needed in other pathfinding functions, but addressing these issues would be a start.
 

Nightinggale

Deity
Joined
Feb 2, 2009
Messages
5,032
NB - the K-Mod version on Erik's pathfinder branch looks quite a bit different
That's my main concern regarding this issue. If this is fixed in the old version and we then switch to the K-Mod approach, then we have to implement it again. I really wonder if it is worth it to solve this problem right away. It mainly depends on the ETA of @devolution's work.
 

raystuttgart

Civ4Col Modder
Joined
Jan 24, 2011
Messages
9,150
Location
Stuttgart, Germany
It mainly depends on the ETA of @devolution's work.
There is no need to hurry with this. :thumbsup:

If it is too much effort to adjust the existing pathfinding now to the "new movement calculation" and then do it again with the K-Mod pathfinding,
then I will simply wait until the work of @devolution is ready and will be merged into "develop" so I can merge it from there into "Plains".

Then I will try to figure out how I can adjust the pathfinding of K-Mod.
Help would be appreciated of course, since I know very little about pathfinding currrently.

So again:

No need to hurry. I still have enough other stuff to work on.
I can wait until the new pathfinding of @devolution based on K-Mod is ready to be merged.
 
Last edited:

devolution

Prince
Joined
Oct 7, 2016
Messages
527
Location
Norway
Some quick questions:

How would combat work ? I suppose that it would work as normal but it would be more tactically interesting to let the unit wait on the source plot before it arrives on the target plot. This could allow an enemy that occupies the target plot to escape since combat would only be initiated by the turn the attacker arrives and the enemy is still occupying the plot.

Should you be able to cancel a move ? If you accidentally start a movement to a forested jungle hill, this could tie up the unit for 3 or 4 turns which could anger some players.

What about having fractional moves left before attempting to enter the target plot? Consider a unit having 1/2 movement points left (from perhaps moving a turn on a plot with a road).

Maybe a simpler solution is to simply use civ6 movement rules? In civ6 a unit needs to have enough movement points equal to the cost of the target plot to be allowed to move. This is in contrast to civ4/5 where any remaining movement would allow a unit to enter a plot.
 

raystuttgart

Civ4Col Modder
Joined
Jan 24, 2011
Messages
9,150
Location
Stuttgart, Germany
How would combat work ?
Had not yet considered to make this impact combat itself. :dunno:

I suppose that it would work as normal ...
That was indeed my intention.

... more tactically interesting to let the unit wait on the source plot before it arrives on the target plot.
I really do not like that. It is visually very confusing and it slows down gameplay a lot.
I know that it is "Alpha Centauri"-style but I hated that movement mechanic.

Also see here:
I like your idea better, i.e. moving immediately and then "resting" to pay off the debt.

----

Should you be able to cancel a move ?
That is the beauty of my "movement logic":
Stuff like that is not needed. :)

----

What about having fractional moves left before attempting to enter the target plot?

The same, you would be able to enter, and then pay off the dept.
(Quite similar to now, only that the current system does not know the "dept".)

----

Summary:

I would really rather implement it this way. :dunno:
It is pretty simple and easy to visualize actually.

I am not a fan of "Alpha Centauri"-style to first save a budget "Movement Points" before moving.
I would rather do it "ray"-style and simply pay of the dept of "Movement Points" after moving.

----

Simply give it a try once it is fully done. :thumbsup:
It actually plays quite nicely in my tests. :)
 
Last edited:

devolution

Prince
Joined
Oct 7, 2016
Messages
527
Location
Norway
I didn't mean to criticize, only to provoke some thoughtful response :)

I agree that it's probably more elegant to let the unit enter the target plot and then "rest" (even if it makes a potential cancellation mechanic less "aesthetic" i.e. the unit would have to revert to the source plot by teleportation!)
Since we briefly touched on Alpha Centauri mechanics, I did like the combat system (but that will have to wait for another future post!)
 

raystuttgart

Civ4Col Modder
Joined
Jan 24, 2011
Messages
9,150
Location
Stuttgart, Germany
I didn't mean to criticize, only to provoke some thoughtful response.
No problem. :)

I agree that it's probably more elegant to let the unit enter the target plot and then "rest" ...
It really plays better to my opinion. :thumbsup:

... even if it makes a potential cancellation mechanic less "aesthetic" ...
Please let us not make things more complicated than they need to be. ;)
"Magic beaming out of the jungle" by cancellation is really nothing I want to see.

Player has made a decision to enter the jungle and he shall live with it.
Currently player also can not simply revert his move if he stepped next to a "Wild Animal".

----

Let us first simply give this a try as suggested. :thumbsup:
(Rules may be a bit more challenging, but it makes the game quite interesting actually.)
 
Last edited:

Buffalo Solider

Chieftain
Joined
Aug 11, 2016
Messages
37
I think on one hand I like the idea, but I think people on legs are better at treversing forest and jungle.. I think it's way more complicated than such simple calculation.

Maybe non-mounted units should have double movement in forest?
Because person moving through forest isn't bothered by forest too much, he can (for most part) just go. Horse rider has bigger problem in forest. For sure he can not move as freely as on open plains.
Also in jungle - person on legs move as fast as person on horse (if not faster, given that horse needs more space to be cut through trees/bushes/everything while providing absolutely NO speed value)
On the other hand - hills (without forest).. I think horse is way better option for treversing hills, than moving on legs. On legs you get tired, on horse... I don't know, I have very little idea about horses!

Overall I think :
person should move 1 tile on flats, 1 tile in light forest, 2/3 or 1 tile in forest, 1/2 tile in jungle, 1/2 tile on hills, 1/4 tile on peaks
horse rider should move ... 3 tiles on flats, 2 tiles in light forest, 1.5 tiles in forest, 1/2 tile in jungle, 2 tiles on hills and maybe 1 or 1/2 tile on peaks (but only scouts can move there)
(I also very much don't agree with current version, where scout have 2 movement speed, while dragoons have 3)

So maybe flats - 1 cost
light forest - 2 cost
forest - 3 cost
jungle - 4/6 cost
hill - 2 cost
peaks - 4 cost
foots - 1 speed, double move forest, dobuble move jungle
horse - 4 speed? But -50% in jungle? Or .... 2 speed, double move plains, double move hill/peaks... I don't know ...
Then double moves from promotions could be ditched all together. They would be only obtainable by "having" or "not having" horses. I also don't really like -1 terrain movement cost bonuses. -1 is arbitrary number... 2->1 makes huge difference, 4->3 almost none... also it does nothing on plains 1->1 . IMO - It is totally messed skill effect.

I imagine peaks as mountains, it wouldn't be really impossible/or even hard to move on horse, tho it would very much depend on what mountains are we talking about. Most moutains are not too crazy and they usually have some trails.

Of course system like proposed by you could open doors for very many variations! So I still would be happy to see it. Even if I don't agree with final form of movement speeds, thanks to such system I will be free to tweak whatever I want in XMLs!


What I miss from older civilizations/and colonization is moving along river bank (but I imagine it would be very time-consuming and hard, so I won't dare to ask for it). Moving from tile next to river to another tile that is next to (same) river, should always cost 1 move point (unless there's some mountainous waterfall, hahah).
 
Last edited:

ConjurerDragon

King
Supporter
Joined
Dec 13, 2012
Messages
653
Location
Rhineland-Palatinate
I think on one hand I like the idea, but I think people on legs are better at treversing forest and jungle.. I think it's way more complicated than such simple calculation.

Maybe non-mounted units should have double movement in forest?
Because person moving through forest isn't bothered by forest too much, he can (for most part) just go.

I do not agree with that.
Yes, in nowadays forests that are cut up and through by highways, speedways, streets and pathes for trecking and biking a person walking could move without restrictions. So - if you move normally without restrictions then why are you twice as fast in the forest than outside the forest? That makes no sense. What could make sense would be to have a person walking use the same speed in plains as in forests as you are not that hindered - but back then in a time without any roads and with everything you need to survive in your backpack (no, not some lightweight composite but backpack and clothing from linen and wool) and seeing how a forest looks if it is let to grow in the way the german forests frightened the roman legions in ancient history (trees as high as houses, growing so dense to each other that even in the middle of day one is walking in darkness (there are still a few places like that e.g. in Blackwood Forest) and enormously restricting underbrush and rotting trees laying left and right one needs to imagine Forests back then more like the obstacle path from American Gladiators with clear pathes through it rare and those existing winding their way confusingly...

Horse rider has bigger problem in forest. For sure he can not move as freely as on open plains.

A horse rider can ride nowhere "freely". A fox hole or some mole or prairie dogs holes could be quite camouflaged in the grass on a rolling prairie or plains and break a horses legs if a rider thinks he can safely race his horse over that land. While "a rider" suffers restrictions in a forest (in the worst case halving his speed as he has to walk and guide his horse) that is much more punishing for a unit of riders that tries to find it´s way through and is either snaking on a small path one behind the other or spread and dispersed to be nearly ineffictive if attacked.

...
Overall I think :
person should move 1 tile on flats, 1 tile in light forest, 2/3 or 1 tile in forest, 1/2 tile in jungle, 1/2 tile on hills, 1/4 tile on peaks
horse rider should move ... 3 tiles on flats, 2 tiles in light forest, 1.5 tiles in forest, 1/2 tile in jungle, 2 tiles on hills and maybe 1 or 1/2 tile on peaks (but only scouts can move there)
(I also very much don't agree with current version, where scout have 2 movement speed, while dragoons have 3)

So maybe flats - 1 cost
light forest - 2 cost
forest - 3 cost
jungle - 4/6 cost
hill - 2 cost
peaks - 4 cost
foots - 1 speed, double move forest, dobuble move jungle
horse - 4 speed? But -50% in jungle? Or .... 2 speed, double move plains, double move hill/peaks... I don't know ...
Then double moves from promotions could be ditched all together. They would be only obtainable by "having" or "not having" horses. I also don't really like -1 terrain movement cost bonuses. -1 is arbitrary number... 2->1 makes huge difference, 4->3 almost none... also it does nothing on plains 1->1 . IMO - It is totally messed skill effect.

Yet it does make practical sense. Someone who has much experience with travelling through forests has an easier time moving through that forest than someone who hasn´t.

I imagine peaks as mountains, it wouldn't be really impossible/or even hard to move on horse, tho it would very much depend on what mountains are we talking about. Most moutains are not too crazy and they usually have some trails.

Depends what a mountain is. In my opinion for example anyhthing in the Netherlands is a mole hill and anything on the British Isles are just foothills (including Snowdon with 1000 metres and Bein Nieveis with 1300 metres). Mountains are the spine of the Rocky Mountains and the highest of the Appalachian range.
 

Buffalo Solider

Chieftain
Joined
Aug 11, 2016
Messages
37
Maybe non-mounted units should have double movement in forest?
I think you miss-understood my intention behind this. I didn't wanted units to have two moves in forest (currently this is what happens to units that have 1 MP and double move in forest), but I thought maybe after movement rework it would finally work properly (so 1 MP in forest = move, wait, move, wait. So 1MP + double move in forest just gets to move once per turn instead (in light forest) )
I think in light forest it makes sense, as there isn't really anything that slows footsman here. As for regular forest, I thought maybe that unit should move 2/3rd tile per turn, or cost 1.5 of movement points -> (move,pause,move,move,pause,mmpmmp ...) 1/2 tile per turn would also make sense.

It was kind of begining of my thoughts on topic, and I imagined having regular colonist treversing forest at speed 1 tile per 2 turns, while scout would just zoom through it without any slow down (because he probably has some nonsence -1 terrain movement cost), and I thought - there's no way that horse could move even at equal (to colonist on foot) speed in forest where there is no roads, or anything.

I think base double movement in forest for foot colonists is good as "workaround", so that there's no need to bend any rules (by hardcoding something, or whatever). Units on horses would just "not have it" and so they would be the ones who are more heavily affected by forest terrain.

On the other hand, I think now of this wise statement :
Someone who has much experience with travelling through forests has an easier time moving through that forest than someone who hasn´t.
, I think maybe double movement in forest should be earned by those foot-units.. So maybe they shouldn't get it right from start. But then horse rider (with no forest experience) would still be faster in forest than foot-traveler... Ah, I don't know. Really some terrains (forest/jungle) would just require to have flat movement cost.. Doesn't matter if you use horse or legs, you will still have to use legs in this terrain.



I think it all might boil down to realism vs mechanics.. From game mechanic perspective terrain promotions are good for planning and strategy of game, but it wouldn't be very realistic to ever allow scout to move 5 tiles through forests and mountains, because he knows some founding father that gives him +1 speed, he has forced march 2 and explorer 2

Actually then more I think about all of this, then more I remind myself of video by lindybeige on transport/travel in older days...
Spoiler :
I think this creator is actually worth of recommending.
Over-all he talks mostly about river/road transport, though. Exploration and road building must have been really difficult tasks..

1. If you can go by waterway - choose waterway
Realistic exploration and travel system would be very challenging, so maybe I shouldn't think strictly about realism... But if I could change only 1 thing in game it would be to throw away -1 terrain cost modifier from any promotions :D Ignoring terrain is not immersive.
 
Last edited:

ConjurerDragon

King
Supporter
Joined
Dec 13, 2012
Messages
653
Location
Rhineland-Palatinate
...
It was kind of begining of my thoughts on topic, and I imagined having regular colonist treversing forest at speed 1 tile per 2 turns, while scout would just zoom through it without any slow down (because he probably has some nonsence -1 terrain movement cost), and I thought - there's no way that horse could move even at equal (to colonist on foot) speed in forest where there is no roads, or anything.

The only reason you could see it that way is if you reduce "Scout" to rider and "Colonist" to walker. However that is too simple.
A scout is a rider (or small group of riders) specifically suited for fast travel and exploration - so light baggage, everything he has is in his saddlebags.
That means he can be faster than say Cavalry, because it is not just another guy on a horse but a military unit that needs to coordinate it´s movements and which probably sets up a camp perimeter before nightfall when travelling as a military unit and probably brings a supply wagon with supplies and ammunition.

And e.g. a settler is not just another guy on foot but a whole family and all the tools and goods they need to start a new village.

I think base double movement in forest for foot colonists is good as "workaround", so that there's no need to bend any rules (by hardcoding something, or whatever). Units on horses would just "not have it" and so they would be the ones who are more heavily affected by forest terrain.

A rider could just dismount and lead his horse. There is no reason to make people on foot (that actually are carrying a lot of equpment) faster than mounted units in light forest.

I think it all might boil down to realism vs mechanics.. From game mechanic perspective terrain promotions are good for planning and strategy of game, but it wouldn't be very realistic to ever allow scout to move 5 tiles through forests and mountains, because he knows some founding father that gives him +1 speed, he has forced march 2 and explorer 2

Why not?
Imagine a greenhorne that just dropped from the Mayflower and al the botanics and geography he is used to is the green shires of England. Set him on a horse for the first time and he will be a very slow and cautious scout, unused to the peculiarities of pre-colonization forests and with raw skin after a few hourse in a saddle.

On the other hand an experienced scout with several promotions is probably someone like "Old Shatterhand" or Grizzly Adams - a guy who lived for decades in the Wilderness, who knows every track of every animal and their pathes through the underbrush, knows the ways the natives use, who knows the area by heart and memorized every creeks turn and every ford across the rivers. Who has the condition to ride a whole day of 24 hours and the night too if necessariy as long as he has a spare horse.

Actually then more I think about all of this, then more I remind myself of video by lindybeige on transport/travel in older days...
Spoiler :
I think this creator is actually worth of recommending.
Over-all he talks mostly about river/road transport, though. Exploration and road building must have been really difficult tasks..

1. If you can go by waterway - choose waterway
Realistic exploration and travel system would be very challenging, so maybe I shouldn't think strictly about realism... But if I could change only 1 thing in game it would be to throw away -1 terrain cost modifier from any promotions :D Ignoring terrain is not immersive.

Which is why there was a discussion to add canoes to units travelling along rivers as a "normal speed" way to travel while travelling through Wilderness without any road or path would be very slow.
 

PlanarFreak

Chieftain
Joined
Jul 11, 2013
Messages
30
Location
USA
Interesting idea... if this moves forward, I wonder if terrain movement cost might be adjusted? To some extent, the debilitating 3 MP for Jungle is offset by the fact that you can move at least 1 tile per turn. So to have similar balance as we currently have (or some other desired balance): 1. proportionally reduce rough terrain movement cost, or 2. increase baseline movement speed and proportionally increase rough terrain movement cost.

Edit:
Another consideration with movement... If you are tracking fractions, is it possible to add logic for longer diagonals?
 
Last edited:

codiac

Chieftain
Joined
Oct 15, 2022
Messages
29
FWIW I have been playing with the new movement system. It's obvious impacted by the pathing not adjusting to it yet, but even with that I only found 2 things to be frustrating.

1. Early on I like to micromanage my scouts to make sure they visit local villages and goodies.
2. I like to micromanage my pioneers to make sure I get the upgrades and roads I want in the order I want them.

I gave them both an extra movement point and decreased the build cost of each tier of roads.

I sold myself the movement cost by telling myself that both of these classes should be better at moving in harsh terrain than other units are :cool: I sold myself the road build cost change by accepting I can be impatient :lol:

I have found myself using ships more to move my attacking units around, and I've started building roads to make minimize rough terrain in preparation for attacks. In one instance I built a road across some native land to a computer player and the AI used that road to attack me ... how rude!
 

raystuttgart

Civ4Col Modder
Joined
Jan 24, 2011
Messages
9,150
Location
Stuttgart, Germany
It's obvious impacted by the pathing not adjusting to it yet,
It is still on the todo list, simply not yet implemented. :sad:
2. Pathfinding for new Movement Cost System
I still hope I will find some support with this. :dunno:

-----------

I gave them both an extra movement point and decreased the build cost of each tier of roads.
Actually I was instead considering to give all Units double the Movement Points.
So Terrain would matter much more but Units could move generally relative fast (e.g. on Flatland).

But I am simply not yet at the point where I could or want to start such balancing discussions.
Simply because I have not yet played a single game with the branch myself - too busy investing my time into modding.

-----------

The main reason for this feature was simply:

I wanted players to actually consider how to move through Terrain and Terrain Features.
Moving onto a Mountain / inside a Jungle instead of moving around should come at some cost.

e.g. the "Mountain Hoping" (with last move on a Peak) because of the View range is completely unimmersive.
Still it was almost the best way to explore and came with almost no downside (since it was last move anyways).

There was no decision making involved anymore.
Simply because there was just a single "best choice".
 
Last edited:

codiac

Chieftain
Joined
Oct 15, 2022
Messages
29
Hi Ray! No one will be able to really see how it will work out, or what will need to be tweaked, until the pathing is adjusted, but if people know I was happy with just a small tweak it might be useful.

I haven't worked out how the pathing works yet so I can't guess how hard that will be.
 

raystuttgart

Civ4Col Modder
Joined
Jan 24, 2011
Messages
9,150
Location
Stuttgart, Germany
No one will be able to really see how it will work out, or what will need to be tweaked, until the pathing is adjusted ...
I agree, but we are still in alpha phase and thus are a few open todos that simply have not yet been done. :dunno:
Once we are in beta phase we will worry about fine tuning and balancing but we are simply not yet at that point.

Currently the internal development is not intended to be "played".
It is intended to be used for implementing content and bugfixes.

So please stay patient. :thumbsup:
 
Last edited:

raystuttgart

Civ4Col Modder
Joined
Jan 24, 2011
Messages
9,150
Location
Stuttgart, Germany
Hi @devolution, hi @Nightinggale,

currently the game "generally" supports both "New Movement System" and "Classic Movement System".
(It is possible to switch by GlobalDefine: USE_CLASSIC_MOVEMENT_SYSTEM)

But Pathfinding currently only supports "Classic Movement System".
Is it possible to have it support "New Movement System" as well?

----

If the effort to support both is too big, I would rather throw away "New Movement System" - instead of not having Pathfinding support for it.
It is a cool new feature in my eyes because it requires more thinking and decisions, but I do not like to have features only half implemented.

Please give me some feedback on the effort to adjust Pathfinding to support both.
Of course every support implementing Pathfinding adjustments would be highly appreciated.

Best regards
ray
 
Last edited:

Nightinggale

Deity
Joined
Feb 2, 2009
Messages
5,032
Is it possible to have it support "New Movement System" as well?
Yes. It is technically possible as pathfinding is done entirely in the DLL. How? Beats me. That would be pending investigation. I haven't looked into our new Kmod pathfinding addition.

In theory it should be a more simple task to find the shortest path as it shouldn't consider the unit's movement points and instead just add up cost for the entire path. The question is where the code for this is located and how to do it in a way, which won't kill performance. If everything else fails from a performance point of view, we can make it pick at compile time and that way optimize the code to be the most efficient for each case.

However as luck would have it, I'm currently working on caching the data from GlobalDefinesAlt.xml and it will benefit cases precisely like this one. This means it will make the most sense to ignore pathfinding for now and finish the cache first and then have that extra ability to rely on when looking into pathfinding costs.
 
Top Bottom