As promised I will post my new PAXLink ai when it has a good chance to not get bankrupt. And I consider that done by now. (at the very bottom you find a screenshot if you want to look on it before reading all this long text)What makes PAXLink special?
PAXLink is a passenger only AI that builds bus services in towns and then when the town is big enough it builds an inter city airport station next to the town and feeds all the passengers to the airport instead, using transfer orders. Using planes it makes the big money by transporting passengers from one town to another. Actually before I added the inter-city part it struggled hard to not go bankrupt as each bus station cost about 700 pounds per year around 1950, which is a high cost compared to the little money you earn by intra (in city) transport.
Now PAXLink is not just that. While coding it I have had the goal to build a robust AI by not storing any meta state information in Squirrel, instead it reads all state information from the map. - If there is at least 2 bus stops in a town, then we can build a bus depot. If there is at least 2 bus stops and a depot, then we can buy buses. If the town has an inter-city station and it is served by air-vehicles then put the town buses in feeder mode, else use local mode. etc. etc.Town grid
When building bus stations in town it uses a grid as shown below. The red dots shows the grid tiles and the light blue shows the 8 adjacent tiles. PAXLink will first try the red tile, and if that fails pick one of the light blue based on their score (which involves a few parameters). For a placement to succeed it need to be adjacent to a road tile. The size of the grid depends on town size but also for a station to be built it need to catch enough cargo (to not cost 700/year for no use) and have road access. (the AI don't connect grid bus stations to road currently)
TownGrid.png [ 1.27 KiB | Viewed 27549 times ]
A problem right now is that if it only builds one road stop in a town it need to leave it there, as removing it will only cause it to be re-built soon again, as the AI don't store any state information. To fix this I need to rewrite the grid bus stop building to first check that after construction there will be at least 2 stations before building.
To not make multiple PAXLink AIs conflict too much I think about adding a grid offset that then will be picked either by random or by knowing which PAXLink company in order the company is. This offset will then need to be stored in savegame and as a squirrel variable, or the AI might not find its existing stations.Regulating of network
One of the nice things that it already does is that it expands its bus network as the town grows and updates the bus schedules with the new stations. If a station get far to little cargo (someone destroyed buildings) it removes grid bus stations. Also it regulates the number of buses in a town as well as the number of airplanes on an air-connection. Todo
The AI is currently neither really good on management of the bus network nor the airplane network. Some TODOs:
- Don't only check if a town has an airport, also check that the airport
a) has bus stops
b) accepts passengers
before counting it as an inter city station.
- Check the IC station regularly to see that it has all road stops built
- Don't build airports that will not accept passengers
- Buses in feeder mode need a better sort of stations in the order list.
- Upgrading of airports, and blocking of big planes from using small airports
- Don't build only one road station in towns, either accept a second with a bit worse score than usual or by building road for a second. Or don't build the first one at all. Having an unserved station in towns seams to give bad rating over time in that town.
- Increasing and especially decreasing of a vehicle fleet needs more work. (now it just decreases the fleet with capacity 50 when it decides to decrease, which causes problem with vehicles with more than 50 in capacity)
- Give vehicles with high capacity some extra scores when the capacity limit of a network has been reached, or at least replace low-capacity vehicles with high-capacity vehicles when the number of possible vehicles a network can handle has been reached.
- Adopt to game settings such as none breakdowns, or even worse if a used mode of transport is disabled by the user.
- Better calculations of maximum vehicles a network can handle. (now it allows 5 vehicles per station)
- ... <- there are even more things that can be done
Save/load should work due to the design of the AI (no saving of state in squirrel). A half-constructed inter city airport is not fixed on load etc. but on the other hand it can happen because a town refuses to allow it to be completely constructed, so it is not really a save/load problem but can happen from other interruptions too.Changelognew in version 4
: improved checking for slopes when building grid bus stations (Thanks Yexo for both noticing about the issue and providing code to get the maximum height of a tile)
_________________My OpenTTD contributions
(AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)Junctioneer
(a traffic intersection simulator)