AIAI

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
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

AIAI

Post by Kogut »

Here is my attempt to write an AI. It is intended to be both challenging and produce nice looking infrastructure. I also plan to make it working with all possible settings and add support for all "normal" newgrfs - for now it should work with all newgrfs from bananas.

Done:
full save load support
support for eGRVTS, HEQS, NARS, 2cc etc
support for FIRS, ECS etc
full RV support
freight train support
plane support
uses all cargoes (except mail, tourists)
newtrack support

code and bug tracker resides at https://github.com/matkoniecz/AIAI
Attachments
support for FIRS and eGRVTS.PNG
support for FIRS and eGRVTS.PNG (38.88 KiB) Viewed 64405 times
Now with trains!.png
Now with trains!.png (140.29 KiB) Viewed 58523 times
Last edited by Kogut on 21 Sep 2016 19:08, edited 72 times in total.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI pre-alpha 0 version

Post by Kogut »

...
Attachments
support for HEQS.PNG
support for HEQS.PNG (21.81 KiB) Viewed 64403 times
av8 support.PNG
av8 support.PNG (56.3 KiB) Viewed 63991 times
basic ECS vectors support.PNG
basic ECS vectors support.PNG (71.87 KiB) Viewed 63991 times
Last edited by Kogut on 16 Mar 2010 14:04, edited 1 time in total.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: AIAI pre-alpha 0 version

Post by planetmaker »

Nice view. I tried to give it a shot (no newgrfs, temperate climate):
Attachments
AIAI crash
AIAI crash
Neu Hahnmünster Transport, 13-02-1975.png (33.49 KiB) Viewed 64401 times
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI pre-alpha 0 version

Post by Kogut »

I uploaded incorrect version. :cry:
Now it should works.
Thanks for bug report!
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: AIAI pre-alpha 0 version

Post by Brumi »

Good work! :)
In my first test, your AI is working fine, it is incredibly fast :))
Keep it up, it's nice to see a new AI!
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI alpha version

Post by Kogut »

Version alpha uploaded

New
limit of RV in one route
useless vehicles are sold
better error handling
improvement of road pathfinder (from SimpleAI)
fixed crash when no suitable RV are available
fixed bugs
better secondary cargo handlig (conditional orders)
money menagement
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: AIAI alpha version

Post by Steffl »

I'm really liking your AI. It plays really very fast and good, even it is only a alpha version.
It remembers me a little to the Pathzilla AI, which is one of my favourite AI's.
But unfortunenally I have to report a little bug, which I don't know why it happened.
Keep on working. Nice greetings.

Edit:
I have an idea to fix the problem. You just have to change line 352 of main.nut to:

local name=AIVehicle.GetName(car)+" ";
Attachments
Baker & Co., 22. Sep 1947.png
Baker & Co., 22. Sep 1947.png (10.75 KiB) Viewed 10292 times
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI alpha version

Post by Kogut »

Thanks for bug report and good opinion about ai.

The main problem was that vehicleID was valid in RenevRV function (when AI created vehicle list in 413 line) but RV was destroyed before executing of CzyNaSprzedaz function. In result vehicle become invalid and program crashed. I must check what happen when Noai API get it: AIVehicle.Sth(invalid_vehicle).

Edit:

local name=AIVehicle.GetName(car)+" "+" "+" "+" "+" "+" "; //it may work, but i must check what getname return when performed on illegal vehicle
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI alpha version

Post by Kogut »

New version of AIAI!

- Planes (support for air newgrfs)
- Kind of support for ECS
- Bugfixes (thx Steffl)
- Better menagement
- Now ai (should) replace vehicles
Attachments
aiai_beta.tar
(94 KiB) Downloaded 2475 times
What AIAI constructed on flat map.PNG
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: AIAI alpha version

Post by Brumi »

Nice work! :)
It's still one of the fastest AIs of all time, it was working fine in my test, it reached the vehicle limits in a matter of years...
I have one little problem: airports are sometimes overworked, there were 14 planes using one small airport, for example. Apart from that, it was doing very well.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI alpha version

Post by Kogut »

Airport capacity still have flaws to find (sometimes capacity control is ignored). I am working on it.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI beta version

Post by Kogut »

Fixed:
EDIT Another bug fixed, new version uploaded
EDIT
known problems
- stupid plane behaviour on very large maps (too big distances between airports)
- sometimes ai try to build aircrafts when limit is reached
Attachments
aiai_beta3.tar
(96.5 KiB) Downloaded 2160 times
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI beta4 version

Post by Kogut »

New feature: shameless copy - paste from cluelessplus (replacing level crossing with bridge)

Fixed known probles, new problems are known:
n^2 is bad idea when n may be 5k (n = AIIndustryList().Count() ) In other words - searching for best industry on large maps is very, very slow.
solution: change to amortized contant time (200)

long bridges sometimes are unavailable!

very high rotation of vehicles
Attachments
aiai_beta4.tar
(113.5 KiB) Downloaded 2688 times
Przechwytywanie.PNG
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: AIAI beta4 version

Post by Steffl »

I found some little bug again in your AI again. But I'm sure you can handle it easily :-)

PS.: I try to make a AI too (ok, it's not really mine), but it can hardly compete with your AI. Only sometimes it is a little bit better. But in most cases your AI wins.
Attachments
Baker & Co., 10. Sep 1945.png
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI beta4 version

Post by Kogut »

Thanks! It happens when industry is closed during looping over industry list.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

............................................................

Post by Kogut »

All known problems fixed (including bug reported by Steffl)!
This is gamma version/first bananas candidate.
So I wait for next bug reports.

The biggest new feature: industry to city routes.

And one small question. I keep aiai in content_download folder. Where it should be to avoid overwrittion by Bananas?
Attachments
Przechwytywanie.PNG
Przechwytywanie.PNG (82.16 KiB) Viewed 63610 times
aiai_gamma.tar
(123.5 KiB) Downloaded 2183 times
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: AIAI beta4 version

Post by Zuu »

<openttd dir>/ai/AIAI/info.nut

Where the openttd dir can be either the installation dir or OpenTTD in your documents etc.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI gamma version

Post by Kogut »

Aaargh
Know problem - factory servised both by truck and plane

Bugfix - plane connection to industry without production.
Attachments
aiai_gamma1.tar
(123.5 KiB) Downloaded 2787 times
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: AIAI gamma1 version

Post by Morloth »

Hey Kogut,

Congratulations with your AI, I just took it for a test run and it performs really well! I did 2 quick runs I did with it it beated NoCAB fair and square :). It was quite a nice match to see, NoCAB took the initiative while your AI was able to catch up after 10-15 years and took the lead after that. Seems that your strategy to look for the best industries and connect those pays off, from what I gleaned from the games played NoCAB spends way too much time planning and thinking while AIAI builds and takes the lead as it is really fast.

Later in the game NoCAB did manage to crawl closer to your AI as better trains became available and it replaced all its small airfields with larger ones, but never close enough to surpass yours (at least not before 1985 after which time I had to quit).

Well done and I'm looking forward to your final AI! In the meantime I'll use this one to benchmark my own ;).
- Bram
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: AIAI gamma1 version

Post by Lord Aro »

Whoa!
An AI that beats NoCAB? (i've never tried Rondje OK?)
This is going to be some fearsome AI...
Good Luck! :mrgreen:
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
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests