The International Simutrans Forum

 

Author Topic: (wishful thinking) multi-tile structures behaving like other objects.  (Read 9437 times)

0 Members and 1 Guest are viewing this topic.

Offline Leartin at

  • Devotee
  • *
  • Posts: 1196
  • PAK-DEV P192C
  • Languages: DE, EN
In Simutrans, it is possible to build a roundabout. Just build a 3x3 square way and put one-way-signals on the corners, entering/exiting roads on the sides. Simutrans knows how to deal with that construction, everything is fine, right? (well, it can cause a deadlock and until recently might crash the game, but leave that aside for now)

What I'd like to do is create a 3x3 object which looks like a really nice roundabout, and behaves just like the construction I described above. Whenever a route is calculated, the game only sees normal ways with one-way-signals, and the middle is just occupied. The only difference is that if you try to delete one tile of the structure, the structure is gone, leaving roads and signals behind, so actually just the graphic is deleted, not the functionality beneath it.

I chose the roundabout as an example since I think it's best to illustrate the advantage even without showing an image. Just try to imagine what a roundabout would look like if you buildt it with normal roads, but somehow deleted the inner lane of the circle (since no car goes the other direction it's not needed) and not showing one-way-signals, and it's already a lot nicer. Add some roundabout-signs at the entrance, and decorate the "island" in the middle, and it looks beautiful already.

Some other ideas how to use it? Well, quite similar are one-way-roads. Currently, you can easily create functional one-way-roads just by placing a sign, but they still have two lanes, one of which isn't used. With a structure like I propose, you could have it include a piece of way and a one-way-signal, while showing the graphic of one lane. Keep in mind it's currently not possible to do that with road graphics because of map rotation - rotate twice and it's the wrong lane showing.

How about a big railway station that's both station and extension, consisting of two rails with stations already buildt on them, and the main building besides. Since it's only one graphic, you can surely make it look much more consistent than you can do with normal stations. And if you delete it, it just changes back to some normal stations and -extensions, behaving exactly the same.

The way I envision creating such structures is quite simple. For each tile, say which 'normal' object there is. Like this:
Code: [Select]
way[0][0]=somestreet[SE]
signal[0][0]=somesignal
this would behave as if on the northwest tile, there is a somestreet and a somesignal. When placing a way, it needs to be said in which direction it is connecting to get the right ribis, since otherwise they would just be unconnected dots. Since it's more or less a building plan, I guess each tile has to be buildt after the other, but only if it is possible. Since you can't place the signal without a way, you can't switch that order.

Graphics are defined normally, but probably per tile, not cut like with tilecutter - to get the behaviour with vehicles right.



Now I know this is a lot, especially since it works different than anything already in simutrans. Hence wishful thinking. But I'd like to know if it is even possible, maybe an estimation on how complicated it is, and of course hear what others think of the idea. Maybe someone can think of other uses where this might come in handy?

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5469
  • Languages: EN, NO
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #1 on: March 14, 2015, 12:29:58 PM »
Special-casing things like roundabouts will easily lead to messy and slow code. When contemplating ideas for a "next generation Simutrans", I have been thinking of a different way to do roads that makes it possible to define structures like roundabouts, slip roads (and junctions with limited turns in general) and variable number of lanes. It requires a different way of building things, more like Transport Tycoon than Simutrans. That also goes for roundabouts as well, although the bridges and old-style tunnels are also special in that case.

Offline Vladki cz

  • Devotee
  • *
  • Posts: 2628
    • My addons, mostly roadsigns
  • Languages: EN, CS
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #2 on: March 14, 2015, 12:49:01 PM »
The other lane on one way roads is not useless - can be used for overtaking.

Also for roundabouts, there already is graphics for that
sign: http://forum.simutrans.com/index.php?topic=9551.msg89780#msg89780
centre decorations: http://forum.simutrans.com/index.php?topic=11015.0

Offline Leartin at

  • Devotee
  • *
  • Posts: 1196
  • PAK-DEV P192C
  • Languages: DE, EN
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #3 on: March 14, 2015, 08:19:51 PM »
Special-casing things like roundabouts will easily lead to messy and slow code.

See, I actually don't want any special casing. As far as the code is concerned, it's just a normal roundabout, as if it would be buildt by hand. Actually, let's explain it like this:

As a developer, you create a structure by defining a build plan. Much like a macro, it just tells the game what to build where.
The player sees that structure as one Icon in the menu. Click on the icon, click anywhere on the map.
First, the game checks whether the structure fits, whether there is enough space.
Then, it builds all the objects defined in it's build plan.
As the last step, the graphics of the structure are drawn above whatever was buildt.

From that point onward, the structure just exist to remind the game there are alternate graphics in this place. So it's only called for map drawing and the deletion tool (since it's "on top" of everything else, it gets deleted first. Just like you delete stations before ways)- everything else, like wayfinding, simply ignores it. True, this is different behaviour than anything else in the game, thus a little special, but I suppose that's not what you meant.


Let's not focus on the roundabout too much, I just thought it would be a good example. Others would be big way crossings (highway cloverleaf. Or a rail crossing - would be usefull even without special graphics), a complex station forecourt for a terminus, two-tile ramps for elevated ways,... well, some of those would require the structures to elevate the ground. Still, I'm sure there are a lot more examples on what you could do with that stuff, to both make it easier to build for players and nicer looking as well.




(Actually, it would even work without alternate graphics, since you could theoretically define other objects with just the right graphics for your structure and define no icon. This would lead to masses of incomplete ways and stuff, and i think it would be very messy down the road, much like japanese add-ons. But it would work)

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5469
  • Languages: EN, NO
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #4 on: March 14, 2015, 09:52:59 PM »
See, I actually don't want any special casing. As far as the code is concerned, it's just a normal roundabout, as if it would be buildt by hand. Actually, let's explain it like this:

As a developer, you create a structure by defining a build plan. Much like a macro, it just tells the game what to build where.
The player sees that structure as one Icon in the menu. Click on the icon, click anywhere on the map.
First, the game checks whether the structure fits, whether there is enough space.
Then, it builds all the objects defined in it's build plan.
As the last step, the graphics of the structure are drawn above whatever was buildt.

From that point onward, the structure just exist to remind the game there are alternate graphics in this place. So it's only called for map drawing and the deletion tool (since it's "on top" of everything else, it gets deleted first. Just like you delete stations before ways)- everything else, like wayfinding, simply ignores it. True, this is different behaviour than anything else in the game, thus a little special, but I suppose that's not what you meant.


Let's not focus on the roundabout too much, I just thought it would be a good example. Others would be big way crossings (highway cloverleaf. Or a rail crossing - would be usefull even without special graphics), a complex station forecourt for a terminus, two-tile ramps for elevated ways,... well, some of those would require the structures to elevate the ground. Still, I'm sure there are a lot more examples on what you could do with that stuff, to both make it easier to build for players and nicer looking as well.




(Actually, it would even work without alternate graphics, since you could theoretically define other objects with just the right graphics for your structure and define no icon. This would lead to masses of incomplete ways and stuff, and i think it would be very messy down the road, much like japanese add-ons. But it would work)

Well, the special casing was just the unavoidable consequence that if one can build a roudabout or cloverleaf, it should behave like one. A circular road with one-way signs doesn't. If you build such a contraption yourself, you know what you build, but when using a standard build roundabout function, you expect a proper roundabout.

Offline Sarlock

  • Devotee
  • *
  • Posts: 1340
  • Languages: EN
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #5 on: March 14, 2015, 10:14:46 PM »
In order to behave correctly with graphics, one would need to define a "path" that the vehicles take across the new way graphic.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5469
  • Languages: EN, NO
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #6 on: March 14, 2015, 10:19:50 PM »
In order to behave correctly with graphics, one would need to define a "path" that the vehicles take across the new way graphic.

This was central in my "next generation" idea. It's completely different from how Simutrans works, so I don't think it can be retrofitted.

Offline Vladki cz

  • Devotee
  • *
  • Posts: 2628
    • My addons, mostly roadsigns
  • Languages: EN, CS
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #7 on: March 14, 2015, 10:28:45 PM »
See, I actually don't want any special casing. As far as the code is concerned, it's just a normal roundabout, as if it would be buildt by hand. Actually, let's explain it like this:

As a developer, you create a structure by defining a build plan. Much like a macro, it just tells the game what to build where.
The player sees that structure as one Icon in the menu. Click on the icon, click anywhere on the map.
First, the game checks whether the structure fits, whether there is enough space.
Then, it builds all the objects defined in it's build plan.
As the last step, the graphics of the structure are drawn above whatever was buildt.

The macro idea is interesting and might be helpful. However, I would omit the last step with alternative graphics. Just a pure macro that does a few steps that could be done by hand with already available graphics.

Offline isidoro

  • Devotee
  • *
  • Posts: 1129
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #8 on: March 15, 2015, 02:58:42 AM »
I don't understand it fully, but I see it in three steps:
  • Sets of complex objects "built in advance" that can be placed by the player anywhere without having to build them himself.  For instance, a highway intersection with adequate elevated ways, entrances, exits, etc.
  • The same as 1., but with different graphics.  For the game you have a structure "tilewise", but graphics are different.  Nevertheless, vehicles follow the same paths, rotations, etc. that would do in a normal structure (the model is the same, but the view different, in the Software Engineer parlour).
  • Fully fledged objects that can take vehicles and change their position and paths.  Much more complicated, but would give a lot of flexibility: special animated platforms for loading/unloading, parking lots, etc.
It isn't clear for me which of the three levels was intended by Leartin...

Offline Vladki cz

  • Devotee
  • *
  • Posts: 2628
    • My addons, mostly roadsigns
  • Languages: EN, CS
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #9 on: March 15, 2015, 08:23:37 AM »
I think that Leartin meant #2, but I think #1 would be interesting improvement by itself.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5469
  • Languages: EN, NO
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #10 on: March 15, 2015, 09:05:21 AM »
Objects are fundamentally tile-based in Simutrans, so #2 would necessarily degrade to #1, except that there are no tools for building the parts individually. Multi-tile buildings are multiple objects whos object descriptions point to the same building description, so they are sort of #1-ish. Off-shore industries take this one step further by being both a factory and a stop. The difference is that these are integral, and can only be removed as a whole as well (which is a case of special-casing).

Offline Leartin at

  • Devotee
  • *
  • Posts: 1196
  • PAK-DEV P192C
  • Languages: DE, EN
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #11 on: March 15, 2015, 08:02:56 PM »
I don't understand it fully, but I see it in three steps:
  • Sets of complex objects "built in advance" that can be placed by the player anywhere without having to build them himself.  For instance, a highway intersection with adequate elevated ways, entrances, exits, etc.
  • The same as 1., but with different graphics.  For the game you have a structure "tilewise", but graphics are different.  Nevertheless, vehicles follow the same paths, rotations, etc. that would do in a normal structure (the model is the same, but the view different, in the Software Engineer parlour).
  • Fully fledged objects that can take vehicles and change their position and paths.  Much more complicated, but would give a lot of flexibility: special animated platforms for loading/unloading, parking lots, etc.
It isn't clear for me which of the three levels was intended by Leartin...

Well, I'd love to have number three, but even though it's wishful thinking, I wanted to base the wish somewhere on the realm of reality, even if it's somewhere on the edge - so what I tried to describe was number two. Although I'd not intend to have alternate graphics for the tiles itself, but "place them on top" as an additional, multitile object (kind of like you could place way-objects on ways to change their graphic)

