News:

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

Proof of concept: one-way, two-lane avenues?

Started by isidoro, December 08, 2011, 11:31:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

isidoro

Thinking about the recurrent idea of building "real" one-way, two-lane avenues, I was wandering if the concept is, in fact, very different from that of overtaking.

When I started developing the overtaking patch, the concept was very simple.  Overtaking was, in essence, "temporarily drive on the left".  ST was then prepared for vehicles to drive on the left.  Therefore, the patch only had to do this:

       
  • If a vehicle would be forced to stop because other slower one was in front of it, it checked if it was safe to overtake (no facing traffic, only one vehicle in front, etc.). Then,
  • ST calculated how much time it would take to overtake, considering the speed of both vehicles. Then,
  • The vehicle was marked to drive on the left and, when the previously calculated time expired,
  • The vehicle was marked to drive on the right again.

I think the concept may be easily made more general.  One of these four classes can be associated to each road tile:

       
  • 0: overtaking not allowed (painted with a continuous line)
  • 1: overtaking allowed, traffic in both directions (present behavior)
  • 2: two-line one-direction free traffic
  • 3: two-line one-direction traffic, but vehicles must keep to the right as soon as possible.
The most difficult to program would be class 2, but to me it only means to allow overtaking but making the calculated overtaking time infinite and check once in a while if the vehicle can safely return to the right.  Also check if the vehicle reaches another one on the left lane and stop.

The class of the road will only take two bits for each tile.  Surely there would be some problems.  For instance, you have to combine the tile classes with signals (visible or invisible) to prevent traffic to enter in the wrong direction or the route finder find a route in the wrong direction.  Also, if one of those one-line roads ends, traffic may not go back...  To mention only two that come to mi mind.

What do you people that know the code internals think about this?


TurfIt

Implementation wise, for in-city multi-lane one-way avenues with intersections, traffic lights, halts, etc., I don't think the overtaking approach of pre calculating a clear road, then ignoring the normal tile by tile checks would give satisfactory results. Instead, further extending those checks (ist_weg_frei, no_cars_blocking) would be my approach.

I've already done some preliminary work on multi-lane one-way roads, but I was targeting creation of controlled access highways. Avenues could be an extension of that with much more logic added to handle intersections especially. But, of course that means I need to get back to working on it...

Speaking of overtaking, I'm ~80% done with extending the logic there to account for vehicle acceleration, more than one vehicle in front, and several other cases where overtaking would be possible but for the timid Simutrans drivers sticking behind the slow truck infront. With the patch, one-way signs preventing oncoming traffic, and no intersections, the vehicle behaviour is what you're calling class 3.

Dwachs

As a first step it would be nice to have class 3 implemented.
Parsley, sage, rosemary, and maggikraut.

Fabio

But would these classes be inherent to the road object (in dats) or simply triggered by signals?

I hope the former, but how could you set the direction of the road?

ojii

Quote from: fabio on December 09, 2011, 08:45:54 AM
But would these classes be inherent to the road object (in dats) or simply triggered by signals?

I hope the former, but how could you set the direction of the road?


Not sure if simutrans can do this, but would it be possible to have the waybuilder actually build both lanes? This way one could just check for 'drive on left/right' to determine which way is which. Obviously this would force players to build the dual lane avenues/highways with both lanes always right next to each other, which might feel a bit restrictive...

Otherwise, how about adding arrows every n tiles, which can be switched using signals, and by default the direction in which the road is "painted" is taken?

Markohs

#5
Can't this be solved by making the way building tool, when dealing with 2 lane contruction ALLWAYS build 2x2 blocks? That whould solve the problem of dead-end ways being reversable and forcing the direction of the lanes automatically. That also marks the lane to be of they type 2 isidoro menctioned.

EDIT: And yea, refering to what fabio menctioned, they should be different .dat entries than normal city roads, we'd have:

1: two-way single lane city road. (maybe here no overtanking allowed)
2: two-way single lane roads (with various speeds, with overtaking)
3: two-way double lane city AVENUE. (free driving and lane choosing on vehicles)
4: two-way double lane highway. (driving on the right prefered, but overtaking as soon as possible).

This opens the door to make richer graphics for city avenues, with place for pedestrians and good decorations on the separation between both lanes.

Fabio

Quote from: Markohs on December 09, 2011, 11:33:08 AM
Can't this be solved by making the way building tool, when dealing with 2 lane contruction ALLWAYS build 2x2 blocks? That whould solve the problem of dead-end ways being reversable and forcing the direction of the lanes automatically. That also marks the lane to be of they type 2 isidoro menctioned.

Wow, this would be just great!

Markohs

As a sidenote, this scheme whould allow a implementation of roundabouts to solve intersections, with something simiular to this:


Isaac Eiland-Hall

Going back to the idea of limited-access highways....

