News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

One-way Two-lane road Fun Patch

Started by THLeaderH, February 06, 2017, 02:04:26 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Ters

Quote from: Vladki on February 09, 2017, 06:49:49 AM
If someone is about to stop, he should make it clear by blinking, but that is not possible in simutrans

No, but Simutrans vehicles can read each other's "minds". How easy it is to make the correct decision even then is another matter.

Andyh

I downloaded the patch yesterday and tested it. 


I created one way roads the normal Simutrans way (using the 'no entry' signs) and tested the new functionality using a variety of scenarios involving different types of road, and a mix of citycars and player vehicles.  This definitely seems to be an improvement on the old overtaking functionality.  Overtaking happened more frequently and there were occasional instances of multiple overtakes (but not very often). 


However, in most cases the scenarios eventually degenerated into slow moving queues of traffic in the right (slow) lane, with vehicles refusing to overtake one another.  Worse, when I set up a stop on a one way road, vehicles would soon refuse even to pass a stationary bus waiting at the stop, and a large queue of stationary traffic would result, even though the overtaking lane was completely empty. 


My guess at what's happening is that at lower speeds vehicles are struggling to achieve the 5 kmph speed difference with a vehicle in front and therefore cannot start to overtake. 


Here are some suggestions for improvement:


1. Consider reducing the speed difference required to start overtaking to 1 or 2 kmph (the risk of two vehicles ending up at the same speed side by side, as mentioned in this thread, based on my observations, seems minimal)
2. Consider changing the 'start overtaking' rule so that it compares the current speed of the vehicle in front with the theoretical maximum speed of the overtaking vehicle.  That's much more likely to result in a 5 kmph difference (and is much more realistic in my opinion)
3. Consider making the required speed difference a percentage (say 5%) of one of the vehicle's speeds instead of a fixed value.  That would make it easier for vehicles to initiate overtaking at lower speeds.
4. Consider relaxing the requirements for a vehicle to return to the right (slow) lane after overtaking.  Time and again I saw vehicles finish their overtaking maneuver too soon and get caught in a slow moving queue in the right lane.





jamespetts

These seem to be very sensible ideas.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

THLeaderH

Thank you for your testing and suggestions, Andyh!
I'm still working on solving the slow vehicle blocking issue. It is assumed that this takes a couple of more days to deal with, sorry :(
I'm planning to release a new version of patch and executable binary in a few days.

QuoteHowever, in most cases the scenarios eventually degenerated into slow moving queues of traffic in the right (slow) lane, with vehicles refusing to overtake one another.
In the current release of this patch, when vehicles on passing lane is blocked by another vehicle, the vehicle is forced to go back to traffic lane immediately. This is a bug of the current release. I'll fix it in the next release. (Actually this is already fixed in my code.)

Quote1. Consider reducing the speed difference required to start overtaking to 1 or 2 kmph (the risk of two vehicles ending up at the same speed side by side, as mentioned in this thread, based on my observations, seems minimal)
On congested roads (vehicle's speed is lower than a half of maximum theoretical speed), even speed difference == 0 is accepted to overtake. However, this condition does not seem to work efficiently. I'm still researching about this issue.

Quote2. Consider changing the 'start overtaking' rule so that it compares the current speed of the vehicle in front with the theoretical maximum speed of the overtaking vehicle.  That's much more likely to result in a 5 kmph difference (and is much more realistic in my opinion)
When road is filled with vehicles which have same maximum speed and there is traffic jam, moving to passing lane will not happen and passing lane will be  completely empty with the use of theoretical maximum speed in comparison. This is useless. Using current speed of vehicle in comparison is one of the essentials of this extension.

Quote3. Consider making the required speed difference a percentage (say 5%) of one of the vehicle's speeds instead of a fixed value.  That would make it easier for vehicles to initiate overtaking at lower speeds.
4. Consider relaxing the requirements for a vehicle to return to the right (slow) lane after overtaking.  Time and again I saw vehicles finish their overtaking maneuver too soon and get caught in a slow moving queue in the right lane.
Thanks but I'll consider about these later, sorry.

Andyh

Hi THLeaderH

Thanks!  I'm looking forward to seeing the next release!

I think you may have misunderstood my suggestion 2.  My idea is to compare the current speed of the vehicle in front with the max speed of the vehicle behind. Let's consider the following fact pattern:

Vehicle in front
Current speed    40
Max speed.         100

Vehicle behind (overtaking vehicle)
Current speed   44
Max speed        100

Under your rule the difference is 4 kmph (44-40) therefore no overtaking is initiated .

Under my suggestion the difference is 60 (100 - 40) therefore overtaking is initiated.

I feel this is more realistic because in real life a driver will more likely consider his potential speed not his actual speed when starting to overtake





THLeaderH

Oh I misunderstood your suggestion 2! Now I understand. Thanks ;)

