Latest Posts

Topic: Steep roads

mxb2001
Avatar
Joined: 2019-05-20, 18:49
Posts: 124
Ranking
At home in WL-forums
Location: The land of the thirsty spider
Posted at: 2021-06-18, 20:12

I have a question about steep (red and yellow marker) roads. The help says that the speed down is faster and up slower. Do they cancel out? Are all grades equal speed when traffic goes equally both ways? In other words does it take as much time to go back and forth over a green road as it does a red road?


--
To Boldly Go Where No Man Has Gone Before

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1433
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2021-06-18, 20:32

I've always wondered about this as well face-grin.png

According to the code, the walking-time along a slope (positive means up, negative means down) is calculated as

cost = BASE_COST_PER_FIELD * f

with

f = 1.0 + d(Slope) - d(0)
d = (Slope + SLOPE_COST_STEPS) * (Slope + SLOPE_COST_STEPS - 1) / (2 * SLOPE_COST_DIVISOR)

BASE_COST_PER_FIELD = 1800 ms
SLOPE_COST_DIVISOR = 50
SLOPE_COST_STEPS = 8

This gives the following results (in milliseconds):

-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
900 1008 1152 1332 1548 1800 2088 2412 2772 3168 3600

And the accumulated sums (ms):

0 1 2 3 4 5
3600 3636 3744 3924 4176 4500

Meaning that steeper roads are less efficient.

(The red slope indicator is used to indicate slopes of 4 and greater; green for 1 and less; yellow in-between.)

Edited: 2021-06-18, 20:35

Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 04:10
Posts: 1930
Ranking
One Elder of Players
Location: Germany
Posted at: 2021-06-18, 20:39

If I'm not mistaken this effect also occurs in real physics : )


Wanted to save the world, then I got widetracked

Top Quote
andreiosu121
Avatar
Joined: 2019-02-17, 04:31
Posts: 10
Ranking
Pry about Widelands
Location: Romania
Posted at: 2021-06-19, 09:49

WorldSavior wrote:

If I'm not mistaken this effect also occurs in real physics : ) Yes that is correct


Top Quote
the-x
Avatar
Joined: 2019-01-19, 13:23
Posts: 800
Ranking
One Elder of Players
Posted at: 2021-06-20, 17:43

Nordfriese wrote:

I've always wondered about this as well face-grin.png

According to the code, the walking-time along a slope (positive means up, negative means down) is calculated as cost = BASE_COST_PER_FIELD * f with ``` f = 1.0 + d(Slope) - d(0) d = (Slope + SLOPE_COST_STEPS) * (Slope + SLOPE_COST_STEPS - 1) / (2 * SLOPE_COST_DIVISOR)

BASE_COST_PER_FIELD = 1800 ms SLOPE_COST_DIVISOR = 50 SLOPE_COST_STEPS = 8 ```

This gives the following results (in milliseconds):

-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
900 1008 1152 1332 1548 1800 2088 2412 2772 3168 3600

And the accumulated sums (ms):

0 1 2 3 4 5
3600 3636 3744 3924 4176 4500

Meaning that steeper roads are less efficient.

(The red slope indicator is used to indicate slopes of 4 and greater; green for 1 and less; yellow in-between.)

We can extend such interesting logical things. I like them very much and it gives a good gamneplay though its very easy change but moving speed.


Top Quote