ChooChoo, a train network AI

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

I don't know :-/ I tried checking whether each tile of rail built was actually built, as far as the API could tell me. Might be an OpenTTD bug, but I'd sooner expect my own code ;)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: ChooChoo, a train network AI

Post by planetmaker »

I just run a test round. It seems that the AI indeed removes those tiles on his own. They have been built (I've seen it) - and later they were missing. Solving this issue would put your AI seemingly among the top performers of the AIs I have running concurrently. I guess the errors I got are only those which are already reported above (non-critical ones):
Attachments
some errors
some errors
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: ChooChoo, a train network AI

Post by planetmaker »

But... give it some time (13 years) and it can come up with very nice constructions, those which I truely enjoy seeing built by an AI.
Attachments
A small network with hub
A small network with hub
The hub
The hub
Weired but functional connection of the station in the upper part of the screenshot
Weired but functional connection of the station in the upper part of the screenshot
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

Cool :D
Interesting map, too. Glad to hear it's still doing well! Why do they keep releasing new games, preventing me from tinkering with it? ;)
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: ChooChoo, a train network AI

Post by Kogut »

Fix for railway running away from front of station:

in file builder.nut

Old version:

Code: Select all

369 local station = AIStation.GetStationID(location);
370 foreach (index, entry in network.stations) {
New:

Code: Select all

369 local station = AIStation.GetStationID(location);
370 if(AIVehicleList_Station(station).Count()>0)return; //diff
371 foreach (index, entry in network.stations) {
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: ChooChoo, a train network AI

Post by ChillCore »

Hello Michiel,

I was toying a bit around with 14 AI's enabled and I noticed something strange.

I have been playing with NuTracks and YARSS ever since they were made but choochoo has a problem with NuTracks.
When it builds its rail tracks it uses the track planning tracks instead of one of the other options.
Trains are not build and choochoo keeps on building track.

It is funny to see what choochoo is planning but I guess this is not the intention. ;)
Other than that I like how choochoo rolls.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: ChooChoo, a train network AI

Post by Zuu »

I took a look at http://noai.openttd.org/docs/1.0.0/classAIRail.html to see what chose criterias there is in the API. And just as what I guessed, the last features for eg. track speed are not added. That said, there is API functions to see what engines that can run on what track type. Still, the more track types came very late before 1.0. Perhaps make a suggestion for AIRail.GetSpeed(rail_type) and other functions depending on what the GRFSpec can do with rails.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: ChooChoo, a train network AI

Post by ChillCore »

Zuu wrote: I took a look at http://noai.openttd.org/docs/1.0.0/classAIRail.html to see what chose criterias there is in the API. And just as what I guessed, the last features for eg. track speed are not added. That said, there is API functions to see what engines that can run on what track type. Still, the more track types came very late before 1.0. Perhaps make a suggestion for AIRail.GetSpeed(rail_type) and other functions depending on what the GRFSpec can do with rails.
You may want to have a looksie at r19591 before opening a flyspray task.
The Force works in mysterious ways ... (and fast :) )
Thank you Yexo.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
HUgo8745
Engineer
Engineer
Posts: 29
Joined: 11 Feb 2010 20:05

Re: ChooChoo, a train network AI

Post by HUgo8745 »

This is ChooChoos train trying to run to Senington, But it cant because its not connected. I dont know what happened, really...
Attachments
Obama & Co., 16th Apr 1963.png
Obama & Co., 5th Oct 1963.png
Obama & Co., 3rd Oct 1963.png
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

Thanks for the bug report - it's a known problem, which I still haven't fixed, unfortunately.
HUgo8745
Engineer
Engineer
Posts: 29
Joined: 11 Feb 2010 20:05

Re: ChooChoo, a train network AI

Post by HUgo8745 »

Another one, this time it removed its terminus station. But except for these bugs its a very good AI.
Attachments
Ranpool Bridge Transport, 12th May 1950.png
Ranpool Bridge Transport, 12th May 1950#1.png
Ranpool Bridge Transport, 12th May 1950#2.png
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

New version available! The long awaited bug fix, and some cosmetics:
- junctions now get a name in the form of a waypoint, which makes debug output indicating what it's doing much easier to read (I like how it looks, but this will become optional once I implement... options)
- better cleanup of dead track (try blocking a path being built)

Tarball is in the first post, but BaNaNas is giving me trouble. When I try to update it, I get "Unexpected error while uploading." If I make a new version instead, I get "A file with this name already exists". Hopefully tomorrow!
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

And another update. Details in the first post - main improvements are settings (max bridge length, number of single line tracks to start with, whether to place waypoints at junctions) and better station placement at towns.
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

It's in BaNaNas! For future me: upload a ZIP file :)
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: ChooChoo, a train network AI

Post by Kogut »

Is it possible to do sth with giant CPU usage during searching for crossing? Maybe small Sleep(1) command may help.
It is irritating because after connecting everything possible cc starts to lag game.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: ChooChoo, a train network AI

Post by Lord Aro »

something i've noticed:
on huge maps (2048x2048) with many thousands of towns, choochoo spends about a year and a half searching for its initial stations - perhaps stop it after 100 connections or something?
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: ChooChoo, a train network AI

Post by Kogut »

It stops after first good connection, probably it have problems with estimating is it good connection for huge maps.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

Kogut wrote:Is it possible to do sth with giant CPU usage during searching for crossing? Maybe small Sleep(1) command may help.
It is irritating because after connecting everything possible cc starts to lag game.
I'll see what I can do. It should already be much better; once it concludes the map is full it'll start sleeping for one day intervals.
Lord Aro wrote:something i've noticed:
on huge maps (2048x2048) with many thousands of towns, choochoo spends about a year and a half searching for its initial stations - perhaps stop it after 100 connections or something?
That's the only part of it that is affected by map size. I'm not sure how to handle this - it's important that it picks decent spots for its initial routes, or it may go bankrupt or grow very slowly. However, that currently involves looking at all the cities on the map and checking if they have a potentially interesting neighbour. I'll see if I can redesign this bit!
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

Update!

ChooChoo now starts with cargo trains instead of (single track) passenger lines, which should provide a more stable income when starting off, especially in the deserts with their tiny towns. Note that you can turn these off, but it'll need a larger starting loan to get going. This also fixes the slow startup: even on 2048x2048 maps, it'll start nearly instantly.

It now places a sign where it's currently working and what it's doing. This can be turned off in its settings (all settings can be changed during the game).

I've made the pathfinder multiplier a setting too, so you adjust the tradeoff between speed and optimality. This is tied to difficulty levels: on hard, it's really fast, but potentially really ugly. Give it a go :)

New tarball in the usual spot; BaNaNas coming up.
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel »

It should really have a lake detector... the pathfinder is still slow when it tries to find a route across or around a large body of water. Never mind, just thinking out loud :) It's fun giving it infinite money and watching it spew forth all over the map :)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 4 guests