Multi-tile buildings are multiple objects whos object descriptions point to the same building description, so they are sort of #1-ish. The difference is that these are integral, and can only be removed as a whole as well (which is a case of special-casing).
You may think of it as such a multi-tile building which is placed over other objects, and drawn instead of other objects (similar to how ground is not drawn where a building is, unless the needs_ground-parameter is set). Just like multi-tile buildings, the structure can only be removed as a whole - but since the ways, signals and such are actually there beneath it, all this removing does is revealing what it looks like without the structures graphic. Just like the ground, which was not even drawn while a building is on it, is revealed the moment you delete the building.


I think that Leartin meant #2, but I think #1 would be interesting improvement by itself.

It certainly would be, and thus could be the first step of implementation.
But if you only do number one, I could already create my roundabout by cutting it in 9 parts and putting eight of them on a road-sheet as junctions and curves, it would look the same as with number two. However, if you delete one tile of it, two others would change to end-tiles, and everything would be ruined, looking all glitchy and stuff. To me, this is a problem, which is why I suggested the "full graphic replacement" - that way, removing part of it dissolved the fancy graphic first and leaves "normal" roads and signs the player already knows how to handle. That's far smoother and easier for the player to comprehend, I think.

Well, the special casing was just the unavoidable consequence that if one can build a roudabout or cloverleaf, it should behave like one. A circular road with one-way signs doesn't. If you build such a contraption yourself, you know what you build, but when using a standard build roundabout function, you expect a proper roundabout.

Really? Because I would not know what the difference between a simutrans roundabout and a real-life roundabout is, even if I buildt it myself. Unless you refer to right of way, in which case you should patch out junctions as a whole, they do not work like in real life either ;) As for the expectation, I'm sure at the very least upon deleting it and seeing the objects beneath it, it would be very clear to the user what it really is.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5469
  • Languages: EN, NO
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #12 on: March 15, 2015, 08:57:57 PM »
You may think of it as such a multi-tile building which is placed over other objects, and drawn instead of other objects (similar to how ground is not drawn where a building is, unless the needs_ground-parameter is set).

The only way for it to be drawn instead of another object, is to remove that other object. (Unless it covers exactly every pixel of that other object, but the other object would still be drawn, wasting CPU cycles. One of the platforms in pak64 does that to the track, which also makes it impossible to see broken tracks.) Simutrans' graphics system has been stretched to slightly beyond its capabilities as it is.

Really? Because I would not know what the difference between a simutrans roundabout and a real-life roundabout is, even if I buildt it myself. Unless you refer to right of way, in which case you should patch out junctions as a whole, they do not work like in real life either ;) As for the expectation, I'm sure at the very least upon deleting it and seeing the objects beneath it, it would be very clear to the user what it really is.

Players shouldn't have to delete things to figure out how they work!

Right-of-way is one of the things that wouldn't work as expected. True, it doesn't work on other junctions, but the right-of-way rules in junctions vary from junction to junction anyway. Roundabouts tend to follow just one system. Roundabouts can also become grid-locked, as you mentioned early on, because vehicles don't see it as a whole. Arguable, many motorist don't see roundabouts as a whole either, but I don't thing I've ever heard of a grid-locked roundabout. Third, the inner lane doesn't work.

Roundabouts are a bit odd to implement as multi-tile structures anyway. A 3x3 roundabout in Simutrans would correspond to something big like the magic roundabout. In fact, the junctions in Simutrans do behave somewhat like roundabouts, with the odd yielding pattern as an artifact caused by scale and a "simulation" of varying "aggressiveness" of the drivers.

Offline Leartin at

  • Devotee
  • *
  • Posts: 1196
  • PAK-DEV P192C
  • Languages: DE, EN
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #13 on: March 16, 2015, 10:21:27 AM »
The only way for it to be drawn instead of another object, is to remove that other object.
Sure, since nothing else was ever needed in the current range of objects. But I'm quite sure it's not impossible. Unless...

