Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sat May 26, 2018 12:12 pm

All times are UTC




Post new topic  Reply to topic  [ 10 posts ] 
Author Message
 Post subject: TracAI
PostPosted: Wed May 27, 2015 12:58 pm 
Offline
Engineer
Engineer

Joined: Wed May 27, 2015 12:10 pm
Posts: 2
Hi, I started playing this game recently and got really hooked up in it. So I decided to try write new AI (also I needed a topic for my bachelor thesis :) ). This is my first attempt to create AI. I would really appreciated posting bugs here if someone finds any.

Implemented:
- trains (town-to-town and industry-to-industry routes)
- reusing accepting industries stations
- aircrafts (passengers and mail only) note: this is modified version of WormAI
- choosing ai speed (difficulty)
- save/load function
- demolishing unfinished or unused routes

Known issues:
- signaling is not perfect (sometimes creates deadlock)
- sometimes after a while it stops buying new vehicles (buying does not suceed for unknown reasons)

This AI does not have NewGRF support (meaning only that it has not been tested) so if anyone tries it with NewGRF please post here if there were any issues or not.


Top
   
 Post subject: Re: TracAI
PostPosted: Wed May 27, 2015 4:41 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 880
I'm trying it right now.
The AI is remarkably stable for a first release so far, still going strong after 20 years. The only problem is that it only has 12 trains and 7 aircraft currently (I've seen more aircraft before, one of them probably crashed). The terrain is mountainous, maybe the pathfinder is having quite a hard time.

I am amazed to see that the AI already does some railway networking, good job on that :) And I'm especially happy that we have another multi-profile AI (trains and aircraft, passengers and freight) :)

There are two problems I see so far:
  • You mentioned that the signalling is not perfect. I fail to see how this possibly deadlocks (apart from overloading the network with so many trains that there is no space anymore), but the main problem is that you're mixing path signals with block signals. So either use path signals only (simply delete those exit signals at the platforms and use path signals everywhere else) or block signals only (change all your current path signals to simple block signals).
  • It's really nice to see that it removes unused routes, but some sections are not cleared properly.
    Attachment:
    TracAI tracs.png
    TracAI tracs.png [ 134.79 KiB | Viewed 3379 times ]

And as I was writing this post, the AI crashed :(
Attachment:
TracAI crash.png [29.37 KiB]
Downloaded 14 times


Anyway, it's nice to see a new AI using trains, best of luck for your thesis :)


Top
   
 Post subject: Re: TracAI
PostPosted: Fri May 29, 2015 1:12 am 
Offline
Engineer
Engineer

Joined: Wed May 27, 2015 12:10 pm
Posts: 2
Thanks for the quick reply, did not expect that :). Also thanks for the signal tip. I am quite new to the OpenTTD and signals are still quite confusing to me.

I have to admit that my AI doesn't build many routes, therefore does not have many trains (in contrast to other AIs).

I will definitely look at the demolishing (why it does not demolishes station tracks). I am quite suprised that it did not come up when i tested it (I had to be thorough because ot the thesis), though it will be probably after my finals.

For the signal deadlock, it happens rarely (that is why it is not fixed yet). Sometimes pathfinder uses part of route even from opposite direction (meaning it uses route between two signals). This causes that signal is one tile after a 'exit' junction and if trains stops at that signal it can block both ways. It needs to have certain amount of trains (but not many that you could call it jam).

I have a question about your crash report (btw. thanks for that). How big was your map when the AI crashed? It will help me understand the problem.


Top
   
 Post subject: Re: TracAI
PostPosted: Fri May 29, 2015 4:23 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 880
According to the logs, it seems that TracAI was still alive at the time of my last autosave, at least it says something about loading the save state when I load up the savegame. It's a 512x512 map, see it attached az autosave0.sav.

But I found something that may be more interesting to you: the AI crashes instantly upon loading one of my autosaves, I attached that one as well as autosave8.sav.


Attachments:
autosave0.sav [564.64 KiB]
Downloaded 36 times
autosave8.sav [541.54 KiB]
Downloaded 38 times
autosave8 crash.png [30.29 KiB]
Downloaded 10 times
Top
   
 Post subject: Re: TracAI
PostPosted: Sat May 30, 2015 10:44 am 
Offline
Engineer
Engineer

Joined: Sun Jul 14, 2013 12:33 pm
Posts: 86
Location: Netherlands
Nice to see that you found my WormAI useful enough to reuse especially since I still lack time and motivation to work on it myself.
I haven't looked at your AI yet but good luck!


Top
   
 Post subject: Re: TracAI
PostPosted: Mon Aug 10, 2015 12:34 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Tue Apr 08, 2008 9:47 am
Posts: 228
Location: Finland
In a very vanilla game from 1950 to 2050 against AdmiralAI and some other AIs that crashed at some point or another, TracAI won by a decent margin.

Some observations about its behavior:

It pathfinds both ways between two stations separately. This seems wasteful in terms of planning time, as a bi-directional route is very likely to be optimal for the two tracks to run alongside one another.

It begins pathfinding from the destination to the source, and will not populate the tracks with trains until both directions have been pathfound. It could build the source-destination track first and put a train on it, while pathfinding the other direction, to make a bit more money.

It builds depots at the exit of the destination station, and buys trains there. That means that those trains have to make half the trip empty, pointlessly. It should rather build a depot and buy trains at the entrance to the source, so they can start loading faster.


Top
   
 Post subject: Re: TracAI
PostPosted: Fri Apr 29, 2016 3:03 pm 
Offline
Engineer
Engineer

Joined: Sun Jul 14, 2013 12:33 pm
Posts: 86
Location: Netherlands
TracAI crashed after being in second place for a long time.


Attachments:
Unnamed, 1987-10-25.png [732.05 KiB]
Not downloaded yet
Top
   
 Post subject: Re: TracAI
PostPosted: Tue May 03, 2016 8:51 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Feb 26, 2015 12:52 am
Posts: 212
Survived 100 years without crashing for me, though. Tested it as solo since 1950-2051

I noticed a train jam and a few abandoned tracks laying around.


Attachments:
TracAI, 1st Jan 2051.sav [454.29 KiB]
Downloaded 29 times
TracAI #2, 2051-02-09.png
TracAI #2, 2051-02-09.png [ 149.74 KiB | Viewed 1898 times ]
openttdCore2.cfg [10.75 KiB]
Downloaded 30 times

_________________
Formerly known as Samu
Top
   
 Post subject: Re: TracAI
PostPosted: Mon Jun 20, 2016 10:26 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Feb 26, 2015 12:52 am
Posts: 212
TracAI v1 OpenTTD 1.6.1-RC1

I took TracAI for a train competition 100 year solo test, starting from 1950. He actually started really strong, beating the other competitors for a short period of time, but he started to fall as soon as he got to manage train jams. It creates way so many trains that they can't physically fit on the entire connection start to finish. It got to a point where his profits actually started to diminish. It's been a constant struggle ever since. The script however, died by 2015.

Here's part of the log.