If this is all successful, I'd like to throw out an idea: Access ramps. Right now, when I build my fake freeways, a full-sized road is needed for entrance/exit ramps; but if there will be rules in place on how to treat streets when building an avenue/highway, perhaps something (I have some possible ideas, but don't know what the code will support) that will enable a special road to connect with what appear to be angled ramps, with a single lane...

Václav

Isaac, idea of highway entrance/exit ramps is nice (and I would like to support this too) - but I am worried about that it would be difficult - owing to that in queue of currently available graphics of roads is nothing usable - or my imagination/fantasy (I am really not sure what word is more suitable to this place  :-[ ) is very short :o

Chybami se člověk učí - ale někteří lidé jsou nepoučitelní

Fabio

Graphics is the easiest of issues: they can be painted

Isaac Eiland-Hall

I imagine that if a system enabling access ramps was created, someone would paint graphics for it. :)

isidoro

Quote from: TurfIt on December 09, 2011, 03:55:36 AM
[...]I don't think the overtaking approach of pre calculating a clear road, then ignoring the normal tile by tile checks would give satisfactory results. Instead, further extending those checks (ist_weg_frei, no_cars_blocking) would be my approach.

I agree.  In fact, this new, more general approach would also benefit the overtaking code:  present code ends overtaking when the precalculated time expires.  If that is changed, overtaking may be chained, for instance.

If I recall it correctly, there was a flag is_overtaking.  Now it would mean is_on_left_lane.  And this, combined with the class of the road, would make all the logic feasible.

Quote from: fabio on December 09, 2011, 08:45:54 AM
But would these classes be inherent to the road object (in dats) or simply triggered by signals?
I hope the former, but how could you set the direction of the road?

A combination of both: the tile would mark if overtaking is possible/impossible/safe and graphics would mark it with usual lines painted on the road.  But tiles remain bidirectional.  You say what direction is used with the help of signals at the entrances/exits.  Furthermore, some special signals marking a direction could paint the corresponding arrows on the road and serve for vehicles to follow the right direction and not turn back.

Quote from: ojii on December 09, 2011, 10:21:49 AM
Not sure if simutrans can do this, but would it be possible to have the waybuilder actually build both lanes?[...]

My opinion is that that should not be enforced.  That way, the player is free to temporarily separate both roads to avoid a park, for instance.

Quote from: Isaac.Eiland-Hall on December 09, 2011, 04:39:29 PM
[...]Access ramps. Right now, when I build my fake freeways, a full-sized road is needed for entrance/exit ramps;[...]

Technically I think that this is quite feasible: roads (for cars) with the behavior of railways:  one direction per tile.


Václav

#13
... of course that it can be painted. It means probably more graphics against basic roads. Left handed stripe, right handed stripe (from view of player of game, of course) - and bridges and elevated ways for them ... for connection of roads that are not in the same level.

... and I forgot on something - busstops - because these roads would may be finally used for creation of busstops out of main stream of transportation.

Chybami se člověk učí - ale někteří lidé jsou nepoučitelní

Fabio

Vaclav, I see your point. Probably the new graphics should be incorporated in the existing objects, so that the menus would be pretty much unchanged, whereas new graphics would appear according to the context.

Isaac Eiland-Hall

Have we discussed sub-menus? It could really reduce the clutter in the large menus... Click a button, and a vertical set of buttons appears - maybe even 'squared' (i.e. 16 buttons would be 4x4 grid)

greenling

Isaac.Eiland-Hall
Your Idea with The Submenus be Great!
Submenus make the Mainmenu thin!
Opening hours 20:00 - 23:00
(In Night from friday on saturday and saturday on sunday it possibly that i be keep longer in Forum.)
I am The Assistant from Pakfilearcheologist!
Working on a big Problem!

Václav

Quote from: fabio on December 10, 2011, 09:24:54 AM
Vaclav, I see your point. Probably the new graphics should be incorporated in the existing objects, so that the menus would be pretty much unchanged, whereas new graphics would appear according to the context.
I did not talk about menu. I talked only about amount of new graphics.

But back to chief's idea of access ramps ... access points, if they would be built automatically, should not have form as is in SC3:


but it should have form of real road-highway access points - connection stripes (of length at least one tile before end, in game) as is on this picture
.

So, in this case I suggest free building by players.

Chybami se člověk učí - ale někteří lidé jsou nepoučitelní

jamespetts

This is a rather excellent idea - but I do wonder whether, in reality, there is the distinction suggested between classes 2 and 3; certainly, in the UK, the rule is as in class 2: one must use the left-most lane unless overtaking (with a few exceptions, such as right turn lanes, etc.).
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.

IgorEliezer

