• Welcome to SC4 Devotion Forum Archives.

TE Lots, Transit Switches, and You :)

Started by mott, October 25, 2007, 02:47:59 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

mott

NEWS YOU NEED TO KNOW
---------------------
These are just some general bullet points that must be accepted and understood before proceeding:

* The "internal" map that the game simulators are using for themselves, would look almost exactly like SC Classic for DOS if you could see it.  Under the hood, this basic game engine has not changed since the beginning. 

* There are no diagonals in SimCity now, and there never have been.  There's no such thing as a Transit-Enabled lot, either.  These are mere display tricks.

* The game carries its own process scheduler, needed for DOS/Win31/9x support, which is why it can't spread across the cores of newer multi-core machines.  It appears to the machine as a single process that cannot be divided.

* The game gives the UI a generous amount of CPU time no matter what.  You can do something that causes the pathfinding and demand/desirability engines to fall into a near-infinite loop, and the UI won't "lag."  Just because your game *seems* to be running OK, doesn't mean it really is. 

* The simulators - pathfinding, demand, all of them - are "perfect."   If they are doing something "wrong," it is a result of wrong information being fed to them.

* Everything in the simulator is related to everything else in it.  If you aren't testing your mods/lots on a default installation with no plugins, played on "hard," you can't be sure you have a true sense of what they do.  The easier settings artificially inflate some of the simulators, and you never know what J. Random BATter is going to throw into a .dat file.  Test "clean."



NEWS YOU CAN USE: "THE RULES" FOR TE LOTS
-----------------------------------------

These are not *my* rules.  These are the *game's* rules.  Everything presented here is a direct, logical consequence of how the game works, due to behavior that is hard-coded in the EXE.  Arguing with the rules will not change them.  Knowing why they exist is essential.

If you follow these rules, you can use TE lots in appropriate situations, and they will not mess up anything else in your game or harm performance too badly (no worse than the Maxis ones do, anyway).

If you choose not to follow them, the resulting lots will cause *something* about the game to start going wrong.  Sure, the first one you plop may seem fine, and the second may seem fine.  As you plop more "bad" TE lots, the negative effects do not just add up, they *multiply*. 

As with all things that affect pathfinding, those "negative effects" usually manifest as errors in the demand/desirability/development engine, that lead to inappropriate development and serial abandonment.  All mods that lie to the simulators will usually end up doing that, one way or another.


So here they are - "The Rules"
If you bend these at all, there *will* be a price to pay somewhere, somehow.


1) One lot == One network == One travel type.
-----------------------------------------
The original design spec for Transit Switch lots never anticipated multiple travel types passing through the switch, and they cannot properly account for them.  Traversal Time and Capacity cannot be properly set on a multi-network TE lot.

* "One lot" means the lot you are making.
* "One network" means you can TE for regular rail but nothing else, road but nothing else, etc.
* "One Travel Type" means that if you TE for a network that allows more than one kind of vehicle, such as roads, you're going to have to "block" all but one of them from passing.  A "Bus Only" lot is OK; a "No Trucks" lot is not.  A TE'd rail station should allow freight or passenger trains to pass through, but not both.  It's OK to let other transit types (pedestrians, for example) into a transit station lot, but they *must* ride the transit. 

This is extremely important, for not adding compounding amounts of error into the pathfinder. 
Maxis/EA did not always follow this rule, and Sims walk through bus stops (for example) as a result.  This is bad in more ways than just looking stupid, but we'll get to that when we discuss performance


2) All paths across the lot must be equivalent. 
----------------------------------------------
Since only one kind of use was anticipated, the lot can have only one "travel time" across itself. 

* Parallel rails are fine, as long as they are the same length (and the same kind of rail; see rule 1). 
* Think carefully before allowing multiple networks; it usually isn't necessary.
* Keep in mind that any vehicle entering a multi-path switch may "jump networks" inside the lot.
* Rule 1 still applies. 



3) If the lot is not square, it must only allow thru travel N/S or E/W, not both. 
-------------------------------------------------
This is a consequence of Rule 2.  Two paths of different lengths *cannot* be equivalent.  Therefore, they cannot be allowed.

* See the Transit Switch properties for the Maxis Elevated and Monorail stations for an example of how this is enforced. 
* Rule 1 still applies. 