Quote:
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] Selling not suceeded ERR_VEHICLE_NOT_IN_DEPOT
dbg: [script] [0] [I] 2015-03-08 --- Urgent Tasks Done ---
dbg: [script] [0] [W] Building new industry rail route
dbg: [script] [0] [I] Finding industry pair...
dbg: [script] [0] [I] Suitable pair found
dbg: [script] [0] [I] IndustryPair - Industry PRO: Nedinghead Coal Mine Industry ACC: Fort Padham Power Station Cargo: COAL Distance: 114 Value: 268800000
dbg: [script] [0] [I] ipro tilelist not found
dbg: [script] [0] [I] Finding industry pair...
dbg: [script] [0] [I] Suitable pair found
dbg: [script] [0] [I] IndustryPair - Industry PRO: Shorningstone Coal Mine Industry ACC: Senfingburg Power Station Cargo: COAL Distance: 84 Value: 268800000
dbg: [script] [0] [I] iacc tilelist not found
dbg: [script] [0] [I] Finding industry pair...
dbg: [script] [0] [I] Suitable pair found
dbg: [script] [0] [I] IndustryPair - Industry PRO: Shorningstone Coal Mine Industry ACC: Fenfingley Power Station Cargo: COAL Distance: 154 Value: 268800000
dbg: [script] [0] [I] iacc tilelist not found
dbg: [script] [0] [I] Finding industry pair...
dbg: [script] [0] [I] Suitable pair found
dbg: [script] [0] [I] IndustryPair - Industry PRO: Shorningstone Coal Mine Industry ACC: Wradingbury Power Station Cargo: COAL Distance: 160 Value: 268800000
dbg: [script] [0] [W] pro station not build
dbg: [script] [0] [I] 2015-03-09 Managing rail routes
dbg: [script] [0] [I] Removing route 54
dbg: [script] [0] [I] Removing route 153
dbg: [script] [0] [I] Removing route 1440
dbg: [script] [0] [I] Removing route 1481
dbg: [script] [0] [I] Removing route 1876
dbg: [script] [0] [I] Removing route 2049
dbg: [script] [0] [I] Removing route 2280
dbg: [script] [0] [I] Saving TracAI game data. Used ops: 38717
dbg: [script] [0] [I] Removing route 2653
dbg: [script] [0] [I] Removing route 3624
dbg: [script] [0] [S] Your script made an error: parameter 1 has an invalid type 'null' ; expected: 'integer'
dbg: [script] [0] [S]
dbg: [script] [0] [S] *FUNCTION [RemoveRoute()] tracai-1.0\rail_manager.nut line [856]
dbg: [script] [0] [S] *FUNCTION [ManageRailRoutes()] tracai-1.0\rail_manager.nut line [912]
dbg: [script] [0] [S] *FUNCTION [Start()] tracai-1.0\main.nut line [295]
dbg: [script] [0] [S]
dbg: [script] [0] [S] [is_depot_acc_used_by_more_routes] false
dbg: [script] [0] [S] [is_depot_pro_used_by_more_routes] false
dbg: [script] [0] [S] [is_station_acc_used_by_more_routes] false
dbg: [script] [0] [S] [route_idx] 146
dbg: [script] [0] [S] [route] INSTANCE
dbg: [script] [0] [S] [route_id] 3624
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [i] 146
dbg: [script] [0] [S] [routes_len] 155
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [build_air_delay_factor] 1
dbg: [script] [0] [S] [build_rail_delay_factor] 1
dbg: [script] [0] [S] [sleepingtime] 100
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] The script died unexpectedly.
One of the running scripts crashed. Please report this to the script author with a screenshot of the AI/Game Script Debug Window


Attachments:
TracAI, 1st Apr 2015.sav [3.6 MiB]
Downloaded 27 times
TracAI, 1st May 2015.sav [3.08 MiB]
Downloaded 27 times
openttdCore4.cfg [11.23 KiB]
Downloaded 29 times

_________________
Formerly known as Samu
Top
   
 Post subject: Re: TracAI
PostPosted: Sun Jan 07, 2018 10:30 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Feb 26, 2015 12:52 am
Posts: 212
excessive cpu usage in valuator function

Quote:
dbg: [script] [0] [I] (start: 2107-02-02; stop: 2121-10-01)
dbg: [script] [0] [W] path_pro_acc not found
dbg: [script] [0] [I] Saving TracAI game data. Used ops: 2754
dbg: [script] [0] [W] ticker: 1700
dbg: [script] [0] [W] Building new town rail route
dbg: [script] [0] [I] Saving TracAI game data. Used ops: 2754
dbg: [script] [0] [I] Saving TracAI game data. Used ops: 2754
dbg: [script] [0] [I] Saving TracAI game data. Used ops: 2754
dbg: [script] [0] [I] Saving TracAI game data. Used ops: 2754
dbg: [script] [0] [S] Your script made an error: excessive CPU usage in valuator function
dbg: [script] [0] [S]
dbg: [script] [0] [S] *FUNCTION [IsTileRectagleFlatAndBuildable()] tracai-1.0\util.nut line [93]
dbg: [script] [0] [S] *FUNCTION [Valuate()] tracai-1.0\valuators.nut line [60]
dbg: [script] [0] [S] *FUNCTION [Valuate()] NATIVE line [-1]
dbg: [script] [0] [S] *FUNCTION [GetTownStationSpotList()] tracai-1.0\rail_builder.nut line [770]
dbg: [script] [0] [S] *FUNCTION [CreateNewTownRoute()] tracai-1.0\rail_manager.nut line [191]
dbg: [script] [0] [S] *FUNCTION [Start()] tracai-1.0\main.nut line [282]
dbg: [script] [0] [S]
dbg: [script] [0] [S] [list] INSTANCE
dbg: [script] [0] [S] [tile_to] 135409
dbg: [script] [0] [S] [tile_from] 130800
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [north_nw_se] false
dbg: [script] [0] [S] [north_ne_sw] false
dbg: [script] [0] [S] [self] INSTANCE
dbg: [script] [0] [S] [tile] 130800
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [valuator] INSTANCE
dbg: [script] [0] [S] [other_town_direction] 8
dbg: [script] [0] [S] [town_tile] 125164
dbg: [script] [0] [S] [town_tilelist] INSTANCE
dbg: [script] [0] [S] [radius] 4
dbg: [script] [0] [S] [number_of_tracks] 2
dbg: [script] [0] [S] [platform_length] 5
dbg: [script] [0] [S] [other_town] 12
dbg: [script] [0] [S] [town] 158
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [i] 1
dbg: [script] [0] [S] [town_pair_array] ARRAY
dbg: [script] [0] [S] [railtype] 3
dbg: [script] [0] [S] [cost] NULL
dbg: [script] [0] [S] [money_reservationID] NULL
dbg: [script] [0] [S] [station_acc] NULL
dbg: [script] [0] [S] [station_pro] NULL
dbg: [script] [0] [S] [town2_tilelist] INSTANCE
dbg: [script] [0] [S] [town1_tilelist] INSTANCE
dbg: [script] [0] [S] [best_town_pair] NULL
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [build_air_delay_factor] 1
dbg: [script] [0] [S] [build_rail_delay_factor] 1
dbg: [script] [0] [S] [sleepingtime] 100
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] Your script made an error: excessive CPU usage in valuator function
dbg: [script] [0] [S]
dbg: [script] [0] [S] *FUNCTION [GetTownStationSpotList()] tracai-1.0\rail_builder.nut line [770]
dbg: [script] [0] [S] *FUNCTION [CreateNewTownRoute()] tracai-1.0\rail_manager.nut line [191]
dbg: [script] [0] [S] *FUNCTION [Start()] tracai-1.0\main.nut line [282]
dbg: [script] [0] [S]
dbg: [script] [0] [S] [valuator] INSTANCE
dbg: [script] [0] [S] [other_town_direction] 8
dbg: [script] [0] [S] [town_tile] 125164
dbg: [script] [0] [S] [town_tilelist] INSTANCE
dbg: [script] [0] [S] [radius] 4
dbg: [script] [0] [S] [number_of_tracks] 2
dbg: [script] [0] [S] [platform_length] 5
dbg: [script] [0] [S] [other_town] 12
dbg: [script] [0] [S] [town] 158
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [i] 1
dbg: [script] [0] [S] [town_pair_array] ARRAY
dbg: [script] [0] [S] [railtype] 3
dbg: [script] [0] [S] [cost] NULL
dbg: [script] [0] [S] [money_reservationID] NULL
dbg: [script] [0] [S] [station_acc] NULL
dbg: [script] [0] [S] [station_pro] NULL
dbg: [script] [0] [S] [town2_tilelist] INSTANCE
dbg: [script] [0] [S] [town1_tilelist] INSTANCE
dbg: [script] [0] [S] [best_town_pair] NULL
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [build_air_delay_factor] 1
dbg: [script] [0] [S] [build_rail_delay_factor] 1
dbg: [script] [0] [S] [sleepingtime] 100
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] The script died unexpectedly.
One of the running scripts crashed. Please report this to the script author with a screenshot of the AI/Game Script Debug Window

_________________
Formerly known as Samu


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.