#19
First off, one-way-two-lanes would be a big relief for players who need to supply a pharmacy or a gas station in a downtown with all those traffic jams. I sometimes ended up building a railway to supply those small markets in the towns because buses and trucks used to lock the streets. But.... a railway here doesn't make some much sense.

Quote from: fabio on December 09, 2011, 08:45:54 AMBut would these classes be inherent to the road object (in dats) or simply triggered by signals?
I prefer by object, because player would intuitively try to build an one-way lane instead of placing a sign.

For now, considering the people's ideas (and Issac's too), these are the possibilities I could think of that could be combined depending on the need:

I) Number of lanes:
- Two lanes: both lanes have traffic
- One lane: one lane is used, and the other is unused (where grass or white strips could be painted).

II) Directions:
- Two-direction
- One-direction

III) Overtaking:
- Allow
- Disallow

IV) Player vs. Citycars:
- Free traffic: player vehicles and citycars can use both lanes freely.
- Separate: player vehicles always drives on main lane, and citycars always drives on second lane. (i.e. main lane = right lane in U.S. and left lane in U.K)








Quote from: fabio on December 09, 2011, 08:45:54 AMI hope the former, but how could you set the direction of the road?
Player could. The direction could be set by the clicks:

1st click -----------> 2nd click
Therefore, traffic goes W -> E

2nd click <--------- 1st click
Therefore, traffic goes E -> W

Now, how would the player see the directions of the way after he's done?

1) The graphics, depending on the pakset theme, he can distinguish by colors and strips.

2) Likely "Show/Hide reserved blocks" and "Show/Hide station coverage", Simutrans could use visual cues (arrows and colored tiles) to show the player directions, type of road and ownership (if the road belongs to him, someone else, or public service).

Isaac Eiland-Hall

Simcity4 shows arrows that point the way. Seems like another option for display. :)

Good job on the post, Iggor; I hope this idea does take off. :D

jamespetts

One issue is: how will the UI for building one-way roads work?
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.

Markohs

#22
Great job in your posts guys. Anyway I keep thinking two-lanes should be built only as a 4x4,4x6 or 4x6 when needed in a mandatory way, giving the chance to build one-way lanes be build manually when needed, will solve many usability problems, and those blocks can be used by cityrules easy, to avoid non-return lines. Just my thoughts, through. :) Applied to cityrules: they should be able to relocate citizens (build another building anywere else) and bulldoze the old building, to make room for new lanes.

EDIT: I'd take sim city 4 as a reference model too, was really easy to build in that game, and had lots of possibilities.

prissi

OpenTTD has also one way roads. They use an arrow for them. I suggest to use a dedicated graphics and maybe add 128 to the system type for one way ...



I think, one way roads with separate lanes for player and citycars are most easy (but they defy the meaning of citycars ... ). Any other system would require a lot of addition to ist weg frei, which is already eating a lot of performance now. Also the sorting of vehicles need to be changed on such roads or again lot of clipping errors become obvious with trailer trucks and the like.

TurfIt

Permanently displayed arrows on the road are rather ugly IMHO. I would rather have an arrow overlay displaying the ribis that can be toggled on/off as needed.

I'm still thinking highways instead of city avenues, atleast for a first crack. Is it cleaner to implement with system type, or just create a new waytype? A new waytype for highways, with access roads controlling the transition between waytypes seems better to me...

Separate player and citycar lanes turns citycars into eye candy only. They're supposed to be a nuisance when the player is badly serving the transport needs of the citizens. Pointless to implement this IMO, just turn citycars off instead.

ist_weg_frei isn't too bad CPU wise; Yet  ;) . Adding logic to handle city avenues would be a truly monumental undertaking. Having just recently overhauled the routine to better handle intersections, I think anyone attempting to expand this for multilane intersections will be in for a world of pain. Which leads me back to highways where there are no stops, no intersections, no crossings, ...

UI wise, freeform building is the only way. Other games that force placing of prefab 2x2 or larger blocks are always frustrating. The ribis could be set based on the order the tiles are constructed. i.e. Build tool for oneway roads would set the direction from first click to second (or along the drag direction). A separate tool to flip the directions of already build roads would be handy.

prissi

As long as there is no suitable ist_weg_frei, such construction is mood anyway. Imho, wether highway or not: The importance is free of crossings for that way type if ist_weg_frei is not to be touched. Maybe just a new way system type (16 or so) that forbids crossings with it and a second flag (system type 128) for one way.

Still I have troubles on how such a waytype would be allow to neglect any crossing checking and determines which lanes to use.

isidoro

As you talk deeply about the topic I get more and more lost.  My comments may be nonsense.  If so, please ignore...

If planned as a new waytype, would it be possible to join several roads to form a 3-lane, 4-lane, etc. highway?

Would the problem of crossroads be simpler if only T crosses are allowed?  In fact, in highways, usually there are only T crosses at entrances (two in, one out) and exits (one in, two out).  Besides, T crosses force the use of roundabouts, don't they?

