The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Andarix on May 17, 2026, 12:28:01 PM

Title: Passenger Script-AI from koa - Proposed Changes
Post by: Andarix on May 17, 2026, 12:28:01 PM
change select start city to minimum citizen 500

Since code synchronization is difficult without a repository, I have written the new code into the file `changes_andarix.nut`.

The pathfinder does not build bridges over rivers and bodies of water with shallow banks. I need to investigate why this is the case. This behavior had already been observed in `pak.nippon` in connection with `sqai_rail`.


I have removed unused files to improve clarity.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: koa on May 17, 2026, 02:35:33 PM
Quote from: Andarix on May 17, 2026, 12:28:01 PMThe pathfinder does not build bridges over rivers and bodies of water with shallow banks. I need to investigate why this is the case. This behavior had already been observed in `pak.nippon` in connection with `sqai_rail`.
I think the reason you can't build bridges with the "Half-Height" pak set is because it isn't tall enough.IMG_2782.png
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: prissi on May 18, 2026, 12:06:34 PM
How about setting up a guthub repo? Then things are easier to follow.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: koa on May 18, 2026, 10:59:00 PM
Quote from: prissi on May 18, 2026, 12:06:34 PMHow about setting up a guthub repo? Then things are easier to follow.
Thank you for nice suggestion.
In that case, I'm not sure how to structure the repository.
How does sqai_rail?
Is it included in the main Simutrans development repository, or separate repository?
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: prissi on May 19, 2026, 03:29:03 AM
The ai are in the main branch. Since most people nowadays prefer github, it might be easier to just add repository on github by cloing from sqai. I think I would leave Andarix to suggest something.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: Andarix on May 19, 2026, 05:10:46 AM
sqai_rail (https://github.com/Andarix/simutrans-scenarios/tree/master/ai/sqai) is a fork of sqai by Dwachs (https://github.com/Dwachs/simutrans-scenarios/tree/master/ai/sqai).

There are now 5 possibilities:

Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: prissi on May 19, 2026, 07:11:36 AM
I am fine with repo under the simutrans ubrella or as a fork from Dwachs/Andarix. I think, forking may be easier long term to synchronize the parts that do not change but were improved in squai/sqai_rail
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: Andarix on May 19, 2026, 05:36:17 PM
Quote from: prissi on May 19, 2026, 07:11:36 AMI am fine with repo under the simutrans ubrella or as a fork from Dwachs/Andarix. I think, forking may be easier long term to synchronize the parts that do not change but were improved in squai/sqai_rail

With regard to `astar.nut`, this is certainly advantageous, as it essentially contains only neutral logic (pathfinding, station construction, station expansion, object selection, etc.).
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: Andarix on May 21, 2026, 09:02:58 AM
Changes to slightly limit network expansion:

- Limit route length to straight-line distance + 20%
- No further network expansion if capital falls below 50,000
- Limitation to expansion to 5 cities if capital is below 70,000


provided no mistakes are made
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: koa on May 21, 2026, 11:39:52 AM
Quote from: Andarix on May 21, 2026, 09:02:58 AM- No further network expansion if capital falls below 50,000
- Limitation to expansion to 5 cities if capital is below 70,000
If it curbs investment without turning a profit, it will eventually go bankrupt.
To curb investment, it must first generate profits.
And to generate profits, it needs to build a solid network.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: koa on May 21, 2026, 11:42:19 AM
I opened repository of passenger AI forked from Andarix.
thanks.
https://github.com/koa-simutrans/simutrans-scenarios/tree/master/ai/sqai/
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: prissi on May 21, 2026, 12:27:06 PM
I think the criterum should be rather net wealth, a capital is not accounting for the value of vehicles. But maybe, a slower expansion below a certain threshold could stabilize it to went went bankrupt while expanding.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: Andarix on May 21, 2026, 06:37:16 PM
The decision to focus on capital stems from the fact that, currently, only a single depot in the starting city is being utilized.

This means that vehicles incur significant operating costs before they have even reached their first scheduled stop.

sqai_rail calculates the construction costs and then determines whether the available capital is sufficient.

sqai_koa appears to check the capital, but it does not calculate the cost of expansion or the associated maintenance expenses. Furthermore, an entire series of cities. I have seen as many as eight at once are connected in a single batch.

Quote from: koa on May 21, 2026, 11:39:52 AMIf it curbs investment without turning a profit, it will eventually go bankrupt.
To curb investment, it must first generate profits.
And to generate profits, it needs to build a solid network.

With your strategy relying on a single depot and operating out of just one starting city you face the inherent problem that significant operating costs are incurred before your buses even reach their first scheduled stop.

Furthermore, you are currently not utilizing any waiting times. As a result, a large number of your buses are driving around largely empty.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: Isaac Eiland-Hall on May 21, 2026, 10:08:43 PM
I'm of course well removed from this discussion, but I have been following it with interest. Surely the "contribution" I'm about to make has been well thought of, so please forgive me in such a case, but I didn't see any discussion about fixes, so...

Seems like a simple check to see how expensive it would be to run a vehicle from the intiial depot to the start of its route could be added, and if the cost of a new depot would be like a third or half of the running costs, it would make much more sense to build a new depot.

But surely there's a reason that's not being considered that I'm missing, so don't worry about it if I'm way over here out of understanding, I'm still going to enjoy reading the discussions. :)
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: Andarix on May 22, 2026, 01:40:40 PM
@Isaac

see this post (https://forum.simutrans.com/index.php?msg=212638)

There are certainly solutions. However, this is koa's AI, and consequently, I will not alter his strategy.

I can attempt to improve the AI's survivability. To what extent koa chooses to adopt any changes I make remains entirely his decision.

Furthermore, it is understandable that one would build an AI based on one's own playing style. I, too, have a different playing style than many others. What may seem incomprehensible to me when observing other players simply makes sense to those specific individuals.

The sqai_koa is still in a relatively early stage of development and is, in fact, based on rather old files (dating back to 2021) of mine. Over the past few years, however, I have devoted a great deal of effort to stabilizing sqai_rail. Unfortunately, I receive no feedback regarding the behavior of sqai_rail—which leads me to believe that it sees very little use.

However, it is worth bearing in mind that purely freight transport is something entirely different from purely passenger transport in Simutrans.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: Andarix on May 22, 2026, 08:28:15 PM
Quote from: prissi on May 21, 2026, 12:27:06 PMI think the criterum should be rather net wealth, a capital is not accounting for the value of vehicles. But maybe, a slower expansion below a certain threshold could stabilize it to went went bankrupt while expanding.

The restriction currently applies only to the further connection of new cities. City traffic is, after all, still being expanded.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: koa on May 23, 2026, 11:35:46 AM
Quote from: Andarix on May 21, 2026, 06:37:16 PMWith your strategy relying on a single depot and operating out of just one starting city you face the inherent problem that significant operating costs are incurred before your buses even reach their first scheduled stop.
I think bus of running cost in pak64 is very high compare to pak128.japan.
Idealy the judgement to depart from a base depot or build a depot on-site want to be based on the depot's maintenance costs and the distance to the other city.
But it is very difficult to establish criteria for making such judgment.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: Andarix on May 23, 2026, 01:23:20 PM
Quote from: koa on May 23, 2026, 11:35:46 AMI think bus of running cost in pak64 is very high compare to pak128.japan.
Idealy the judgement to depart from a base depot or build a depot on-site want to be based on the depot's maintenance costs and the distance to the other city.
But it is very difficult to establish criteria for making such judgment.

Well, in my opinion, a first step would be to place the starting city closer to the center of the map. Or regardless of the starting city to build the depot closer to the middle of the map.

This decision may also be specific to the particular pakset being used.

pak64.german will be even trickier to handle, as stations in that pakset are not allowed to become overcrowded.

In pak128, the issue lies with the vehicle selection. However, I haven't taken a look at that one in quite some time. Back then, it was very difficult to find buses that could turn a profit, because their operating speed would very quickly drop below the bonus speed threshold.

Depending on the pakset, the AI needs to adapt its strategy accordingly. And that is precisely what makes the development process so tricky and time-consuming. Unfortunately, it is impossible to test everything personally and feedback, after all, is quite scarce.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: Andarix on May 25, 2026, 11:31:08 PM
Various changes.

Most of these changes are now effective only in pak64.

What still does not work well is vehicle management.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: Andarix on May 27, 2026, 01:09:28 PM
This will likely be my last version for the time being.

Summary of changes:


Buying and Selling Vehicles:

The aim of these changes is to eliminate the constant buying and selling of vehicles. This behavior is detrimental when using a depot system for the card, as operating costs are incurred continuously costs that, in passenger transport, cannot initially be offset by revenue.


Ultimately, how well or poorly everything works depends heavily on the specific map. For the start, I tend to prefer smaller cities and more mountainous terrain. What works on my maps should also work on maps that are flatter and feature larger cities.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: Andarix on May 27, 2026, 06:50:44 PM
reupload

Change

QuoteAdjustment of the maximum waiting time, rather than changing the number of vehicles.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: koa on May 28, 2026, 10:19:50 PM
It's great work.
Unnecessary running costs were reduced, leading to improved economy performance.
Title: Re: Passenger Script-AI from koa - Proposed Changes
Post by: Andarix on May 31, 2026, 09:42:02 AM
Yet another version.

City lines may now only be built if no other player currently has more than one stop in that city.

Only vehicles with a capacity greater than 10 may be used.

If a city contains two adjacent stops, these are made public. To determine this, the players' total assets are checked.

A problematic issue for the script AI is that river crossings are no longer constructed if the road speed exceeds that of the crossing. Since bridges are not built over rivers with shallow banks, the resulting routes become excessively long and are therefore not built. This also affects sqai_rail. This will have a significant impact on flat maps.

test sve
simutrans 124.4.2 r11990
pak64 + food addon