Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Oct 18, 2017 4:36 pm

All times are UTC




Post new topic  Reply to topic  [ 248 posts ]  Go to page 1 2 3 4 513 Next
Author Message
PostPosted: Wed Aug 19, 2009 9:26 am 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 873
Hi all,
Let me join this wave of new AIs. I'm trying to remake the old AI in the NoAI framework, of course with some changes. It uses road vehicles, trains and aircraft. As it is intended to be similar to the old AI, it is a weak competitor, so don't expect too much from it. I did not remake the road/rail building style of the old AI, I'm using the library pathfinder. I have to compensate that the AI cannot cheat anymore with terraforming.
Attachment:
SimpleAI.png
SimpleAI.png [ 98.61 KiB | Viewed 22871 times ]


Features:
  • Uses road vehicles, trains and aircraft
  • Supports all non-NewGRF cargo, and most NewGRF cargo as well
  • Goes for subsidies
  • If there are no subsidies, it chooses the cargo and the industries/towns randomly.
  • It uses the library pathfinder.
  • It corrects the route if it's interrupted while building.
  • It electrifies existing rail lines when the first electric engine is introduced.
  • It sells unprofitable vehicles and removes the route if all vehicles are sold.
  • Save/load compatibile
  • The handling of old vehicles is similar to the old AI, instead of using autorenew.
  • It upgrades existing bridges to newer ones if they're available.

Changelog:
v12
  • The AI now correctly calculates the minimum amount of money needed to invest in aircraft
v10
  • Alternate naming system for the company by 3iff
  • The inflation rate is now correctly handled as a float, possibly avoiding some bugs
v9
  • Fixed an overflow bug which could cause division by zero
v8
  • Fixed a bug related to saving games right after loading
v7
  • Updated to NoAI API version 1.2
  • Support for NewGRF trainsets
  • Support for range-limited aircraft
  • Avoid railtypes that do not support all cargoes
  • Fixed a crash when the game was saved between the construction of two stations
  • A more advanced road vehicle selection algorithm (from DictatorAI)
  • Fixed a rare road building bug
  • The AI now uses Road Pathfinder v4 and AyStar v6
v6
  • Added comments to the code
  • Written this readme
  • Refitting train wagons
  • Fix a bug when some old vehicles didn't get replaced at all
  • Support for NewGRF train stations
  • An option to use path signals at single rail stations
  • Avoid going bankrupt because of station maintenance costs
v5
  • Plane support
  • Upgrading existing bridges
  • An option to use PBS signals instead
  • Bugfixes
v4
  • Bugfixes again
v3
  • Bugfix
v2
  • Bugfixes
  • Updated to NoAI API version 1.0
  • Changeable settings in-game
  • An option to use two-way signals (like in TTO)
v1
  • First Bananas release
  • A little change in pathfinder penalties
beta3
  • Bugfixes
  • Checking vehicles which are sitting in the depot
beta2
  • Improvements in save/load
  • Adding wagons to existing trains
  • An option to make the AI slower as the time progresses
  • Bugfixes
beta1
  • Basic save/load support
  • Adding road vehicles to an existing route, up to a limit chosen by the user
  • Replacing older models with newer ones
  • Added setting to specify the number of days to wait between building two routes
  • Flipping passing lane sections
  • A bit more consistency with the HQ builiding behaviour of the old AI, added a setting to build the HQ in a town
alpha5
  • Double railway lines (in the style of the old AI)
  • One more wagon is added to a train if the engine has only one unit
  • Combined passenger/mail trains, no more pure mail trains
  • Minor bugfixes
alpha4.1
  • A little bugfix
alpha4
  • Correcting the rail line if the AI gets interrupted while building
  • Basic money handling, paying loan back
  • Support for other railtypes, electrifying existing lines
  • Detection of "Disable trains/roadvehicles for computer" under Advanced Settings
  • Bugfixes
alpha3
  • Train support (single point-to-point routes so far)
  • Added settings to use trains or road vehicles only
alpha2
  • Added setting to configure the chance of going for a subsidy
  • Added setting to configure competition level based on the last month transported percentage
  • Basic event handling
  • Selling unprofitable vehicles and deleting empty routes
  • Refitting road vehicles
alpha1
  • Basic version, road vehicles only

Dependencies:
  • Pathfinder.Road v4
  • Pathfinder.Rail v1
  • Graph.Aystar v4 (a dependency of the rail pathfinder)
  • Graph.Aystar v6 (a dependency of the road pathfinder)
  • Queue.BinaryHeap v1 (a dependency of Graph.Aystar)
These sould be installed in content_download\ai\library if you download the AI from here.

I'd like to say thanks to the writer(s) of the library pathfinder, I couldn't have done without it!
Also thanks to 3iff for his contribution which enables the AI to use custom company names instead of the default names.
The AI contains code from PAXLink, NoCAB and DictatorAI, so thanks for Zuu, Morloth and krinn for writing that.
I'd also like to say thanks to all those who tested this AI.

Version 12 is downloadable here.


Attachments:
SimpleAI-12.tar [220 KiB]
Downloaded 154 times


Last edited by Brumi on Wed May 10, 2017 10:05 pm, edited 41 times in total.
Top
   
PostPosted: Wed Aug 19, 2009 11:10 am 
Offline
Route Supervisor
Route Supervisor
User avatar

Joined: Fri May 18, 2007 12:47 pm
Posts: 485
Location: Oxford
Brumi wrote:
I'd like to say thanks to the writer(s) of the library pathfinder, I couldn't have done without it! :bow:

Here here! :bow:

Also - why no NewGRF support? It's dead simple to integrate, just use the lists rather than any hard-coded values ?(

_________________
Real Tycoons do it on Trains!

JAMI: Just Another Moronic Intelligence


Top
   
PostPosted: Thu Aug 20, 2009 6:45 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 873
Xander wrote:
why no NewGRF support?

Well, it's not totally true that it has no NewGRF support at all. If I teach the AI tho refit its vehicles it will be fairly compatibile with some basic NewGRFs that doesn't change the game too much. The current version shouldn't have problems with the Generic Tram Set, for example. What I want to avoid is the more 'radical' GRFs, which change costs or even the economy. Currently the AI can't cope with them.
My primary goal is to remake the old AI in some way (which didn't have NewGRF support), so let me concentrate on that first. OK I will introduce refitting compatibility, but I don't want to deal with the ECS vectors for now.
I will change that notification in the first post. Sorry if that is too harsh.


Top
   
PostPosted: Thu Aug 20, 2009 7:10 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Wed Dec 07, 2005 7:22 pm
Posts: 272
Brumi wrote:
Xander wrote:
why no NewGRF support?

Well, it's not totally true that it has no NewGRF support at all. If I teach the AI tho refit its vehicles it will be fairly compatibile with some basic NewGRFs that doesn't change the game too much. The current version shouldn't have problems with the Generic Tram Set, for example. What I want to avoid is the more 'radical' GRFs, which change costs or even the economy. Currently the AI can't cope with them.
My primary goal is to remake the old AI in some way (which didn't have NewGRF support), so let me concentrate on that first. OK I will introduce refitting compatibility, but I don't want to deal with the ECS vectors for now.
I will change that notification in the first post. Sorry if that is too harsh.


2cc seems to be the most popular train set. You might want to make a priority list of NewGrfs and support them in that order. NARS is easy. 2cc is slightly harder. ECS I haven't even considered.

_________________
Denver & Rio Grande Railroad AI


Top
   
PostPosted: Thu Aug 20, 2009 8:49 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Mar 06, 2004 11:51 pm
Posts: 1493
Location: The sunny side of Alps
Really nice effort, Brumi.
I have similar thing planned to do when I have the time and perhaps when the framework is made easier to cope with (one such effort being the Library)... :-)

By the way - Dustin - is it really necessary to support 2cc/NARS, etc. by some special way - I mean doesn't the AI author only have to take care of vehicle handling through comparing costs/HP/speed and then choose based on that?

_________________
NewGRF: Oil Wells in Temperate terrain now can Increase production, Better vehicle names, Use-able default aircraft, Oil Rig for Snowland and Desert, Speed for Suspension bridges.
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.

Keep 'em rollin'!


Top
   
PostPosted: Thu Aug 20, 2009 9:43 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Wed Dec 07, 2005 7:22 pm
Posts: 272
SirkoZ wrote:
Really nice effort, Brumi.
I have similar thing planned to do when I have the time and perhaps when the framework is made easier to cope with (one such effort being the Library)... :-)

By the way - Dustin - is it really necessary to support 2cc/NARS, etc. by some special way - I mean doesn't the AI author only have to take care of vehicle handling through comparing costs/HP/speed and then choose based on that?


I had some suprises when I switched between default to NARS. I had actaul crashes.

I think the logic to join the wagons to the engine was a problem. When I switched to 2cc my AI never built a train. The "best" locomotive costs more than the starting loan. So I had to add some logic to buy the best, yet affordable engine. So in the AI was code compatible, but needed some tweaks to actually run a profitable route. D&RG still goes bankrupt often with 2cc on a rough map.

With D&RG if you run the default set it runs best with a low "fiscal restraint". If you run 2cc it will go bankrupt with anything less than super "fiscal restraint". So I added that as a setting to the AI.

So, just because you work in default doesn't mean you will work with the other sets.

_________________
Denver & Rio Grande Railroad AI


Top
   
PostPosted: Fri Aug 21, 2009 8:24 am 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 873
Thank you for the replies.
It's true that my biggest fear is the 2cc set with its high prices, but I didn't mention it because I have no train support yet. The other part is engine selection, as with the default set it is quite good to choose the strongest and fastest engine. The current code sorts the vehicles by maximum speed, and excludes articulated vehicles. NewGRF road vehicle sets (at least the more well-known ones) should be fairly easy to support, refitting should do the trick. Another thing I should do is to handle the case when there are no suitable vehicles available (e. g. the eGRVTS at early dates, when all vehicles are articulated).
Train engine selection will be much harder with NewGRF sets. I rarely play with NewGRF sets, and even I have trouble with choosing the right engine. But first the railway construction will be a pretty hard task for me. Those single lane point-to-point routes should not be so difficult to do, but I will certainly have lots of difficulties with the old AI-like double rails. (you know, two stations first, then two passing lane sections, then connecting them) I will surely have to deal with some terraforming.
Anyway, how do you decide if you will have enough money to build a route? Currrently the AI tries to build a new route if it has more than 90,000 pounds. But that is certainly not the correct routine.


Top
   
PostPosted: Fri Aug 21, 2009 6:06 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Wed Dec 07, 2005 7:22 pm
Posts: 272
Brumi wrote:
Thank you for the replies.
It's true that my biggest fear is the 2cc set with its high prices, but I didn't mention it because I have no train support yet. The other part is engine selection, as with the default set it is quite good to choose the strongest and fastest engine. The current code sorts the vehicles by maximum speed, and excludes articulated vehicles. NewGRF road vehicle sets (at least the more well-known ones) should be fairly easy to support, refitting should do the trick. Another thing I should do is to handle the case when there are no suitable vehicles available (e. g. the eGRVTS at early dates, when all vehicles are articulated).
Train engine selection will be much harder with NewGRF sets. I rarely play with NewGRF sets, and even I have trouble with choosing the right engine. But first the railway construction will be a pretty hard task for me. Those single lane point-to-point routes should not be so difficult to do, but I will certainly have lots of difficulties with the old AI-like double rails. (you know, two stations first, then two passing lane sections, then connecting them) I will surely have to deal with some terraforming.
Anyway, how do you decide if you will have enough money to build a route? Currrently the AI tries to build a new route if it has more than 90,000 pounds. But that is certainly not the correct routine.


DR&G decides to build a new route if it has some fraction of the max loan available as cash. With low restraint it's 50%+ with super restraint it 100%+. So it's automatically scaled for inflation.

_________________
Denver & Rio Grande Railroad AI


Top
   
PostPosted: Sat Aug 22, 2009 12:00 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 873
I posted the alpha2 version in the main post. You can see the changelog there.
Now the AI supports basic road vehicle sets, so it should work with (e)GRVTS. It doesn't use articulated vehicles, so it won't do anything if there are only horse carriages available.
I added event handling, from now on the AI will sell its unprofitable vehicles. It's quite a slow process, it only happens when the AI gets the 'vehicle unprofitable' notification from the game engine.
Still no progress was made in the field of money handling, I'm thinking about that. :oops: Please report it if the AI runs out of money while building the route!
Thank you for testing,
Brumi


Top
   
PostPosted: Sat Aug 22, 2009 2:11 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sun Mar 22, 2009 7:24 am
Posts: 81
Location: Haarlem, The Netherlands
I've been testing SimpleAI. I like how it works, really fast, no difficult calculations (as far as I can see in the log)
Suggestion: try to re-use stations. It built a drop off for iron ore and a pick up for steel. I don't know whether that's necessary.


Top
   
PostPosted: Sat Aug 22, 2009 2:54 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9021
Location: Sol d
Eliandor wrote:
Suggestion: try to re-use stations. It built a drop off for iron ore and a pick up for steel. I don't know whether that's necessary.

It's actually good practise to not mix drops and pickups together in one station. It saves you jams... especially that situation where nothing can be delivered anymore due to all slots being taken by pickup trains thus that no delivery can happen.

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
PostPosted: Sat Aug 22, 2009 3:04 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sun Mar 22, 2009 7:24 am
Posts: 81
Location: Haarlem, The Netherlands
planetmaker wrote:
It's actually good practise to not mix drops and pickups together in one station. It saves you jams... especially that situation where nothing can be delivered anymore due to all slots being taken by pickup trains thus that no delivery can happen.


Hm OK, point taken XD


Top
   
PostPosted: Sun Aug 23, 2009 6:17 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 873
Thank you for testing. :)
It's a good idea that the AI should re-use stations (at least drop-off stations), but I'm afraid I won't be able to do it in the early alpha stage. First I'd like to get done with emulating the old AI (at least trains), then I can concentrate on some advanced features. Re-using stations would need station expanding to be implemented, which is not an easy task for me. So I'll se what I can do, but don't expect it to be implemented too soon.
Thanks again for testing.


Top
   
PostPosted: Sat Aug 29, 2009 4:43 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 873
I uploaded alpha3 to the first post.
The most visible change is the train support, from now on the AI will use trains as well. 8) So far I only implemented single point-to-point routes. I will have a hard time getting those old AI style double railways to work... :?
It is supposed to remove the rail line if the train is unprofitable, so please report it if it doesn't do so!
Currently it chooses between trains and road vehicles based on pure chance, I will do something about that until the next release. It also doesn't notice if it gets interrupted while building the railway.
Thanks for testing.


Top
   
PostPosted: Sat Aug 29, 2009 4:53 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 308
Location: Indonesia
Good Job :D

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Top
   
PostPosted: Sat Aug 29, 2009 4:57 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 873
fanioz wrote:
Good Job :D

Thank you :)

Oops... I forgot to remove a line from the code that was there just for debug reasons. I updated the .tar file in the main post. Nothing serious, it just removed unused rails very slowly.


Top
   
PostPosted: Sat Aug 29, 2009 6:20 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sun Mar 22, 2009 7:24 am
Posts: 81
Location: Haarlem, The Netherlands
Congrats on the new version. I tried it with 0.7.2 but it crashed. Just downloaded the latest nightly and that worked perfectly fine. Maybe you should add that as a note to your first post, to avoid confusion.

By the way, it builds lovely tracks. I know it's just the default pathfinder, but it really suits your simple AI. It's nice to play against because of it's "clean"-ness. :)


Top
   
PostPosted: Sat Aug 29, 2009 7:00 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 873
Thank you for the kind words. :)
Eliandor wrote:
I tried it with 0.7.2 but it crashed. Just downloaded the latest nightly and that worked perfectly fine.

Really? ?( I've always tested it with 0.7.2 so far, never tried the nightly. In fact, I'm developing it for 0.7.2, and I'll try to fit it for the latest stable release. In the nightly it may have minor problems (or even crash) because of the new subsidy management, but that's really a small issue. It should work just the other way round :D
Anyway, please post it here if you encounter that crash again. Probably it's a bug in the code.


Top
   
PostPosted: Sat Aug 29, 2009 7:06 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sun Mar 22, 2009 7:24 am
Posts: 81
Location: Haarlem, The Netherlands
Brumi wrote:
Really? ?( I've always tested it with 0.7.2 so far, never tried the nightly. In fact, I'm developing it for 0.7.2, and I'll try to fit it for the latest stable release. In the nightly it may have minor problems (or even crash) because of the new subsidy management, but that's really a small issue. It should work just the other way round :D
Anyway, please post it here if you encounter that crash again. Probably it's a bug in the code.


Alright... this is just weird. I downgraded to 0.7.2 again and tried once more, it didn't crash this time. It crashed two times before though o__0; well, I guess everything's cool then. I'll keep on the lookout for it though.


Top
   
PostPosted: Sat Aug 29, 2009 7:11 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sun Mar 22, 2009 7:24 am
Posts: 81
Location: Haarlem, The Netherlands
Wanted to add another teaser to what you have in your first post, something illustrating it's typical behaviour:

Attachment:
simpleAI_teaser.png
simpleAI_teaser.png [ 50.41 KiB | Viewed 23613 times ]


I can confirm that SimpleAI tries (and succeeds) to re-pathfind roads when blocked unexpectedly. Congrats once again :D
When the pathfinding fails completely, though, it does remove the stations, but not the route. Oh well.

Suggestions:
= make it build larger stations when the route is longer. In cities it's mostly not possible to build 4 tile stations at reasonable places, but close to industries, it may be.

Edt: removed bug report because it was already in your first post (train error correction)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 248 posts ]  Go to page 1 2 3 4 513 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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-2017 phpBB Limited

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