Regarding Igor's idea of citycars-only lanes, there's something like that in real life: bus only lanes in some big cities (but don't usually apply to transportation of goods).

The idea of my class 3 type (go to the right asap) was to allow for easy transition to normal roads.


prissi

Any crossing needs to be considered for ist_weg_frei, same as for determining whch lane to chose. Without extending it any bet is off. However, three way crossings may only affect vehicles on the right lane (resp. left lane) and my be easier to implement.

Isaac Eiland-Hall

I definitely think users should be able to place single rows of one-way tiles (like we have now with road placement). If there's some other building mode that uses 2x2, that's cool too - but when building roads, I may want to separate the two directional roads.

I can't do screenshots at the moment because I'm in a rehearsal at the theatre (long times between sound effects, though. hehe)... There are several bits for inspiration and discussion:

Roads are placed similarly to Simutrans, though slightly differently. Single-clicking lays a single tile of road; because of Simutrans's history, it's different, but this is minor and no reason to change. But of course you can click-drag to place road. Simutrans having the ability to click-move-click is also nice.

Avenues are places in 2x2 sections, as has been discussed here. This is alright - it's certainly quick to place the roads, and the two one-way sides are automatic. Dragging an avenue over a road expands it to an avenue, with tiles on each end that convert to the road. This would be nice to have.

One-way roads are placed like roads, and here's something to consider: The direction is determined by the direction of the drag - and can be reversed by dragging the other way. This seems handy to emulate. I personally like the arrows on one-way roads. Some don't. So I recommend an overlay, like electric lines - but that can be toggled on or off like the tile grid. Maybe shift-6 - ^ - the caret? hehe

One concern has been the behaviour of citycars - randomly driving, wanting to turn right, being stuck in the left lane. Well, I for one will pay the price of watching the vehicle cut across traffic if needed. It's a small price to pay for having two lanes of traffic in the same direction. And we still have a bug where sometimes trucks/busses will stack on a single tile just after a curve anyway, so... minor point. :) There are a couple of other visual bugs that are subtle - and this is not criticism of the programmers in the slightest. Just a fact, and my entire point is that it's fine imho. :)

Here's a question: A suggestion was made to try highways first; then worry about city avenues later. Would this be a good step? I'm all for it, if so. I know there would be pressure to get avenues working if highways were done - but this is always true. We always have more ideas, no matter where things go. :)


mEGa

I have a graphic question (Is it too early ?) :
how to make a realistic connecting between acces-ramp and motorway line ?
At present -e.g. with pak128- we can create a approximatively junction with several roads  but not very realistic (see joined picture).
Could we build up this kind of connecting (named "New" on picture)? How vehicules runs on this ?


Current projects in progress : improvements of few designed french paks

Dwachs

Imho, this discussion turned into some kind of christmas wish list.

Discussion about graphics, UI, etc, are quite useless, if there is no single line of code written.

As soon there is a working implementation of what Isidoro called class 2 or 3 (if it were only for straight lines of road), one can start discussion UI issues.

@Isidoro: prissi was talking about extending the current way system-types (flat, elevated, tram) to have more flags like one-way, no-crossings.
Parsley, sage, rosemary, and maggikraut.

Isaac Eiland-Hall

Well, there probably has to be some sort of discussion about ideas and such; though of course there also have to be decisions made and code written before graphics painted. :)

An_dz

#32
I kept track of this discussion and think now I should give one idea. We could use layers, this way we can use less graphics and the game build the way. This gives the ability to have multiple waytypes with the same speed and texture. The idea will have a sub-menu, to work this way:
-You first choose the speed and texture
-Then choose what type it will be, one-way, double-lane, with or without overtaking, elevated or not, etc.


Explaining the image: (used 96.comic for fast image edit)
The 200Km/h road is chosen and the options are:
1- chosen as with overtaking. Other option will be no overtaking.
2- chosen as normal (right hand). Other options will be one way and left hand
3- chosen as normal road. Other options will be Right lane for player, Left lane for player and Both lanes for player.
4- chosen as both lanes. Other options will be no lane on right and no lane on left.
5- chosen as elevated. Other option will be normal (ground level).

An overlay with arrows will be the best solution. In video settings we could add the One-way arrows every N tiles. You could choose from 0 to 15, with 0 being none at all. In any option the arrows will show in crossings.


Isaac Eiland-Hall

Slightly off-topic, but if submenus become a reality, it really could trim up the menus - have road, elevated, and bridge all in one place :)

Graphically, I recommend a split isometric icon, because you need to show the direction of the road in N/S and E/W directions...

prissi

Sigh, this is getting to the extension request section again, as everybody just giving his wish and aparently nobody writing code for it ...