Sims riding transit will also only be able to enter the Transit Switch from the chosen set of directions, so the player must provide a path to allow this.  NAM puzzle pieces (such as GLR-on-PedMall) are *very* useful for this purpose.  We need a set for heavy rail, too.




4) If the lot contains a TE'd intersection, it must be no larger than the intersection, and both networks should be the same type. 
----------------------------------------------
This again is a consequence of the other rules about equivalent-paths and traffic-tracking.  however...
By Maxis convention, when two different types of network intersect, they are both assigned the travel time of the faster network on that tile.  Therefore, if the TE lot is nothing but the intersection, the travel time is equivalent in all directions.  It's OK to intersect street with road, etc. in this case.

* Intersection plops are generally a bad idea to be avoided, but people making bus-only lanes may find such lots useful, and should know that it's OK in that specific instance.  It's not much worse than a Maxis El station.  If the intersection lot is also a station, so much the better.  Just try not to do this unless really, you *have* to.
* Rule 1 still applies.


NOTES:
------
* The Maxis Monorail and Elevated stations can meet the above list of conditions.

* The "Big Dig" lots, assuming that they only allow cars to enter, are another "acceptable" (and brilliant, IMO) example of "proper" TE lot use. 
Those lots are a little big for Transit Switches, but as long as the player is aware of the CTD issues with puzzle pieces, no harm done, and they are tune-able.  The "Dig" is *good* in a lot of ways that will become apparent over the next few posts.



mott

WHAT TE LOTS ARE
----------------

What you see on the screen in SC4 isn't always what you get.  Diagonal networks and Transit-Enabled lots are two good examples.   

A "Road Top Bus Stop," on the game's internal map, looks exactly the same as a regular bus stop.  There is no road under it or on it.  The road ends, there is a bus stop, and the road begins again on the other side.  It looks like a continuous road to the player, but it isn't one, and the simulators themselves know it. 



WHY PUZZLE PIECE HOVERS OVER TE LOTS CAUSE CRASHES
---------------------------------------------------

What the player sees as a "TE lot" is the result of some special coding overrides in the lot, that lie to the network and automata *display* processes.  This way, they are "tricked" into drawing a continuous road for the player, with traffic, instead of displaying the ugly reality (a broken road with a bus stop in the middle of it).

These same lies cause the game to crash to desktop when someone hovers a "puzzle piece" over the lot.  The puzzle-piece preview thinks it's over a network (it believes the lie), so it goes looking for RUL tables so it can auto-orient itself.  Lots don't have the proper tables for this purpose; only networks do.  Null/random pointer, meet desktop.  This is not a "puzzle piece" problem, it's a TE-lot problem, and it's not solvable without modding the EXE itself. 

The underlying point is, the network doesn't *really* go through a TE lot.  That's just a clever display trick.  They're really just Transit Switch lots, like any other.



TRANSIT SWITCHES, EXPLAINED
---------------------------


Transit Switches were invented to solve a particular problem:  Sometimes a Sim has to get off a bus, and then walk back the same way he had just come, on the same street. 

The problem with that is, a simulated trip cannot backtrack.  The pathfinding system does not allow the same route to be traveled twice during a trip. 

The solution was adding the "Transit Switch" property to lots.  Lot-makers may recognize this as the one that makes a lot function as a bus stop or train station, by converting traffic from one form of transit to another. 

They also make the Sim "forget" how he got there.

When the pathfinder encounters a Transit Switch lot, it generates a new trip, from the lot to the destination.  This "new" trip is free to try routes that were already tried by the "old" trip.  That way, Sims can walk any direction when they get off the bus, and the backtracking problem is solved. 

mott

PERFORMANCE IMPLICATIONS OF TRANSIT SWITCHES
--------------------------------------------

Note the words, "try routes that were already tried."  T

Tranbsit Switches have potentially dramatic CPU-usage implications, because all the other possible routes are *also* still being tried.  These things can and do start multiplying the number of trips that the pathfinder must consider, for each such lot encountered. 

Or the other way: These things reduce (worst case, divide) the number of Sims that can be in a city, before the computer overloads.

For things like train stations and bus stops, this is a necessary cost of having mass-transportation options.  As long as the stations are next to (not on top of) the networks so traffic is not forced through them, the pathfinder can save CPU time (and find better paths too) by avoiding inappropriate Transit Switches.  That means more Sims and less "simulator lag."

Therefore, one of the first considerations of a transit switch, is that it should be *avoidable* if at all possible.  You do not want the pathfinder to enter it unless it thinks it has something to gain by doing so. 

The default Elevated and Monorail stations are therefore wasteful.  The only "saving grace" is that rail presents very few decisions to the pathfinder. Trains can only keep going forward until they hit a station or a track switch, and there just aren't any other options to consider.  The CPU overhead is relatively small.

On a road, *every* tile is potentially an intersection.  This makes calculating paths on roads a lot more time-consuming. 




IMPROVING TRANSIT SWITCH PERFORMANCE
------------------------------------

Computers are faster now, but they're not THAT much faster.  You cannot outrun exponential growth in CPU usage.  All you can do is try not to cause it.

The #1 best thing you can do as a first step, is to minimize the number of transit switches on the map.  Every unnecessary one you take out adds more Sims to the city before it goes into the inevitable "grind."  It's unavoidable with actual transit stations, but anything else, if it can be done another way, it should be. 

If a Transit Switch is avoidable, the pathfinder should avoid it unless it has some reason to consider changing transit modes.  Doing so saves a large amount of CPU time for every unnecessary one avoided.

Unfortunately, the game as-shipped does not exploit this possibility.  Even worse, it tries every Transit Switch it sees, and usually uses it (like when Sims get off the bus and back on again). 

This is the kind of thing people download pathfinding plugins trying to fix, but the problem is not in the pathfinding. 

If there was some way to tell the pathfinder that it takes *time* to wait for a bus at a bus stop, the stupid Sims would stay on the bus they were already on.  Pedestrians would go *around* bus stops, not through them, unless they wanted to ride the bus.

This is why the "Transit Switch Entry Cost" property exists.  It is not a "cost" in money, it is a cost in *time.*  Its purpose is to advertise to the pathfinding engine that it should not consider the transit switch unless it thinks it can save at least that much time by doing so.

Setting it to zero, as the default stations do, advertises to the pathfinder that it should *always* try the transit switch first, because it's a "free move."  The pathfinder is not stupid (far from it).  It is making the correct choice based on faulty information, and your Sims walk through bus stops as a result.


mott

CHOOSING A TRANSIT SWITCH ENTRY COST
------------------------------------
I am currently experimenting with proper entry-cost tuning, so this information may be refined in the future.  However, in principle, it should make a decent guideline set.

As noted earlier, the default Maxis stations do not have a "Entry Cost."  Therefore, when using custom stations that *do*, one must either patch all the Maxis stations to match, or use only matching custom stations.  This goes for *all* of them.  If you give a bus stop a cost, but not the train station, Sims will work very hard to avoid the bus stops and use the train instead.  It's all-or-nothing.

That said:

In a default Maxis game, the "time cost" of traveling 1 tile is (1/speed).
Therefore, the "time cost" of your lot, however many tiles wide it is, should usually be (tiles/speed).
But not always.  I'm still working on it...

I'll cover the two important cases now though:

* TRANSIT STATIONS:
-----------------
Pedestrians move at 3.5 kph by default, so to walk one tile takes a "cost" of (1/3.5).  Set a Bus Stop's "Entry Cost" to just over that, say (1/3) or 0.3, and pedestrians will not "cut corners" through that bus stop unless they are going to ride the bus.  Ever.  And Sims on the bus won't get off the bus unless it's their stop.

Since transit stations usually serve pedestrians, using a fixed cost of about 0.3 for *all* stations is appropriate, regardless of size.  Otherwise, it would privilege one station over another, based on size of station, and that's nonsense.  Sims shouldn't be allowed to walk through stations without riding anyway, although some of the Maxis stations do.  They shouldn't.

If the transit station is on-network, it becomes unavoidable, so Sims must then "wait through stops" on the El trains and Monorail.  Buses can't be made to wait through stops without littering the map with "bad" TE lots, so there has to be another way to avoid priviliging buses (such as slowing them down about 25% or so in the pathfinding plugin).

Unfortunately, it is impossible to model realistic "wait times" at transit stops.  The maps are just too small.  In 5 minutes, half the Sims could WALK off-map.  If we could play a whole region at once, it would be feasible.  But it's not.

