• Welcome to SC4 Devotion Forum Archives.

[Programming] Traffic simulation

Started by croxis, September 01, 2009, 12:48:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

croxis

From the SC4 Prima Gude

QuoteAs described in Chapter 19, with each cycle the simulator would take each Residential building and find the closest open job to it.  If the trip between home and job could be made in under 2.5 hours, this was considered a completed trip and thus the illusion exists that a sim living in that house is driving to a job somehwere.  With the next cycle, the simulator did this agian, finding an entirely different job form the one during the prior cycle....

With Rush Hour... fiction has come closer to reality.... The simulatior remembers from month to month what jobs it finds for each Residential structure and holds onto them until something changes....

Every four months or so (it can be longer for larger cities and sooner for smaller ones), the traffic simulator recalculates the route from a Residential structure to the existing job.  If it finds a faster way the simulator will keep the sim in the same job but take the new faster route.  If, however, it can't complete the trip tot hat job in time or some other factor has made it impossible for the trop to be completed in under 2.5 hours, a new job is selected that will persist until at least the next recalculation.

If a trip's route is severed by... destruction of a road, the simulator recalculates the route rather than waiting until the next cheduled recalculation.  If it can't complete the trip to the same job, it tries to select a new job.

For this reason, pause the simulation before upgrading a road. As the road is destroyed to make room for a higher-capacity road, Sims may mistakenly think their route has been severed and recalculate their commute....

Other than increased commute time, what else could cause a change in job? A change in desirability at the workplace location could cause the number of jobs to drop.  In this case, all Residential routes to the job site are recalculated, with some Sims having to look for work elsewhere.

Quote
Route planning.
Before departing, a Sim plans a trip tot he closest possible (as the crow flies) destination.  If, while searching for a route to the closest destination, the sims finds another destination along the way to the choses one, he'll select that destination instead.

Next, he plans a route in the general direction of the found destination.  (Each tile has a time to cross value, depending on mode of transportation and what kind of tile it is.)

....

Below full capacity, traffic travels across a tile at its default rate.  When traffic rises above 100% capacity, the time to cross increases.

...

In the case of Residential trips, which mode of transporatation Sims prefer is dictated by their wealth level.

I see transportation working essentially the same way.  One variation that can be done is have random sims (simitzens? :P) check for a faster route each cycle instead of all at once every 4ish months.  This would give a more organic feel to the simulation as well as be a bit more realistic.

Moving to a freeform system will require a different method than a tile system.  Creating a road network using graphs is relatively easy. A comprehensive transportation network would require modifications.  I still don't personally know how to find a route along an edge (ie house in the middle of a road).  I have found existing open source implementations (here[/url) used for route finding (like google maps) which might be usable.

tomkeus

Quote from: croxis on September 01, 2009, 12:48:35 PM
One variation that can be done is have random sims (simitzens? :P) check for a faster route each cycle instead of all at once every 4ish months.  This would give a more organic feel to the simulation as well as be a bit more realistic.

Yes that's good idea. We could experiment a little with some Monte Carlo traffic simulation methods.
#define TRUE FALSE /*Happy debugging suckers*/

Nique

Quote from: tomkeus on September 01, 2009, 02:37:28 PM
Yes that's good idea. We could experiment a little with some Monte Carlo traffic simulation methods.

Okay, we are going somewhere now. I'm happy to see you guys are serious. Anyway, doesn't Monte Carlo Simulation Methods take to much processor power?
Proudly developer of

tomkeus

Quote from: Nique on September 01, 2009, 02:53:31 PM
Anyway, doesn't Monte Carlo Simulation Methods take to much processor power?

Well, for a given problem, they are usually the most efficient solution. I've posted in the Core Design thread. Check it for few details about this.
#define TRUE FALSE /*Happy debugging suckers*/