Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Dec 10, 2018 2:21 pm

All times are UTC




Post new topic  Reply to topic  [ 340 posts ]  Go to page 1 2 3 4 517 Next
Author Message
PostPosted: Tue Jul 07, 2009 1:33 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Jul 13, 2008 12:57 am
Posts: 313
Hi everyone, I would like to present ChooChoo, another train AI. I've tried to make something that builds "interesting", nice looking networks. For now, it just transports passengers and mail. It works by placing a four way crossing at a randomish location and extending its rail network to towns in 4 directions. When a destination town is "off to the side", it'll build a new crossing, connect the crossings and the station, and extend the newly placed crossing. This continues until the network can't be extended further. Then, it places a new seed crossing to build a new network. Here's a picture of the kind of network it builds:

Image

And here's a screenshot of a nice set of crossings (links to a bigger one):
Image

Picture of the new junction waypoints and station layout:
Image

Known limitations:
  • Limited load/save support (it'll "forget" the current work in progress).
  • It probably won't behave nicely when there's no trains available, so don't start the game in too early a year.
  • It cheats a bit by extending its station coverage with bus stations; this requires "build on town roads" to be enabled.
  • No train replacement except autorenew, but it will switch to new rail types when it starts a new network.
  • Requires 0.7.2 or newer; 1.0 works fine.

It'll play nice with multiple instances of itself because they randomize their starting spots. It's also independent of map size.

Notes for those who want to peek inside:
I've implemented the main processing loop as a "to do list" of tasks. Each task is represented by an object, holding enough state so tasks can be broken off (usually due to running out of money, but it could also be a VEHICLE_IN_THE_WAY, etc.) and resumed. For example, building a crossing is a task (with several subtasks) which then pushes four new tasks onto the queue to expand its four exits.
I'm defining crossings and stations in a local coordinate system which can be moved and rotated to a place on the map. For example, the terminus stations have a single representation from which the four orientations are derived. Feel free to steal bits and pieces that look useful :)

Anyway, enjoy!

Updates
2009-07-09:
- improved startup
- evaluate seed crossing locations before building
- transports mail
- restricted to one station per town

2009-07-12:
- clean up failed crossing exits instead of capping them with depots
- engine selection should now work with newgrfs
- money management to prevent bankrupcy

2009-07-13:
- don't block off crossings when expanding (can still accidentally block an unrelated one)
- start up with some cheap single track lines to get some revenue going

2009-07-16:
- add a fixed number (currently 3) trains per new station and send them to stations that need more trains the most

2009-08-04:
- save/load support
- clean up dead ends more neatly
- removed exit signals from crossings
- stations come with depots; less depots along tracks
- the usual handful of bug fixes

2010-05-17:
- fixed the broken tracks bug
- junctions now get a name in the form of a waypoint, making log output much easier to read (will probably become optional)
- better cleanup of dead track (try blocking a path being built)

2010-05-17:
- settings! Maximum bridge length, how many single track lines to start with, and whether to place waypoints at junctions are now configurable
- first train for a station gets full load orders to improve ratings
- build bus stations before trains to improve cargo production
- more options for station placement by considering the entire station area instead of just the "origin" tile
- handle events while waiting for money

2010-05-25:
- start with cargo, instead of passengers
- places signs showing what it's doing (optional)
- selectable path finder speed: trade off between speed and optimality (the new default is slightly faster than the old one)

2010-05-30:
- build a company HQ
- terrain levelling for stations
- plants trees to raise local authority ratings
- removed depots from tracks to prevent trains going into dead ends

2010-05-30a:
- fixed a terraforming bug

2010-06-05:
- fixed another terraforming bug
- cargo lines are now built single track at first, then extended to double track
- smaller terraforming footprint for crossings

2010-06-12:
- check for compatibility with game settings (allowed to build disjoint stations, drive through stations on town roads)
- cost estimates for bootstrap cargo lines
- single platform cargo stations
- save money to autorenew vehicles
- ignore very small (<200 population) towns
- a whole bunch of bug fixes, including one that would cause it to miss a lot of cargo opportunities

2010-07-01:
- bus service to improve ratings (and because it looks nice)
- improved track building: smoother curves, obstacle avoidance and better double track layout

2011-03-13:
- several start up and profit related improvements, including better cargo route selection
- double track: have the second track follow the first
- try to place more crossings to grow larger networks

2011-03-14:
- double track: REALLY have the second track follow the first

2011-03-19:
- bug fix: don't build multiple stations at the same source industry
- shorter passenger trains

2012-03-28:
Wow, over a year since the last update! And it's mostly bug fixes:
- handle maps with no industries, and large maps with lots of industries
- fixed "Inconsistent compare function"
- "desync" multiple ChooChoo AIs by having them sleep for a short random time so they don't all try to build the same cargo routes
- fixed crash when there are no wagons available for a cargo type

2017-08-26:
Holy crap, has it been over five years? :shock:
- fixed an issue where the AI would be killed for using too much CPU time inside a valuator function

_________________
Building Powargrid: a turn based strategy game


Last edited by Michiel on Fri Aug 25, 2017 10:07 pm, edited 38 times in total.

Top
   
PostPosted: Tue Jul 07, 2009 1:59 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Feb 07, 2008 2:06 pm
Posts: 378
Location: Glasgow
Congratulations Michiel,

I just toyed around with it a little bit and it looks pretty cool! One little thing though, you may want to use other software to pack your tar files, because OpenTTD didn't recognize your AI until I unpacked it...

But I really like the way you use these crossings, makes for some neat reuse of rail tracks. Are you btw going to improve these crossings by using bridges / tunnels so that the transition of 1 train doesn't block the access for any other train on a crossing? But otherwise I'll keep an eye on your project and...
Michiel wrote:
Feel free to steal bits and pieces that look useful :)
Don't mind if I do ;).

Keep up the good work! :)
Bram


Top
   
PostPosted: Tue Jul 07, 2009 9:12 am 
Offline
Engineer
Engineer

Joined: Fri Aug 08, 2008 11:35 am
Posts: 107
Morloth wrote:
One little thing though, you may want to use other software to pack your tar files, because OpenTTD didn't recognize your AI until I unpacked it...


Michiel: slacker... :P We even have a nice and shiny Makefile in our own subversion that makes the tarballs just the way openttd likes them: covered in chocolate and whipped cream on top ;)

_________________
OtviAI
Rondje om de kerk (AI)


Top
   
PostPosted: Tue Jul 07, 2009 8:49 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9062
Location: Sol d
That network screenshot looked to well that I could pass by without giving it a quick shot.

The first result is shown in the first attachment which featured my current test newgrfs. It kinda failed... Building a number of those hubs but nothing else. Setting was starting year 2000, 150k GBP initial loan, on a hilly rough 512^2 temperate map with normal town density.
Attachment:
File comment: hubs...
ChooChoo, 03-03-2000.png
ChooChoo, 03-03-2000.png [ 70.02 KiB | Viewed 31625 times ]

And the reason seems to be (I started the same w/o newgrf, but same results):
Attachment:
File comment: too little money...
Unbenannt, 03-06-1999.png
Unbenannt, 03-06-1999.png [ 12.63 KiB | Viewed 31623 times ]


With very easy settings (max loan and flat map, no newgrf) it started off quite well as you described. It's building IMO exessive bus stations, though, only half of them would be needed for the same coverage:
Attachment:
File comment: station coverage
Eichendorf Transport, 28-03-2000.png
Eichendorf Transport, 28-03-2000.png [ 112.51 KiB | Viewed 31642 times ]


It looks like an interesting start, a good concept which can be modularily improved, so I'm looking forward to further improvements and versions of this AI. Please keep us posted :) - and use bananas for my convenience :P

_________________
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: Tue Jul 07, 2009 9:14 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9062
Location: Sol d
I had the game continue to run... It build one very interesting route (see attachment)
Maybe it would be worth to implement bridges and loop-detection. My guess is that that route won't get overly productive...

This loop-behaviour seems to be a general problem where it actually blocks itself; the AI has a problem with routes which are routed along a shore where it builds the wrong track of the two first so that the other then loops around one hub.


Attachments:
File comment: loop-route
Eichendorf Transport, 01-04-2002.png [177.57 KiB]
Downloaded 267 times
File comment: broken route
Eichendorf Transport, 16-06-2002.png [240.92 KiB]
Downloaded 236 times
File comment: save to demonstrate behaviour
Eichendorf Transport, 01-05-2004.sav [362.5 KiB]
Downloaded 763 times

_________________
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: Tue Jul 07, 2009 9:46 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Jul 13, 2008 12:57 am
Posts: 313
Maninthebox wrote:
Morloth wrote:
One little thing though, you may want to use other software to pack your tar files, because OpenTTD didn't recognize your AI until I unpacked it...


Michiel: slacker... :P We even have a nice and shiny Makefile in our own subversion that makes the tarballs just the way openttd likes them: covered in chocolate and whipped cream on top ;)


We do?
Code:
# svn update

... we do! How convenient :) I just did tar cvf ChooChoo/*.nut and the result looked reasonable. I'll upload a new one, Made by Makefile. Oh wait, I should probably test that one...

Thanks for the feedback guys!

Quote:
Are you btw going to improve these crossings by using bridges / tunnels so that the transition of 1 train doesn't block the access for any other train on a crossing?


Not sure - I'll probably try to manage (reduce) the number of trains instead. Those overpass junctions take up a lot of space, and they don't look very nice.

Quote:
It's building IMO exessive bus stations, though, only half of them would be needed for the same coverage:


Yeah... I'm basically throwing em down wherever there's a suitable road tile :oops: OK, it does skip the next tile when it places one. You've found a very nice worst case scenario :)

I think I can easily prevent it from blocking its own crossings, the code is already there to keep the entrance track from blocking off the exit, and vice versa. To prevent those pointless networks, I'm thinking of either cleaning up failed attempts, or maybe spend some time investigating the site before building a new seed crossing. Maybe even both! Or I get bored and start looking for a new project, so no guarantees :p

Bananas: good point, I'll look into that.

_________________
Building Powargrid: a turn based strategy game


Top
   
PostPosted: Tue Jul 07, 2009 10:38 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 313
Location: Indonesia
Well done and congratulation... :D
I'll try it at home. It have a good concept. (and it smell like release version of otvitrAIn :?: or just another side project :lol: )

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

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


Top
   
PostPosted: Wed Jul 08, 2009 8:05 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Aug 03, 2006 7:32 pm
Posts: 318
Skype: woldy_bg
Location: Bulgaria
Found a major bug - don't introduce desert terrain to the AIs - the result is pooor

Attachment:
Cathill Transport, 13th Aug 1960.png [43.09 KiB]
Downloaded 221 times


Attachment:
Cathill Transport, 13th Aug 1960#1.png [43.69 KiB]
Downloaded 188 times

_________________
Image


Top
   
PostPosted: Wed Jul 08, 2009 12:15 pm 
Offline
Tycoon
Tycoon

Joined: Sat Mar 15, 2008 7:02 am
Posts: 1498
Looks like a good concept, keep it up!


Top
   
PostPosted: Wed Jul 08, 2009 12:43 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Jul 13, 2008 12:57 am
Posts: 313
Wold wrote:
Found a major bug - don't introduce desert terrain to the AIs - the result is pooor

Attachment:
Cathill Transport, 13th Aug 1960.png


Attachment:
Cathill Transport, 13th Aug 1960#1.png


Looks like it's working as intended, though... what happens, does it go bankrupt? The red output is, unfortunately, unavoidable if you use exceptions in your code. The first screenshot shows it's waiting for money before continuing, and the second is an expected failure (it can't extend a crossing because there is no town in the area it's looking in). It should just continue - though if it runs out of starting funds before it gets a decent line going, it won't get very far.

_________________
Building Powargrid: a turn based strategy game


Top
   
PostPosted: Wed Jul 08, 2009 1:04 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Aug 03, 2006 7:32 pm
Posts: 318
Skype: woldy_bg
Location: Bulgaria
Well I've played like 5-6 games and the AI went bankrupt all the times. I even left it alone with no one to compete and it bankrupted in 3-4 years top. The problem I see is that it chooses small towns and the trains produce little income and can't keep with the taxes, since the interest is 10k/year.

Another problem is that it takes all the loan at once and steadily loses money. Another thing is the crossings it makes everywhere which cost ~15k each, but still doesn't connect them.

There should be some priorities in choosing towns, which will make it operate much more efficiently.

I like it though, keep working!

Edit: It doesn't build enough trains ( money issues ) but later, when it has, it doesn't build additional trains to service the route.

Edit2: Not just desert cities * Temperate too

_________________
Image


Last edited by Wold on Wed Jul 08, 2009 6:17 pm, edited 1 time in total.

Top
   
PostPosted: Wed Jul 08, 2009 4:01 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Jul 13, 2008 12:57 am
Posts: 313
Thanks! I guess it's having problems with the low population desert towns. I'll look into evaluating whether a network is viable before actually building it, and maybe implementing DoSomethingIntelligentBeforeBuildingTrains() :wink:

_________________
Building Powargrid: a turn based strategy game


Top
   
PostPosted: Wed Jul 08, 2009 11:41 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Jul 13, 2008 12:57 am
Posts: 313
Update: now evaluates seed crossing sites and starts out building cheap (shorter distances, ignore small towns, cheap locomotives, no extra crossings), so it usually manages to bootstrap itself on a 100k loan in desert maps. It also restricts itself to one station per town, which cleans up the map quite a bit.

_________________
Building Powargrid: a turn based strategy game


Top
   
PostPosted: Thu Jul 09, 2009 12:01 am 
Offline
Director
Director
User avatar

Joined: Sat Apr 18, 2009 5:17 pm
Posts: 577
Location: Basel, CH
I do really like your AI as it seems the first to reuse tracks but:
1. Your AI doesnt support NewGRF trainsets
2. Its got some weird overpasses because it cant build two diagonal tracks on a tile

Otherwise its the best AI i know to date, i think this design is is probably the best ive seen by an AI so far

(Remeber OldAI?)
( :lol: )


Attachments:
File comment: Stupidly Getting from A to B
AIStupid.gif
AIStupid.gif [ 35.52 KiB | Viewed 31356 times ]
Top
   
PostPosted: Thu Jul 09, 2009 10:58 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Jul 13, 2008 12:57 am
Posts: 313
LOL, what the... it built that? In that case, the pathfinder needs a good spanking :) Or did you mean that was the handiwork of the old AI? I'm pretty sure the AI pathfinder I use won't build 90 degree turns.

Quote:
Its got some weird overpasses because it cant build two diagonal tracks on a tile

I think I know what you're referring to, where it builds bridges to "hop over" the other track. I'm currently using a pathfinder I borrowed from OtviTrain; I should switch to the library one. It may have some improvements for this case.

Quote:
Your AI doesnt support NewGRF trainsets

Hmm.. Question for other AI writers: how hard is it to support NewGRF trainsets? I've never used a NewGRF anything. They seem to be quite popular, so if it's not too hard, I'll look into it; otherwise I'll focus on the network building aspects first.

Quote:
Otherwise its the best AI i know to date, i think this design is is probably the best ive seen by an AI so far

Wow, thanks :D

_________________
Building Powargrid: a turn based strategy game


Top
   
PostPosted: Thu Jul 09, 2009 12:15 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
Michiel wrote:
Quote:
Its got some weird overpasses because it cant build two diagonal tracks on a tile

I think I know what you're referring to, where it builds bridges to "hop over" the other track. I'm currently using a pathfinder I borrowed from OtviTrain; I should switch to the library one. It may have some improvements for this case.
The library pathfinder has the same problem.

Quote:
Quote:
Your AI doesnt support NewGRF trainsets

Hmm.. Question for other AI writers: how hard is it to support NewGRF trainsets? I've never used a NewGRF anything. They seem to be quite popular, so if it's not too hard, I'll look into it; otherwise I'll focus on the network building aspects first.
It's easy really, just use AIEngineList and the AIEngine::* functions to select an engine instead of hard-coding one.


Top
   
PostPosted: Thu Jul 09, 2009 12:37 pm 
Offline
Director
Director
User avatar

Joined: Tue Jan 22, 2008 4:33 pm
Posts: 565
Really cool AI Michiel. :) Its a nice, elegant way to create a network.

Michiel wrote:
Hmm.. Question for other AI writers: how hard is it to support NewGRF trainsets?


I dont do train sets yet but I have tried to work with some RV sets. I think you just need to try some popular sets and balance your selection criteria accordingly. NewGRF authors don't stick to a set of common rules so sets can be very different, especially the prices and running costs.

One issue I found with eGRVTS (large RV set) is that vehicle statistics were balanced differently depending on the date of their design, especially for very early vehicles (pre-1950). I use the current date as a balancing factor in my selection criteria to address this.

I dont think there is any way to guarantee that your AI will work perfectly with all NewGRF sets though, given how vastly different they can be.

_________________
PathZilla - A networking AI - Now with tram support.


Top
   
PostPosted: Thu Jul 09, 2009 2:47 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Jul 13, 2008 12:57 am
Posts: 313
Yexo wrote:
It's easy really, just use AIEngineList and the AIEngine::* functions to select an engine instead of hard-coding one.


Oh, I'm doing that already, either picking the fastest or the cheapest (after checking it's not a wagon - the first attempt at cheap was trying to have copper ore hoppers pull its trains :P). I'll see if I can install one of them new fangled train set thingies and see what happens. FHS, I assume you were trying it with "the 2cc set"?

_________________
Building Powargrid: a turn based strategy game


Top
   
PostPosted: Thu Jul 09, 2009 3:33 pm 
Offline
Director
Director
User avatar

Joined: Sat Apr 18, 2009 5:17 pm
Posts: 577
Location: Basel, CH
One time the 2cc set and another time the outdated swiss set taster, i didnt seem to work with either.


Top
   
PostPosted: Thu Jul 09, 2009 6:46 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Aug 03, 2006 7:32 pm
Posts: 318
Skype: woldy_bg
Location: Bulgaria
Since I have no intentions to flood:
#1 - for almost 2 years the AI has built 2 trains ( 1 route )
#2 - no clue what this is, but it should be important
#3 - Day 1 - total failure :D I couldn't find anything like this, but you are the coder
#4 - like #2
#5 & #6 - there is nothing on the map and it couldn't find a town



Something else - because of all the checks the AI does the game runs hell of a slow. You should consider a limit of some sort ( either from the AI itself, or user-defined ).


Attachments:
Choo.zip [327.81 KiB]
Downloaded 512 times

_________________
Image
Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 340 posts ]  Go to page 1 2 3 4 517 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-2018 phpBB Limited

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