Skip to content

Development Notes: Citizen Traffic AI

Nico Borgsmüller edited this page Dec 12, 2020 · 1 revision

Traffic AI Overview

The purpose of this document is to aid us, the developers, with documentation of which parts of the traffic AI belongs to which DLCs and how they relate to each other. For example, if a car can progress down its road is related to if the train crossing has a train passing by. If a pedestrian is block a crossing cannot pass either.

What decides when a vehicle will spawn?

  • Delivery of goods from factory to shop
  • Export/Import of goods
  • Vehicle passing trough the city between to outside connections
  • Transport Method change/transfer, for example cargo train converting to several cargo trucks
  • Service Vehicle dispatch
  • Citizen going to work
  • Citizen visiting something
  • Intercity plane/train/bus entering map
  • Increase in transport line budget
  • Post/Waste/Dead transfer (probably just delivery trucks with different skin)

What may alter the progress of a vehicle?

  • Traffic, this shouldn't be a problem if nothing is random and if EVERYTHING is synced
  • Pedestrians crossing the road
  • Flooding
  • Trains crossing roads
  • Disasters
  • Net(road/tracks/more) deletion
  • Speed
  • Emergency vehicle AI?
  • Timing of traffic lights
  • Stop/Give way signs
  • Vehicle size and trailers (if a delivery truck is spawned as a box truck on the client and a semi on the server)

Thoughts about design architecture

One of the things that makes this so hard is that the tiniest little difference can cause a complete desync. For example, if there's a delay in a road being upgraded on the client to a new road with a higher speed limit, that can cause a car to not make it in time to the next traffic lights. This in turn sets of a chain of events that cause a pile up with a building not getting it's demands fulfilled, which makes citizens unemployed.

Approaching this with a trust in the simulation to some extent and then force resync of positions would make this way more reliable. The question is, is it practical to sync the 16383 moving vehicles (vanilla limit) and 32767 parked ones? Let's look at the numbers. Assuming that positional data would be around 100 Bytes (generous or not, IDK), we would end up with about 160KB of data to sync every second, also assuming that all vehicles need to be synced every second. That's 2Mbit/s for vehicle traffic positions. It's possible to make it a server option to specify traffic sync interval if bandwidth gets out of hand, or even automatically detect this. 2Mbit/s is a lot, but one has to remember that traffic is one of the absolute core concepts of the game.

The following classes have been reverse engineered from the game

Base game AI

  • HumanAI (Pedestrian)
  • PassengerCarAI
  • AircraftAI
  • AmbulanceAI
  • AnimalAI?
  • BirdAI?
  • BusAI
  • CargoShipAI
  • CargoTrainAI
  • CargoTruckAI
  • CarTrailerAI
  • CitizenAI
  • FireManAI
  • FireTruckAI
  • GarbageTruckAI
  • HearseAI
  • HearseDriverAI
  • MetroTrainAI
  • ParamedicAI
  • ParkWorkerAI?
  • PassangerPlaneAI
  • PassangerShipAI
  • PassangerTrainAI
  • PetAI
  • PoliceCarAI
  • PoliceOfficerAI
  • ResidentAI?
  • ShipAI
  • TrainAI
  • TransportLineAI
  • VehicleAI
  • WildlifeAI

After Dark

  • BicycleAI
  • PrisonerAI
  • TaxiAI
  • TouristAI

Snowfall

  • TramAI
  • SnowTruckAI

Natural Disasters

  • ShelterAI
  • AmbulanceCopterAI
  • FireCopterAI
  • GenericFloodAI?
  • HelicopterDanglingAI?
  • PolcieCopterAI?
  • RescueAnimalAI
  • RescueWorkerAI

Mass Transit

  • BlimpAI / BalloonAI
  • FerryAI
  • CablecarAI
  • MonorailAI
  • HelicopterAI
  • PassangerFerryAI
  • PassangerHelicopterAI

Green Cities

Parklife

  • TourLineAI?

Industries

  • CargoPlaneAI?
  • PostvanAI
  • MascotAI?

Campus

Concerts

Sumset Harbor

  • FishingBoatAI
  • TrolleyBusAI

Unknown

  • PrivatePlaneAI
  • RocketAI
  • ServicePersonAI