In general: Stations should be just slightly slower than walking. 


* OTHER ON-NETWORK LOTS:
----------------------

In the case of a lot such as "Trucks Only," "Cars Only," and such that do not involve pedestrians, it is more appropriate to match the lot's Entry Cost to the time it would normally take to traverse the network.  The Maxis El-Sub transition piece would be an example of where this is appropriate.

To know what the "Entry Cost" is for the transportation networks themselves (so you can match your lots to them), all you need is a pocket calculator. 

Say you make a TE'd road lot that allows only cars to pass.  Cars go 31 kph on roads, so type in 31 into your calculator and hit the (1/x) button.  That's the "Entry Cost" of moving 1 road tile by car.  Multiply that by the number of tiles that the Sim must travel to cross your lot, and that's your Transit Switch Entry Cost.

You should also set the capacity to match that of roads, which is 1200.

The "Big Dig" lots, despite being technically stations, would be appropriately set this way because of their purpose.

In general: Entry Cost = (Tiles/Speed).  Network speeds (and capacities) are available in the Omnibus, the Prima Guide, pretty much everywhere.

mott

Tha's all I have.  If anyone can correct/contradict any of the above, maybe a programmer knows more specifics about A* CPU/RAM use than I do, then fantastic.  I should be pretty close though.

sc4luv2

Good Info. Was Readin' while you were postin'.  :thumbsup: Now should we move this?? to mod tutorials  ()meeting()
[

mott

Have some other informaed eyeballs look at it, especially wouaningaine (sp?)... give it a "peer review" process and then let it go wherever it should be once it's completely correct.  I just want it to be good info so people know for sure what they can and can't do.

jplumbley

Quote from: sc4luv2 on October 25, 2007, 02:54:18 PM
Good Info. Was Readin' while you were postin'.  :thumbsup: Now should we move this?? to mod tutorials  ()meeting()

I dont know if this should be in the Tutorial Section as it is not really a Tutorial, but it is a very informative thread.

Thank you Mott... Now I have a better place to link the TE Lotters out there to when defending my position on TE Lots and Networks.  This was very well written, I read every word and it has given confirmation to everything I have been told and everything I have experienced with TE Lots.
"You learn something new everyday."

http://img517.imageshack.us/img517/169/nhpjplumbleykv3.gif
Bringing the new horizons closer to reality.

Berethor ♦ beskhu3epnm ♦ blade2k5 ♦ dmscopio jplumbley ♦ moganite ♦ M4346 ♦ Dedgren ♦ Ennedi Shadow Assassin ♦  Tarkus ♦ wouanagaine
Street Addon Mod - SAM

Filasimo

i stongly agree with plumbey and thank you so much mott for posting this very informative thread *gives mott a karma point* oh snap it dont work anymore  ::) good work man!  :thumbsup:
Plaza Mall Project
http://sc4devotion.com/forums/index.php?topic=2171.0
Coming Soon to the LEX!

NAM Team
What can NAM do for you?
//

RippleJet

This is very well written, mott! And a very good basis for well created custom stations.
My eyeballs couldn't find anything to correct, everything was very easy to follow and easy to agree upon!

I will implement the transit switch entry cost in the formulas for the "X Tool" for the creation of custom stations in the future!
And I suggest that the next NAM changes that property for all in-game stations accordingly! ;)

cogeo

I think there is something wrong with your scales. A pedestrian walking at 3.5 kph (3500 meters per hour) would actually need 16/3500 = 0.0046 hours (ca 16.5 seconds) to walk through a 16-meters long tile, which sounds very reasonable. The time you suggest (1/3.5 = 0.286 hrs) is prohibitive. But I don't know if SC4 trip times are correctly scaled either.

I have experimented a lot with the Transit Switch thingies (for use in my stations) and I have concluded that the units for the Transit Switch Entry Cost property is indeed hours. Below are the effects of various settings (for 1x1 lots):

- 1.0 or 0.5: very high values, no sims are gonna use this station.
- 0.1: very strong effect. No pedestrians will cut corners through the station. Usage (mean the "real" one) fairly lower compared to that of a similar station with a setting of 0 (the station is quite less "competitive" already).
- 0.05: strong effect. No (or very few) pedestrians will cut corners through the station. Usage somewhat lower, but it's bearable. However having several such stations in a row on the same network/path (eg 5 roadtop stations on the same road) can significantly increase travel times, causing sims to look for alternative routes or even choose to work somewhere else, even in a different city.
- 0.02: Seems this is the "correct" value. Few pedestrians will cut corners. Negligible effect on usage. No traffic problems.