Simutrans' graphics system has been stretched to slightly beyond its capabilities as it is.
...unless this is as bad as it sounds. But if it is, what can be done at all, or does any further addition to the graphics system require it to be buildt anew?


Players shouldn't have to delete things to figure out how they work!
Not ideal, but neither should they have to ask on facebook to figure out how to build something in the first place (as it is the case with japanese addons right now).


Right-of-way is one of the things that wouldn't work as expected. True, it doesn't work on other junctions, but the right-of-way rules in junctions vary from junction to junction anyway. Roundabouts tend to follow just one system.

junctions as well as roundabouts work always the same. The car coming from the right gets priority (not in england, of course). This only changes if there are priority signs - which in case of roundabouts almost always exist (in Germany, the roundabout-sign itself is the priority sign) - I think it's unfair to say it would confuse players because there is not the correct right of way if there is no right of way in Simutrans in general.

Third, the inner lane doesn't work.
Which is not a problem, since I don't intend to have an inner lane, because there is no inner lane in any roundabout I ever drove through ;)

Roundabouts are a bit odd to implement as multi-tile structures anyway. A 3x3 roundabout in Simutrans would correspond to something big like the magic roundabout.
Some people want to believe every house is an area of houses, every vehicle is a fleet of vehicles, and everything is meant symbolic. If so, the small roundabout I would create to the liking of small roundabouts I know of (like this one, notice there is only one inside lane) can easily be symbolic for a magic roundabout. But I think the scale would fit quite good in comparison ot the size of the streets in general.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5469
  • Languages: EN, NO
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #14 on: March 16, 2015, 05:42:50 PM »
does any further addition to the graphics system require it to be buildt anew?

Not quite, but there isn't much room for change. It depends a lot on the change.

junctions as well as roundabouts work always the same. The car coming from the right gets priority (not in england, of course). This only changes if there are priority signs - which in case of roundabouts almost always exist (in Germany, the roundabout-sign itself is the priority sign) - I think it's unfair to say it would confuse players because there is not the correct right of way if there is no right of way in Simutrans in general.

My point is that I have yet to see a roundabout without a yield sign (or similar) on all entrances. On plain junctions, I've seen all kinds of combinations. So however vehicles happen to yield in a Simutrans junction will look like some real-life junction (perhaps mostly an all-way stop junction, but not quite), even if it constantly switches between different ones. A roundabout where circulating traffic yields to the incomming traffic half the time doesn't look like any known situation.

But I think the scale would fit quite good in comparison ot the size of the streets in general.

It fits the size of the street, and also the vehicles to some extent, but I have towns in my current game that are smaller than 3x3 tiles. And there are only four tiles between bus stops. Infrastructure occupies an disproportionate amount of space in Simutrans.

Offline isidoro

  • Devotee
  • *
  • Posts: 1129
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #15 on: March 17, 2015, 01:40:43 AM »
As to the roundabout topic, by the place where I live, the convention for all ways *was*, if no sign is present, that the traffic appearing from the right has priority.

Since roundabouts cycle counterclockwise here, if no sign is present, the convention *was* that incoming traffic to the roundabout has preference.

But at some time, some wise person in a dull office of The High Ministry of Transportation And other Movable Affairs came to think that that convention was a sure ticket to traffic jams and set a new law that from then on traffic inside roundabouts is the one to have priority.

But, since there could be people used to the old priority convention, they put signs on every roundabout to mark the new convention.  But, even if there was none, traffic inside roundabouts has now the priority.

Offline killwater

  • *
  • Posts: 221
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #16 on: March 17, 2015, 09:36:11 PM »
Is it possible to make a sign that grants entry to the roundabout only if there is an empty exit like for trains? This would solve the problem of jams probably.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5469
  • Languages: EN, NO
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #17 on: March 18, 2015, 05:56:05 AM »
Is it possible to make a sign that grants entry to the roundabout only if there is an empty exit like for trains? This would solve the problem of jams probably.

The problem with jams is not that there isn't an empty exit (which might change by the time the vehicle gets there), but that the roundabout is full. Road vehicles can only enter a tile unoccupied by vehicles moving in the same direction. They also won't enter a junction until they can exit it (although I think there are some glitches here). If a vehicle enters the last free tile in a roundabout (or any circular road structure, like the streets surrounding a city block) and all vehicles have more than one til to go before they reach their exit, they all get stuck.

Offline killwater

  • *
  • Posts: 221
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #18 on: March 18, 2015, 07:46:44 PM »
I mean it will grant entry only if the vehicle has exit free-there are no other vehicles on the roundabout. something like a presignal before entrance and a signal one tile after roundabout.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5469
  • Languages: EN, NO
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #19 on: March 18, 2015, 08:27:17 PM »
I mean it will grant entry only if the vehicle has exit free-there are no other vehicles on the roundabout. something like a presignal before entrance and a signal one tile after roundabout.

That would ruin the advantage of having a roundabout. In fact, it would perform much worse than a regular junction.

Offline Leartin at

  • Devotee
  • *
  • Posts: 1196
  • PAK-DEV P192C
  • Languages: DE, EN
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #20 on: March 22, 2015, 12:44:45 PM »
My point is that I have yet to see a roundabout without a yield sign (or similar) on all entrances. On plain junctions, I've seen all kinds of combinations. So however vehicles happen to yield in a Simutrans junction will look like some real-life junction (perhaps mostly an all-way stop junction, but not quite), even if it constantly switches between different ones. A roundabout where circulating traffic yields to the incomming traffic half the time doesn't look like any known situation.
While I can't find a picture to proof it, there definitely ARE roundabouts without yield signs. However, I think quite often they are not considered roundabouts, they just look like ones.
I think in Austria the concept of a "roundabout" does not exist in the first place, since our roundabouts all show a normal yield sign and a direction sign on each entrance, thus being buildt "from scratch", while in many other nations, there is an actual roundabout sign - so everything without that sign, even if the traffic goes circular, is not really a roundabout.
Either way, it's a personal preference anyway. Good thing the roundabout was just an example, and since you spend so much energy telling me why roundabouts are a stupid idea (with arguments all working on the early introduced roundabout signs as well), it stands to reason to assume that the actual suggestion can't be that bad ^^

It fits the size of the street, and also the vehicles to some extent, but I have towns in my current game that are smaller than 3x3 tiles. And there are only four tiles between bus stops. Infrastructure occupies an disproportionate amount of space in Simutrans.
A roundabout is infrastructure, why would you use any scale for it but the one of infrastructure?

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5469
  • Languages: EN, NO
Re: (wishful thinking) multi-tile structures behaving like other objects.
« Reply #21 on: March 22, 2015, 02:10:40 PM »
while in many other nations, there is an actual roundabout sign - so everything without that sign, even if the traffic goes circular, is not really a roundabout.

Norway has a roundabout sign, but that only means that you must drive anti-clockwise. A yields sign is always present in addition to give "proper" roundabout behaviour. (How to use the turn indicator is big debate, though, between those seeing roundabouts as a circular one-way road with many junctions, and those seeing it just as one special type of junction.)

A roundabout is infrastructure, why would you use any scale for it but the one of infrastructure?

It's just that infrastructure should become more compact. When roundabouts become bigger than supermarkets (in pak64 at least), bigger than some stations, and so big that bus stops immediately on either side barely cover it, it crosses the limit for my "suspension of disbelief". When the visuals is all there is to gain, and that fails, I can't see anything good in it. In addition, in pak64, having to go around the center can actually mean the difference between profit and loss for busses.