Andyh

Just an idea.  BTW: thank you so much for working on this.  The overtaking issue has been one of my Simutrans 'pet peeves' for the longest time!

DrSuperGood

QuoteUnder my suggestion the difference is 60 (100 - 40) therefore overtaking is initiated.

I feel this is more realistic because in real life a driver will more likely consider his potential speed not his actual speed when starting to overtake
Problem is that the vehicle in front might keep accelerating and so reach 100 and the one behind could never overtake. One would have to purposely force the one in front to remain slow to allow for the overtake to happen successfully, which defeats the purpose of overtaking in the first place. In real life one should only overtake slow vehicles that are well below the speed limit.

Overtaking cars at the speed limit is pointless as it will at most decrease journey time by the distance of vehicles overtaken divided by speed. Over a 15 minute journey this can end up being a matter of seconds, not at all worth the risk of head on collisions.

jamespetts

Quote from: DrSuperGood on February 11, 2017, 04:46:11 AM
Problem is that the vehicle in front might keep accelerating and so reach 100 and the one behind could never overtake. One would have to purposely force the one in front to remain slow to allow for the overtake to happen successfully, which defeats the purpose of overtaking in the first place. In real life one should only overtake slow vehicles that are well below the speed limit.

The Highway Code does require drivers to give way to overtaking vehicles.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

THLeaderH

QuoteI think simutrans cars know that they are being overtaken, so they can behave politely and not accelerate until the maneuver is finished
In current release of standard simutrans, cars know that they are being overtaken. However, in this extension, cars don't know that for the complexity of calculation. In simutrans standard, cars are overtaken one by one, but in this patch, cars can be overtaken by more than one cars continually. So, I gave up to calculate whether cars are being overtaken or not. If it can be known that cars are being overtaken, not accelerate until the overtaking finished is very good idea, I think.

By the way, please take a look at this video :)
https://youtu.be/fBjXpdrWtO4
White bus - 85km/h, Blue bus - 130km/h

This is my answer for the "slow vehicle blocking problem". When a vehicle is on passing lane and there is a slower vehicle in front of it, the faster vehicle demands that the slower vehicle go to traffic lane. Then, the demanded vehicle asks the car on traffic lane to reduce speed 15km/h to make a room. You can see a bus on traffic lane reduces its speed and restore its speed after overtaking finished.

I'm still working for the case that a faster vehicle is on traffic lane and is caught by slower vehicles.

Tjoeker

first: thank you so much!  :) I've been waiting for this day for years now  :P

but I think 15 km/h is a bit much...
I think 5km/h or even 5% slower is better.
You can see these slow overtakes quite regularly.
When a truck is overtaking another truck, faster traffic is stuck behind the trucks for a while in real life as well..




Something related (I know it has been suggested before, but I believe now is the right time to ask again?):
the truck 'hitting' the back of the truck in front of him, decelerating to 0 km/h, accelerating again just to hit the truck in front of him again.. it's kind of sad to see.
I think if a truck can't overtake the truck in front (at that moment) it should adjust its speed to the speed of the truck in front.

Those two patches together would be really awesome :)

THLeaderH

Quotebut I think 15 km/h is a bit much...
I think 5km/h or even 5% slower is better.
You can see these slow overtakes quite regularly.
When a truck is overtaking another truck, faster traffic is stuck behind the trucks for a while in real life as well..

When I write this code, firstly I tested on 10km/h and it took too much time and distance in the simutrans map scale.
I know slow overtakes happen regularly in real life, but I also think it is not appropriate in simutrans world that difference speed is only 5km/h or 10km/h. In my test, 15km/h seemed the most natural in simutrans. To realize smooth overtaking, it may too late to start yielding lane after a faster vehicle is stacked behind.