Crissa

I had been trying to use TE lots to 'interrupt' car traffic flow, but I noticed sims were more likely to get back into their cars than they were the bus - the times for the bus seems to include going to the end of the street and back... (IE, a TE lot at the intersection end of a street the sims would get on the bus as it arrived on the street, not as it left the street)

And I like the look of transit-enabled lots, as well.  Made me wonder if it were possible to program the road network to do a round-about including a TE lot, so that one type of transit would be optimal in one cardinal while the other type of transit was merely interrupted.

-Crissa

mott

Quote from: cogeo on October 25, 2007, 04:44:19 PM
I think there is something wrong with your scales. A pedestrian walking at 3.5 kph (3500 meters per hour) would actually need 16/3500 = 0.0046 hours (ca 16.5 seconds) to walk through a 16-meters long tile, which sounds very reasonable. The time you suggest (1/3.5 = 0.286 hrs) is prohibitive. But I don't know if SC4 trip times are correctly scaled either.

"Time" is relative in SimCity.  So is "Speed."

Try not to think of Pedestrians as moving at 3.5 "kph."  Think of them as moving 3.5 "tiles per step."   Cars move 31 "tiles per step."   And so on.
"Entry Cost" is in Map Steps, not Minutes.

"Max Commute" is the maximum number steps that a Sim can accumulate during a commute trip to work and then back home.

Whatever "Max Commute" is set to, ends up being assigned the value of "255" when passed to the Commute Time graph.   
Therefore, 1 minute = (Max Commute / 255).  The definition of a "minute" depends on Max Commute.

The appropriate place to account for this and scale time back down to reality, is in the Commute Time Graph's exemplar, where a scalar variable is provided for the purpose.  Maxis/EA did not choose to use it (or chose not to), so the Commute Times appear ridiculous to the player, and impossible to interpret.

The formula for setting *that* scalar, is to decide whatever your Max Commute should work out to be in minutes, and using the formula:
Graph Data Multiplier = (Max Commute in Minutes / 255).   That gets you a real-time Commute Time display.  It also gives you the luxury of thinking of Speed in kph, and a Map Step Cost/Entry Cost of 1 == 1 minute on the graph).

Hope this helps.

Diggis

That is one hell of a topic.   One of the things I got from it is that you shouldn't use road top Mass transit as they really need to allow all road traffic to pass?

What is the effect of having more than one transit type on a lot?  You have said that it's a no go, but not what it will do.

jplumbley

Quote from: Diggis on January 24, 2008, 04:15:01 AM
That is one hell of a topic.   One of the things I got from it is that you shouldn't use road top Mass transit as they really need to allow all road traffic to pass?

What is the effect of having more than one transit type on a lot?  You have said that it's a no go, but not what it will do.

The reason there shouldnt be more than one transit type on a lot is because there is only one Transit Swicth Cost.  This Transit Swicth Cost is added to any Sim passing through the lot.  Ripplejet and I have been discussing how the Transit Switch Cost should be  used in the XTool.  And we have come up with a fairly useful calculation.

First off it is most optimal for a lot to be square not a rectangle, but it still can be a rectangle none the less.  The most important thing about a TE Lot is preventing Sims from using is as a shortcut.  So the easiest way to do this is by making sure the distance walking through the station is slower than walking past the station.  This means there will be one variable when calculating the Transit Switch Cost.  So, the MAXIS Speed for a Sim walking is 3.5 which means each tile has a "hop count" of approximately 0.29 (this is a constant).  Then we take the lot and find out what the length and width are, so if it is a 2x3 lot then we have a 2 length and a 3 width, now put this into that triangle equation you learned in highschool (x2+y2=h2).  So, heres the equation:

0.29 x sq. root(length2 +width2) = Transit Switch Cost

This will allow a sim to walk through a Station along the diagonal only because in RL you would walk through the Station if it was on your way.  I will prevent Busses, Trains, etc from using Station Lots as a shortcut because it is way slower.

Now, we have found one problem with these lots already.  IF the lots are too big, such as Ill Tonkso's rail stations the calculated Transit Switch Cost will be way too high.  These lots will have to be modded under a different set of rules.  For example the best way to do this would be to Transit Enable the lot so Pedestrian access can only be obtained through the south side of the lot (the entrance to the Station).  If this is done we can then calculate the Transit Switch Cost based on the South Side of the lot only, meaning it the lot is 8 tiles wide we will end up having a Transit Switch Cost equal to about 2.3 instead of 3.8 or higher depending on the length of the lot.  This Transit Switch Cost for larger lots may just cause Sims to not use the Transit Network you are building, but it needs to be there.
"You learn something new everyday."

http://img517.imageshack.us/img517/169/nhpjplumbleykv3.gif
Bringing the new horizons closer to reality.

Berethor ♦ beskhu3epnm ♦ blade2k5 ♦ dmscopio jplumbley ♦ moganite ♦ M4346 ♦ Dedgren ♦ Ennedi Shadow Assassin ♦  Tarkus ♦ wouanagaine
Street Addon Mod - SAM

wouanagaine

Hey, not sure, I'll have to redo my maths ( quite late for me atm ), but as SC4 does not know diagonals, I'm pretty sure you should use a manhattan distance and not an euclidian one

New Horizons Productions
Berethor ♦ beskhu3epnm ♦ blade2k5 ♦ dmscopio ♦ dedgren ♦ emilin ♦ Ennedi ♦ Heblem ♦ jplumbley
M4346 ♦ moganite ♦ Papab2000 ♦ Shadow Assassin ♦ Tarkus ♦ wouanagaine
Divide wouanagaine by zero and you will in fact get one...one bad-ass that is - Alek King of SC4

Andreas

This information is golden. :) As with many things, I'd say I know the basics of TE'd lots, but when it comes to the details, I'm rather lost - i. e. never cared much about the Transit Switch Cost or simply set it to 0.1, as I found in various lots. Having some kind of calculator (built into the X-Tool or elsewhere) would be very neat. Obviously, you should always use your common sense when figuring out the values, but at least those calculated values are a whole lot better than what Maxis provides with the Plugin Manager...
Andreas

jplumbley

Quote from: wouanagaine on January 24, 2008, 01:46:04 PM
Hey, not sure, I'll have to redo my maths ( quite late for me atm ), but as SC4 does not know diagonals, I'm pretty sure you should use a manhattan distance and not an euclidian one


Ripplejet and I discussed this, and it should allow people to walk through a Station lot, but it should prevent, busses, trains etc from jumping.  This is a way we can allow for a nice median between sims walking past the lot and walking through the lot.  The Manhanttan distance will in effect start causing too high Transit Swtich Costs aswell.  Not enough time to explain.
"You learn something new everyday."

http://img517.imageshack.us/img517/169/nhpjplumbleykv3.gif
Bringing the new horizons closer to reality.

Berethor ♦ beskhu3epnm ♦ blade2k5 ♦ dmscopio jplumbley ♦ moganite ♦ M4346 ♦ Dedgren ♦ Ennedi Shadow Assassin ♦  Tarkus ♦ wouanagaine
Street Addon Mod - SAM

Diggis

Quote from: jplumbley on January 24, 2008, 09:58:12 AM
The reason there shouldnt be more than one transit type on a lot is because there is only one Transit Swicth Cost.  This Transit Swicth Cost is added to any Sim passing through the lot.  Ripplejet and I have been discussing how the Transit Switch Cost should be  used in the XTool.  And we have come up with a fairly useful calculation.

OK, without worrying about the maths, if I use a road top mass transit, with the switch set to that of the pedestrians it will cause a slowdown for the vehicle traffic?  Not necessarily a bad thing if you see the effect bus stops have on traffic here.

If I use it with the traffic speed set to the vehicle speed then it will cause the pedestrians to sprint across the tile?  Again not a major as it's only 1 tile.

From what I understood from Motts discussion though is that it should be enabled for only one traffic type, is only busses, or only trucks.  But surely all road traffic is travelling at the same speed, for the network obviously, so that can't be the problem.  I may be confusing the issue here somewhat, I know I am confused.

RebaLynnTS

Becca

Look for me at ... Becca At Bat