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

User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 313
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel » 19 Mar 2011 12:52

planetmaker wrote:Also the current bananas version still creates continuously errors (though not fatal, it's annoying as it spams the console, which is nothing I like when doing casual testing, of also other stuff concurrently)
Sorry - they're not errors, but ChooChoo makes heavy use of exceptions, which the Squirrel VM always outputs to the console, even if they are caught and handled by the AI.

krinn
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 29 Dec 2010 19:36

Re: ChooChoo, a train network AI

Post by krinn » 04 Apr 2011 08:40

I cannot use choochoo v361, there's no real errors here, just a play style

choochoo refuse to work because of construction.road_stop_on_town_road is off

well, as AI are nearly all bad guys when we speak about town and traffic, at least removing this option (i still allow them to build it on all route but not for town) this will lower chance of road stucks by a waiting bus/truck to load on a town road (because everyone use town roads). It happen too with too many vehicle waiting in front of a station, but with road_stop_on_town_road, it happen with just 1 vehicle waiting.
If i understood clear (didn't test choochoo because of the setting), choochoo isn't even really use it! It's just to extend its station coverage.

You wish keep that setting as-is or change your mind ?

User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 313
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel » 05 Apr 2011 15:15

krinn wrote:You wish keep that setting as-is or change your mind ?
I'll think about it :)

Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: ChooChoo, a train network AI

Post by Kogut » 07 Oct 2011 11:43

Without industries CHhooChoo crashes
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: 313
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel » 07 Oct 2011 18:53

Oh, that's kinda bad. I'll see if I can fix that, thanks!

Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: ChooChoo, a train network AI

Post by Kogut » 07 Oct 2011 19:10

And it will loop over and over with more freight lines to do than industries.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD

CurlySue
Engineer
Engineer
Posts: 2
Joined: 11 Oct 2011 03:09

Re: ChooChoo, a train network AI

Post by CurlySue » 11 Oct 2011 03:12

There are two bugs:
Attachments
choochoo_bug.JPG
(218.73 KiB) Downloaded 3 times
choochoo_bug2.JPG
(173.64 KiB) Downloaded 3 times

User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2365
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: ChooChoo, a train network AI

Post by Lord Aro » 11 Oct 2011 08:42

it helps if you actually read the error message.

You need to enable "Allow building drive-through road stations on town roads" setting in the advanced setting.

Also, try to use .png for screenshots, using OTTDs built in screenshot 'taker' (click far right menu button, and select desired screenshot option)
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

User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 313
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel » 11 Oct 2011 09:25

Thanks for the bug report, Curly, and thanks LordAro for already providing the answer for me :)

Endymion
Engineer
Engineer
Posts: 5
Joined: 12 Oct 2009 09:50

Re: ChooChoo, a train network AI

Post by Endymion » 13 Dec 2011 20:50

i got this bug right after the ai starts
Attachments
bug.PNG
bug.PNG (26.68 KiB) Viewed 4290 times

S4D Rampage
Engineer
Engineer
Posts: 4
Joined: 08 Dec 2011 21:52
Location: South Yorkshire, UK

Re: ChooChoo, a train network AI

Post by S4D Rampage » 13 Dec 2011 21:15

Endymion wrote:i got this bug right after the ai starts
If i remember rightly i got that error like 7 years into the game (1978). Yes I start at 1971!
GT: ImPulSe iZ Tank
Open TTD Name: S4D Rampage
Company name: Rampage LLC

www.writing.com

User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 313
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel » 13 Dec 2011 22:20

Thanks, I'll have a look!

Aali
Traffic Manager
Traffic Manager
Posts: 144
Joined: 01 Oct 2008 00:04
Location: Sweden

Re: ChooChoo, a train network AI

Post by Aali » 03 Jan 2012 05:47

Perhaps you are already aware of this but your AI can completely lock up OTTD on large maps with many industries.
The problem is of course the gigantic list of routes generated then sorted with a comparator function. (sort is a native call and can not be suspended)

Since you are only ever interested in the best 10 routes this is completely unnecessary and the following change will make OTTD run smooth as silk during the bootstrap phase even on a 2048x2048 map with industries set to "high":

Code: Select all

	local routes = [];
	foreach (cargo, _ in cargoList) {
		Debug(AICargo.GetCargoLabel(cargo));
		local consumers = AIIndustryList_CargoAccepting(cargo);
		local producers = AIIndustryList_CargoProducing(cargo);
		producers.Valuate(AIIndustry.GetLastMonthProduction, cargo);
		producers.KeepAboveValue(0);
		
		foreach (producer, _ in producers) {
			foreach (consumer, _ in consumers) {
				local distance = AIMap.DistanceManhattan(AIIndustry.GetLocation(producer), AIIndustry.GetLocation(consumer));
				if (distance < MAX_CARGO_DISTANCE) {
					local route = CargoRoute(producer, consumer, cargo)
					if (route.payback > 0) {
						//Debug(route)
						routes.append(route)
						routes.sort(CompareRouteValue)
						routes = routes.slice(0, min(10, routes.len()))
					}
				}
			}
		}
	}
This is definitely one of my favorite AIs, keep up the good work!

User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 313
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel » 05 Jan 2012 15:12

That's a great idea! I'll put it on the to do list, but I must admit I haven't been getting around to AI development recently...
Aali wrote:This is definitely one of my favorite AIs, keep up the good work!
Thanks :D

frosch
OpenTTD Developer
OpenTTD Developer
Posts: 979
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: ChooChoo, a train network AI

Post by frosch » 12 Jan 2012 19:02

my mailbox wrote: Błąd
:)
Attachments
ottd.JPG
(271.32 KiB) Downloaded 3 times
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁

User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 313
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel » 15 Jan 2012 14:44

LOL, just the other day I was telling Maninthebox that ChooChoo managed to go without a real crash for so long :P
Added to The List (TM) :)

sss
Engineer
Engineer
Posts: 114
Joined: 14 Feb 2012 01:29

Re: ChooChoo, a train network AI

Post by sss » 14 Feb 2012 01:37

nice AI, though howd u get that kind of graphics?


User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 313
Joined: 13 Jul 2008 00:57
Contact:

Re: ChooChoo, a train network AI

Post by Michiel » 20 Feb 2012 18:36

sss wrote:nice AI, though howd u get that kind of graphics?
Thanks! But as FooBar said... what kind of graphics? :)

soravux
Engineer
Engineer
Posts: 2
Joined: 20 Feb 2012 21:00

Re: ChooChoo, a train network AI

Post by soravux » 20 Feb 2012 23:11

I've got an issue with ChooChoo on OpenTTD 1.2 beta 4.

I guess it's a Squirrel parser update in the 1.2 version of OpenTTD that broke the comparator function by not returning a 0 on similar values. The Squirrel engine returned an "Inconsistent compare function" error without this modification.

I have modified the CompareRouteValue function to make it look like this:

Code: Select all

function CompareRouteValue(a, b) {
	if (a.payback==b.payback) return 0;
	return a.payback > b.payback ? 1 : -1;
}
It now works for me on the latest version. Hope it helps...

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests