News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

Script-AI with railroad

Started by Andarix, August 01, 2020, 07:17:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andarix

sqai_rail v0.8.1

To put it right away and not arouse false hopes. The AI is designed in such a way that it can survive in the various packages (at least I hope because not every package has been tested by me). She's not a perfect player in every packset. Finer adjustments to different packages will be possible in the future. That depends on whether players give feedback or not.

Railway lines are being expanded for multi-train operation with sidings. The number depends on the length of the route and the terrain.
From 1935, railway lines longer than 80 tiles can be electrified and use electric vehicles.

For long connections, a higher capital is required. Therefore these connections are discarded if the existing capital is not high enough.

There are several runs for route optimization. Bridges and incisions are built. Tunnel not supportet by script AI. Level crossings are also replaced by road bridges if the number of road vehicles exceeds 100 per month and the course of the road permits.

If the maximum speed of vehicles increases, routes are expanded to the necessary speed.

Road conversions always require suitable owners.

Unprofitable and incomplete routes/connections will be removed again.

When traffic jams occur, empty vehicles will be removed after a while to clear the jam.

Unfortunately, earlier games (< r.0.7.0) no longer work from this version onwards.

Problems
With larger maps and more complex industrial chains, the chains are not fully developed. This results from the amount of the starting capital.

If a player goes bankrupt, his streets become public. However, this does not apply to bridges, these will be removed. This means that lines can be broken. This currently has to be fixed manually by the.

Problems can arise when railroad lines cross.

Connections that require more than 3 sections are not completely built.

When removing routes, remnants may remain.




The zip file contains a script_ai_text.dat. Add these texts to the simutrans/text/[lang].tab or save [lang].tab in script folder sqai_rail to have a translated output in the game.
You can translate on this page (select object script_ai_text) or SimuTranslator Base texts (select object script_ai_text).

required Simutrans r10408 or higher

https://nightly.simutrans.com/en/
https://github.com/Andarix/simutrans/releases
https://www.simutrans-forum.de/nightly/
https://github.com/aburch/simutrans/releases


  • To use, unzip the file to simutrans/ai.
  • Start Simutrans with the package of your choice.
  • Start or load a map.
  • Choose a new Script AI player.
  • Choose sqai_rail from the selection.

Andarix

sqai_rail v0.8.2

Line management changes and bug fixes

Unfortunately, earlier games (< r.0.7.0) no longer work from this version onwards.

Problems
With larger maps and more complex industrial chains, the chains are not fully developed. This results from the amount of the starting capital.

If a player goes bankrupt, his streets become public. However, this does not apply to bridges, these will be removed. This means that lines can be broken. This currently has to be fixed manually by the.

Problems can arise when railroad lines cross.

Connections that require more than 3 sections are not completely built.

When removing routes, remnants may remain.




The zip file contains a script_ai_text.dat. Add these texts to the simutrans/text/[lang].tab or save [lang].tab in script folder sqai_rail to have a translated output in the game.
You can translate on this page (select object script_ai_text) or SimuTranslator Base texts (select object script_ai_text).

required Simutrans r10408 or higher

https://nightly.simutrans.com/en/
https://github.com/Andarix/simutrans/releases
https://www.simutrans-forum.de/nightly/
https://github.com/aburch/simutrans/releases


  • To use, unzip the file to simutrans/ai.
  • Start Simutrans with the package of your choice.
  • Start or load a map.
  • Choose a new Script AI player.
  • Choose sqai_rail from the selection.


Andarix

#38
sqai_rail v0.8.5

This version has the following features


  • connect industries with roads, railways or ships, also combined
  • Optimization of the routes (construction of bridges, cuts (instead of tunnels), route straightening)
  • Construction of railway sidings
  • Electrification of existing routes when electric vehicles are used
  • Retirement of vehicles that are too old
  • Upgrading routes to higher speeds when faster vehicles are used
  • Extension of platforms in the direction of the route, if possible when using longer trains than at the start of the route
  • Demolition of unprofitable routes, unless it is the last connection of 2 industries

The Script AI won't play perfectly, but it should survive and not go bankrupt in most cases. However, the larger (distances between industries) and mountainous (restrictions on terrain construction and no tunnels) the maps are, the more difficult it is for them. The biggest problem will be when industrial chains are not fully developed.

I mainly tested with pak64.german. Optimizations for other packages are possible after feedback. It is also possible that there are still errors in relation to 2 heights. Especially when building bridges that may only have height 1 although height 2 is required.

Unfortunately, earlier games (< r.0.7.0) no longer work from this version onwards.

Problems
With larger maps and more complex industrial chains, the chains are not fully developed. This results from the amount of the starting capital.

If a player goes bankrupt, his streets become public. However, this does not apply to bridges, these will be removed. This means that lines can be broken. This currently has to be fixed manually by the.

Problems can arise when railroad lines cross.

Connections that require more than 3 sections are not completely built.

When removing routes, remnants may remain.

When loading a map with script AI, the AI players may not load properly (see player list). Then the AI players have to be reactivated.




The zip file contains a script_ai_text.dat. Add these texts to the simutrans/text/[lang].tab or save [lang].tab in script folder sqai_rail to have a translated output in the game.
You can translate on this page (select object script_ai_text) or SimuTranslator Base texts (select object script_ai_text).

required Simutrans r10421 or higher (include in r10592)

https://nightly.simutrans.com/en/
https://github.com/Andarix/simutrans/releases
https://www.simutrans-forum.de/nightly/
https://github.com/aburch/simutrans/releases


  • To use, unzip the file to simutrans/ai.
  • Start Simutrans with the package of your choice.
  • Start or load a map.
  • Choose a new Script AI player.
  • Choose sqai_rail from the selection.



Testsave
Simutrans 123.0.2 r10592 pak64.german 0.123.0.0.4 script ai r0.8.5
https://simutrans-germany.com/files/upload/1936_256x256-1983.sve (until 22. Mar 2023)

Andarix

sqai_rail v0.8.7

Different changes for build double ways and create convoys.

Unfortunately, earlier games (< r.0.7.0) no longer work from this version onwards.

Problems
With larger maps and more complex industrial chains, the chains are not fully developed. This results from the amount of the starting capital.

If a player goes bankrupt, his streets become public. However, this does not apply to bridges, these will be removed. This means that lines can be broken. This currently has to be fixed manually by the.

Problems can arise when railroad lines cross.

Connections that require more than 3 sections are not completely built.

When removing routes, remnants may remain.

When loading a map with script AI, the AI players may not load properly (see player list). Then the AI players have to be reactivated.



The zip file contains a script_ai_text.dat. Add these texts to the simutrans/text/[lang].tab or save [lang].tab in script folder sqai_rail to have a translated output in the game.
You can translate on this page (select object script_ai_text) or SimuTranslator Base texts (select object script_ai_text).

required Simutrans r10842 or higher

https://nightly.simutrans.com/en/
https://github.com/Andarix/simutrans/releases
https://www.simutrans-forum.de/nightly/
https://github.com/simutrans/simutrans/releases

  • To use, unzip the file to simutrans/ai.
  • Start Simutrans with the package of your choice.
  • Start or load a map.
  • Choose a new Script AI player.
  • Choose sqai_rail from the selection.


Andarix

minor bug

edit or replace the file industry_manager.nut


Andarix

example stations built by sript AI




prissi

Apart from the strange bridge this is very impressive. I think it is time to make the script AI rather the default AI.

Andarix

#43
Quote from: prissi on February 21, 2023, 08:58:02 AMApart from the strange bridge this is very impressive. I think it is time to make the script AI rather the default AI.

Route finding is still not very good in mountainous terrain. The ability to adapt terrain is missing here.

Another problem is larger maps. Without adjusting the starting capital to the map size, the script AI is rather useless on large maps. In other words, it would only use road traffic, if at all. Or build incomplete chains that lead to bankruptcy.

The selection of industries is also not good. On my current test maps (around 384x448), I sometimes turn on all players as AI to achieve full chains.

Another problem is the oil rig with identical industrial connections. The 2nd route ensures that the first route comes to a standstill.

Since my own tests mostly run with pak64.german (single high set), I don't have any feedback from other sets.

I also see the lack of tunnels as a limitation for the AI.



I am currently trying to optimize the route and the passing points. There are still a few things wrong and the left-hand traffic has not yet been expanded/tested.

The focus is also on developing industrial chains. So before parallel connections are built, the chain as such is opened up.

This is also the reason why the current versions are not included in SVN.

Andarix

pak128
example failed upgrade road

Screenshot 2023-02-22 192104.png

Andarix

Quote from: prissi on February 21, 2023, 08:58:02 AMApart from the strange bridge this is very impressive. I think it is time to make the script AI rather the default AI.

Another problem is road bridges. When an AI goes bankrupt, road bridges are removed as opposed to roads becoming public. Such interruptions cannot be located from the script at the time.

Andarix

#46
sqai_rail v0.8.8

FIX bridge error pak128 (double high sets)
FIX select catenary pak128.german



I strongly doubt whether it makes sense to support pak128 (test with version 2.8.1). Pure freight transport is hardly possible there. Maybe by road, but impossible by train. Especially with the railways, the profits are very small in relation to the vehicle costs.

testgame

Simutrans 123.0.2 r10855
sqai_rail 0.8.8
pak128 2.8.1

pak128_AI_test.sve ~ 1 MByte (60 days)

Yona-TYT


Do your scripts fit each pakset? , interesting.. 8)

Andarix

Quote from: Yona-TYT on February 27, 2023, 01:50:23 PMDo your scripts fit each pakset? , interesting.. 8)

Yes, there are a few customizations for sets built in so far. That's why it needs feedback from other sets. Testing is very time-consuming because chance plays a major role and certain situations rarely occur.

Since the sets are different, this requires such adjustments. Among other things, the speed bonus and industry balancing play a role. Vehicle selection also plays a role.

So far, the AI has had a hard time coping with low production rates. The production rates for the pak128 and pak128.german are very low. This means that there are many low-volume connections. With the pak128, there is also the fact that rail freight transport is hardly feasible.

But pak128 has always been very street-heavy. And it's designed for mass passenger traffic. Maps with low passenger traffic (small towns) are also difficult to play.

The more mountainous a map is, the more difficulties the AI gets. This applies above all to the way search.

The map size also plays a role in connection with the starting capital.

Yona-TYT

QuoteThe map size also plays a role in connection with the starting capital.
Wouldn't it be nice to make a player's starting capital proportional to the size of the map?. 

Andarix

sqai_rail v0.8.9


Mainly changes in road traffic.

The script seems to hang from time to time. Then disable and re-enable the AI players in the player list.
This can be seen from the fact that the player balance sheet is not issued at the beginning of the month. And no other action messages are issued.

Messages for scenarios must of course be activated. The Script AI runs under Scenarios and not under AI.

If there are no bug reports, I think this version can then be added back to Simutrans.


Andarix

Now expanding stations also works at the end. It took a long time for this case to occur.

left before, right after





Andarix

current status

The code from the repo also has the convoy yo-yo a bit softened now. So the constant buying/selling of convoys at short intervals with lines (water, railway).

Otherwise I consider the script AI to be 80% working with trains.

The remaining 20% includes the following issues:
  • the execution of the script getting stuck (with the current card with r10889 apparently mostly after the turn of the year) [recognizable by the fact that no balance sheet report is issued at the beginning of the month]
  • no water route over navigable river is found
  • too little starting capital at too far distances on large maps
  • public water industries should only be developed from one line to the same consumer (there may be multiple connections if construction is simultaneous)
  • Industries that are too far to the edge of the map make it difficult to find suitable fields for stations
  • Assessment of the connection of industries only over the partial routes and not over the entire route (applies to combined routes)
  • Problems when routes cross unfavorably
  • Routing on rough terrain

and

  • too few test games distributed over the graphics sets, i.e. too little feedback

There is still plenty of room for improvement.

range of functions

  • Construction of goods connections by road, water (no canals and apparently without using rivers) and railways
  • Route optimizations after construction (so far without tunnel)
  • Upgrading routes to higher speeds
  • Subsequent electrification of railway lines
  • Extension of railway stations
  • Expansion of railway lines with passing points
  • Adjusting the number of vehicles on lines
  • Replacing vehicles with faster ones
  • no AI connections should be built parallel to human connections (can happen if the AI plans and builds faster than the player)

Andarix

sqai_rail v0.8.12

Other player's bridges are now saved with the lines. However, they will not be rebuilt once they have been removed.

Terrain changes are now applied to the grid. This has not yet been fully tested and has not yet been tested for double heights. There are also checks on the field outside the map and which player the path belongs to.

The latter requires Simutrans r10894 or higher.

Tryouts should have a monthly autosave. If errors occur, please make the last automatic save available.

Unfortunately, earlier games (< r.0.7.0) no longer work from this version onwards.

Problems
With larger maps and more complex industrial chains, the chains are not fully developed. This results from the amount of the starting capital.

If a player goes bankrupt, his streets become public. However, this does not apply to bridges, these will be removed. This means that lines can be broken. This currently has to be fixed manually by the.

Problems can arise when railroad lines cross.

Connections that require more than 3 sections are not completely built.

When removing routes, remnants may remain.

When loading a map with script AI, the AI players may not load properly (see player list). Then the AI players have to be reactivated.



The zip file contains a script_ai_text.dat. Add these texts to the simutrans/text/[lang].tab or save [lang].tab in script folder sqai_rail to have a translated output in the game.
You can translate on this page (select object script_ai_text) or SimuTranslator Base texts (select object script_ai_text).

required Simutrans r10894 or higher

https://nightly.simutrans.com/en/
https://github.com/Andarix/simutrans/releases
https://www.simutrans-forum.de/nightly/
https://github.com/simutrans/simutrans/releases

  • To use, unzip the file to simutrans/ai.
  • Start Simutrans with the package of your choice.
  • Start or load a map.
  • Choose a new Script AI player.
  • Choose sqai_rail from the selection.


Andarix


prissi

IN the svn, the *.tab files need an update too?

Andarix


sqai_rail v0.8.15

bugfix version

include in simutrans r10967

Andarix

#59
sqai_rail v0.9.0

This is a beta release.There are many expenses for control purposes.

The latter requires Simutrans r10894 or higher.


Now when an AI player is activated, the script version is displayed in the message window.

The management for the connections has been changed. Building behavior should now be slower.


Tryouts should have a monthly autosave. If errors occur, please make the last automatic save available.

Games with previous versions (< r0.9.0) may not be compatible with this version.

Problems
With larger maps and more complex industrial chains, the chains are not fully developed. This results from the amount of the starting capital.

If a player goes bankrupt, his streets become public. However, this does not apply to bridges, these will be removed. This means that lines can be broken. This currently has to be fixed manually by the.

Problems can arise when railroad lines cross.

If a rail station is located in an double-way area, it will be demolished if the route is demolished.

When removing routes, remnants may remain.

When loading a map with script AI, the AI players may not load properly (see player list). Then the AI players have to be reactivated.



The zip file contains a script_ai_text.dat. Add these texts to the simutrans/text/[lang].tab or save [lang].tab in script folder sqai_rail to have a translated output in the game.
You can translate on this page (select object script_ai_text) or SimuTranslator Base texts (select object script_ai_text).

required Simutrans r10894 or higher

https://nightly.simutrans.com/en/
https://github.com/Andarix/simutrans/releases
https://www.simutrans-forum.de/nightly/
https://github.com/simutrans/simutrans/releases

  • To use, unzip the file to simutrans/ai.
  • Start Simutrans with the package of your choice.
  • Start or load a map.
  • Choose a new Script AI player.
  • Choose sqai_rail from the selection.


Andarix

sqai_rail v0.9.1

bugfix version

include in simutrans r10986

Andarix

Script-AI has connected 39 of 41 industries. I connected the one oil pump because it was inside the houses and I had to remove a townhouse. However, the connection is now at a standstill because the refinery is constantly overcrowded from the other side.

However, the map is road-heavy. Probably due to the topography.

Simutrans 123.0.0.2 r10987+
pak64 123 r2102
Script AI Rail r0.9.2

pak64_512x448_1943_ski.sve 850 kByte (until July 21, 2026)


The current 9 versions of the script AI can lead to errors in older versions. However, you don't have to.

The most important changes are:
  • Alternating industrial strategy at the start of the AI and no longer according to player position
  • every newly launched AI of an industrial strategy starts later; This means that the first 2 AIs start immediately, the next 2 then after a waiting time, the next 2 then after another waiting time, etc.
    This prevents the previously common practice of building routes in parallel
  • There are also construction breaks built in; If an end user has been developed, the construction pause is longer than in other industries
  • Combined lines now also have a cost calculation, so they shouldn't lead to ruin as often

Most of the debug messages have also been removed.

There can still be errors at double ways (incorrectly constructed signals). Especially in left-hand traffic, because I haven't tested it yet.

More mountainous maps are still problematic. Large industrial distances are also likely to cause problems.

Maps with a lot of water are also critical because many bridges will be built there. Or small areas of water get a ship connection. But ships are usually expensive and so bring capital into the red relatively quickly. If capital is in the red, no routes will be built. The exception is combined routes that have been started and should be completed.



some more feedback would be very welcome


For script AI games it would be helpful if monthly autosave was activated. Because in the event of errors, a real-time score is available that can help me correct the error.

Andarix

Fully developed book chain from a script AI Rail.

script-ai-books.jpg

Andarix

This is surprising to me too. The script AI builds a train route with stations numbering 11! Fields are long.

pak64.nippon 0.6.2

11er_station.png

Andarix

last changes

Longer stations as 6 then build longer double ways.

not full testet, include in the next simutrans release

longer_double_ways.png