HotSpots - Germanunkol/trAInsported GitHub Wiki

Hot Spots

Hot spots are special buildings/tiles on the map. They are usually represented by schools, stores, hospitals etc. On the map that is passed to the player's AI in ai.init(), each tile that is a hotspot is represented by an "S". If a rail is next to a hotspot, then passengers are much more likely to spawn there and also they are much more likely to have this rail as a destination.

This mechanism means that it may be intelligent to spawn your trains near hotspots or that, when picking up a passenger, it could be more intelligent to pick up a passenger that has a destination which is close to a hotspot.

If you decide to give destinations more priority if they are near a hotspot, try to do most of these calculations in ai.init() - because ai.init is allowed to run for a much longer time than other functions.

For those interested in just how much a hotspot influences a rail, here is how the calculation is done internally:

  • The game goes through all the tiles in the map. If the tile is a house, then all surrounding tiles are checked for rails, and these rails are added into a list of rails.
  • Since this is done for all houses, if a rail is next to two or three houses, then it is added to the rail list two or three times.
  • When a tile is a hotspot instead of a house, then instead of adding the rail just once, it is added to the list 25 times.
  • This means that when a rail is, for example, next to one house and two hotspots, it is added to the list 1+25+25 = 51 times.
  • Whenever a passenger spawns, a random entry is selected from the rail list for the destination, and for the spawning point. This way, the more entries a particular rail has, the more likely it is to be chosen for destination or spawning point.
  • In the above example (two hotspots and one normal house next to the rail) the rail is 51 times as likely to be chosen than a rail that is only next to one house (which would only result in one single entry).