Quotethe truck 'hitting' the back of the truck in front of him, decelerating to 0 km/h, accelerating again just to hit the truck in front of him again.. it's kind of sad to see.
I think if a truck can't overtake the truck in front (at that moment) it should adjust its speed to the speed of the truck in front.
In current simutrans, a vehicle which is blocked by other vehicle will restart at the 3/4 of current speed. Speed changes suddenly and this may makes you see that the faster car decelerate to 0km/h and accelerate suddenly. Although this issue is not directory related to this overtaking extension, it is worth enough to solve with!

killwater

Quote from: jamespetts on February 08, 2017, 12:30:38 AM
Currently, only one road vehicle can occupy a tile, but tiles are divided into (if I recall correctly) 32 steps for vehicles. Vehicles also have a length encoded into their .dat files of how many of these steps that they occupy. These two data together should in principle be possible to be the basis for allowing multiple vehicles to occupy the same tiles travelling in the same directions with accurate spacing, and would be a significant improvement in road vehicle handling in the game.
So in theory it should be possible to fit two vehicles in one direction and two in the other direction on one tile? Then we would need a separate graphics for 2x2 road on one tile, different graphic shift for vehicles and to discard overhead collision check when overtaking on this type of road?

jamespetts

I think that you may have misunderstood: I do not mean two vehicles heading in one direction side by side, but rather one in front of the other, as many vehicles occupy only a fraction of a tile's length, yet, at present, no vehicle may enter a tile in which another vehicle is present, even if the vehicle that is in the tile is occupying only a fraction of it.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

THLeaderH

#49
Here is a new release of One-way Two-lane road patch!
The patch file is attached as OTRP3.patch.
For Windows: http://www.filedropper.com/simwinotrp3
For Mac: http://www.filedropper.com/simmacotrp3

In this release, I wrote a solution for the "slow vehicle blocking problem". Also I fixed the bug that vehicles are forced to go back to traffic lane when vehicles are on passing lane and blocked by slower vehicles.

Please try and make a progress in the discussion!


The following is just for my note.

Changed files
simconvoi.cc
simconvoi.h
/vehicle/overtaker.h
/vehicle/simvehicle.cc
/vehicle/simvehicle.h
/besch/weg_besch.h
/besch/reader/way_reader.cc
/besch/writer/way_writer.cc
/boden/wege/weg.h
diff command : diff -u -r sim_original sim_changed > OTRP3.patch
patch command : patch -u -p1 -d simutrans-win < OTRP3.patch

killwater

Quote from: jamespetts on February 12, 2017, 12:31:32 AM
I think that you may have misunderstood: I do not mean two vehicles heading in one direction side by side, but rather one in front of the other, as many vehicles occupy only a fraction of a tile's length, yet, at present, no vehicle may enter a tile in which another vehicle is present, even if the vehicle that is in the tile is occupying only a fraction of it.
Then how is it possible to overtake at all?

Ters

Quote from: killwater on February 12, 2017, 11:03:24 AM
Then how is it possible to overtake at all?

It is possible to have two vehicles on the same tile, as long as it is only one in each lane. (I have heard of four vehicles side-by-side on a two-land road, but that was neither legal nor safe. And they were cars, and probably of the smaller kind, not trucks or buses. Simutrans is mostly about trucks and buses.)

jamespetts

Quote from: killwater on February 12, 2017, 11:03:24 AM
Then how is it possible to overtake at all?

I was not referring specifically to overtaking in that context, but rather to other, related possible improvements to vehicle movement.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

killwater

Ahh that is a shame. I hoped it would be possible to scale down the dual carriageway roads to just one tile wide with only dumping the collision check during overtaking. They wreck the cities and are 2km wide in standard and 250m in experimental. In reality 25-35m. It would compare better to the size of rail infrastructure better as well.

@THLeaderH
Could you post a youtube video with the updated mechanics?

THLeaderH

Quote
@THLeaderH
Could you post a youtube video with the updated mechanics?
Won't this video do? (I posted this video in a past post.)
https://youtu.be/fBjXpdrWtO4

If you want a video which describes mechanics totally about this extension, I'll do. However, it takes a couple of days because of my schedule :(

killwater

I meant one exactly like the one below, but with OTRP3.patch updates included. Maybe with some slower vehicles as well. If it is a lot of work then do not bother.
 

Tjoeker

I've been experimenting a little with multiple platforms in a row.
not that it's a big problem, but something we could think about..



The white bus arrived first.
The grey van has its stop on the third platform. overtaking is no problem.
But the red bus has to get to the second platform. (it can't overtake because its destination is only one tile ahead of the white bus?)

Like I said, not a big deal. But if it would be possible to have fully functioning busstations shaped like this, that would be really awesome

THLeaderH


Mr.Spissky

Where do I find the files to replace?

THLeaderH

@Mr.Spissky

The code of this extension is distributed as patch file.
The patch is attached to this message

An_dz

Quote from: THLeaderH on February 14, 2017, 08:19:29 AM
I made a video.
https://youtu.be/T_6ne8iIal8
There are visible bugs in 0:17~0:27 and ~0:47 in the crossings. Cars on the left lane enter the right roads crossing over vehicles.

Quote from: Isaac.Eiland-Hall on February 07, 2017, 05:49:26 PM
4. On distinguishing the roads - SimCity paints arrows on the tiles. Perhaps a partially-transparent overlay for direction would work. Or the road designer could do something like the mentioned guardrails on each side.
Crazy, something that in Brazil is more logical than in other places. Here a yellow middle line is for dividing opposite traffic directions, while white is for same direction. It's the same for the neighbouring countries and Canada.

killwater

Thanks. Comparing to your 【Simutrans】道路の追い越しの改善 video it looks mega awesome. Good work. I hope the patch will make it at least to the Experim... I mean to the Extended.

Andyh

I tested the latest version of the patch last night.  Definitely better (...and way better than current functionality) but still a few issues:

1. Still a problem with faster vehicles not initiating overtake of slow vehicles. This leads to queues of traffic building up in the right hand lane, even on one way roads.  On numerous occasions a high speed bus would get caught behind a horse and cart in the right hand lane of a one way road and would not overtake.  Traffic flow is improved by using the '80 kmph minimum speed' signs, but realistically you would think that a slower moving vehicle should be easier to overtake.
2. Overtaking of stationary vehicles at a stop has improved a lot, but sometimes a queue of stationary traffic still forms behind a stopped vehicle.
3. It appears to be a lot more difficult for a vehicle to initiate overtaking of a City car (especially a slow City car) than a player vehicle.  Is there something in the way City cars are coded that would make them more difficult to overtake?
4. As noted by An_dz there are some graphical bugs.  To me they seemed to occur most frequently when a vehicle was returning to the right hand lane after overtaking.

THLeaderH

Thank you for your helpful advices! I want to list up issues now I have.

1. Simutrans was updated to 120.2. The current patch cannot be applied to the new version of simutrans standard since the structure of files changed. Although it seems that there is no relations between new features of 120.2 and this extension, codes themselves seems to have been changed because of changes from German to English. So, I cannot simply replaces files. Since generally simutrans version 12X.X.'0' have severe bugs in many cases, I want to wait until the latest stable version is confirmed as a really stable version. Then, I will move the base of this extension to the latest release, but it must take a long time.

2.
QuoteCars on the left lane enter the right roads crossing over vehicles.
This is a bug and should be fixed. Vehicles entering road of the opposite side should check before crossing lane. I'm reading the code to search how to fix it.
In fact, vehicles entering right roads should go back to the right lane before changing their direction and this should be guaranteed when the vehicles start overtaking. However, in this patch, vehicles do not know when they can go back to the right lane and to know this is impossible. So, I think the best way to prevent this collision is to check before crossing lane.

3.
QuoteIt appears to be a lot more difficult for a vehicle to initiate overtaking of a City car (especially a slow City car) than a player vehicle.  Is there something in the way City cars are coded that would make them more difficult to overtake?
In fact, conditions to overtake city cars is not changed yet (still isidoro's condition) ! The new conditions for city cars should be written and I'm planning to do that, sorry.

4.
QuoteOvertaking of stationary vehicles at a stop has improved a lot, but sometimes a queue of stationary traffic still forms behind a stopped vehicle.
The cause of this is still in research. Maybe one of the causes is the condition of "safe space". This condition makes vehicles confirm that the opposite lane is empty for at least one tile in front and in rear when changing lane, but I think there is another and bigger cause of this problem.

5. In my editing code, overtaking vehicles which have larger power is now prohibited. (same power is allowed.) This will reduce the blocking by slow vehicles without ruining the aim of this extension.

One-way Two-lane road fun patch (OTRP) is still on development and there are so many things to be done so that this extension is integrated to simutrans standard or extended. I will continue writing the code until this patch is completed.

THLeaderH

Sorry for posting in a row. I forgot to say about the biggest problem now I have.
Please take a look at the video of this tweet.

Horizontal 4-lane road is no problem. On vertical 2-lane road, there are inappropriate overtaking when waiting for a red signal.

As is in real road, conditions for overtaking is completely different between on 2-lane road and on 4-lane road. On 2-lane road, isidoro's stricter condition is suitable and on 4-lane road my relaxed condition is suitable. I think there is no way to distinguish whether the road is one-way or two-way without using any signs or signals. My conditions of overtaking do not work on two-way road, but conditions of current standard simutrans make (almost) empty lane on one-way road.

As a solution, I want to use overtaking_info flag of roads. To keep compatibility, only strictly conditioned overtaking is allowed on existing road add-ons. Relaxed overtaking is allowed only on roads made newly as one-way roads. I'm writing a code to realize this.

Andyh

Quote from: THLeaderH on February 15, 2017, 06:24:51 AM


3.In fact, conditions to overtake city cars is not changed yet (still isidoro's condition) ! The new conditions for city cars should be written and I'm planning to do that, sorry.




Ah, that would explain a lot.  I had thought the new rule applied to both City cars and player vehicles.  Actually I think the new behavior is pretty good in the context of player vehicles alone, but I think the real boost in performance/realism will come if you were to extend to City cars too.

THLeaderH

Here is a new release of One-way Two-lane road fun patch (OTRP).
This time, I had a trouble in making a patch file. Diff command wrote all of the source files, not the differences! So, I distribute the source code as a zip file.

I stopped using File Dropper and started using Google Drive, so you can download the files whenever you want!

For Windows: https://drive.google.com/open?id=0B_rSte9xAhLDVGJOUk1lRTMwV3M
For Mac: https://drive.google.com/open?id=0B_rSte9xAhLDekRHWGttMWUwM3M
Source: https://drive.google.com/open?id=0B_rSte9xAhLDVWdWLWtpY09SOEU

Note: since this release, the base of this patch is simutrans 120.2.

In this release, overtaking vehicles which have larger power is prohibited to reduce the blocking by slow vehicles.
The main purpose of this release is upgrading the version of simutrans. There is no difference in the playing experience between OTPR3.
Be sure that simutrans 120.1.3 cannot be used for patching.


The following is just for my note.
Quote
Changed files
simconvoi.cc
simconvoi.h
/vehicle/overtaker.h
/vehicle/simvehicle.cc
/vehicle/simvehicle.h
/descriptor/way_desc.h
/descriptor/reader/way_reader.cc
/descriptor/writer/way_writer.cc
/boden/wege/weg.h
diff command : diff -u -r sim_original sim_changed > OTRP4.patch
patch command : patch -u -p1 -d simutrans-win < OTRP4.patch

An_dz

Use the latest trunk code from SVN. Most SVN clients have everything included, including patch creation. And it can almost always update your code automatically, and even when it can't it generally has a diff viewer that shows the conflicts. You can also use git if you prefer it. http://www.simutrans.com/develop/ for the SVN and Git addresses.

You just need to tell your SVN client to download revision 8077 - which is version 120.0 (on git it's commit ea08f1e) - then you can replace the files safely and can update to the latest changes with little effort.

It's also easier for the team to include the code, because you already removed all conflicts with the current code state.

killwater

Quote from: THLeaderH on February 16, 2017, 03:27:13 PM
In this release, overtaking vehicles which have larger power is prohibited to reduce the blocking by slow vehicles.

This sounds like a terrible idea. So a light fast bus will not be able to overtake a heavy lorry?

THLeaderH

QuoteThis sounds like a terrible idea. So a light fast bus will not be able to overtake a heavy lorry?
To say precisely, it's not the "power", but the "max_power_speed", that is the theoretical maximum speed calculated from its power and weight. So, in many cases, a light fast bus can overtake a heavy lorry.
The effect of this condition is that vehicles which have higher max_power_speed, that means they can accelerate more quickly, have priority in overtaking under the situation that all vehicles have the same speed limit.

QuoteUse the latest trunk code from SVN.
OK, I'll use the latest trunk code when releasing a new version :D