Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Thu May 23, 2019 6:05 am

All times are UTC




Post new topic  Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Some AI questions
PostPosted: Tue May 07, 2019 11:56 pm 
Online
Tycoon
Tycoon
User avatar

Joined: Sat Jan 22, 2005 7:31 pm
Posts: 6509
Location: Wakefield, West Yorkshire
Hi there.

I'm trying to make an AI, safe to say, it is going disastrously. I'm using SimpleAI as my starting point, after giving up entirely trying to udnerstand the ChooChoo AI.

I am trying to get it to replicate my method of playing which is proving a little too complex, although anyone who has seen my method of making junctions will know even I don't4 know how I do it sometimes.

Does anyone have recommendations or thingsa to check out to make a 'proper network bot' that is not silly complex?
Is it possible to have a bot choose its own color, if the color is not taken by another company? - i looked at the API and couldn't find anything for 'colour' or 'color'.
In the NoAPI documentation there are endless versions - am i correct in saying i should be using the highest numbered one?
is it possible to select a specific manager face, ie: enter in a seed and it uses that one? - i personally have a specific manager face i used all the tim, i'd like to get the BOT to do the same thing.

I understand anything to do with 'AI' is complex, but it seems making an AI for this game is mostly focused on the elite who can understand code!

Would an AI be expected to work with any version, or do I have to make amendments for if the bot is being run with a specific patch pack? (ie: i use JGRs one)

_________________
Image
Worst Behaved IRC Member of 2008, 2009 & 2010 - Go Me!


Top
   
 Post subject: Re: Some AI questions
PostPosted: Wed May 08, 2019 6:07 am 
Offline
Graphics Moderator
Graphics Moderator
User avatar

Joined: Mon Sep 13, 2004 1:21 pm
Posts: 5379
Location: The Moon
Redirect Left wrote:
I'm using SimpleAI as my starting point

I would recommend starting from as close to scratch as possible.

Quote:
I am trying to get it to replicate my method of playing which is proving a little too complex

I've always thought of AI coding as playing the game blindfolded. It is complex. Start simple.

Quote:
Is it possible to have a bot choose its own color, if the color is not taken by another company? - i looked at the API and couldn't find anything for 'colour' or 'color'.

This was added in 1.9. Look in AICompany.

Quote:
In the NoAPI documentation there are endless versions - am i correct in saying i should be using the highest numbered one?

Yes. The older versions are to maintain backwards compatibility (eg if a function is extended, changed, or removed, it won't break old AIs).

Quote:
is it possible to select a specific manager face, ie: enter in a seed and it uses that one?

No. You can only set the manager gender, which generates a new random face. You could make a feature request on Github.

Quote:
it seems making an AI for this game is mostly focused on the elite who can understand code!

Squirrel is about as simple a coding language as they come. You don't need to use complex "proper programming" methods to make something that works. I wrote my own AI and can't make head or tails of anyone else's.

Quote:
Would an AI be expected to work with any version

Any OpenTTD version which understands the API you're using (so, no 1.9.0 AIs in 1.8.0). Of course, patched versions of OpenTTD might have their own bugs relating to AIs.

_________________
Pikkarail.com blog | Patreon
Current development: UKRS3 - Av9.8 - TaI32 - CivilAI
Dev reference: NML Specs - NewGRF Specs - Savegame Internals - NoAI API - NoGo API


Top
   
 Post subject: Re: Some AI questions
PostPosted: Thu May 09, 2019 12:00 am 
Online
Tycoon
Tycoon
User avatar

Joined: Sat Jan 22, 2005 7:31 pm
Posts: 6509
Location: Wakefield, West Yorkshire
Hi, thanks for those answers Pikka, very helpful.

I tried to start from scratch, but was quickly thwarted, given I do not know anything about 'Squirrel', so the syntax, formatting, functions etc are entirely alien to me, i thought SimpleAI would be a decent start. Especially since I was eager to get some train action going on.

Where can I find further details on things in AIEvents, I found https://noai.openttd.org/api/1.9.0/classAIEvent.html - but it doesn't specify the exact triggers, or perhaps exact definitions. My main wonder is ET_COMPANY_IN_TROUBLE. Does that refer to my company, another company, what are the triggers that determines if your company (or someone elses) is "in trouble".

I note numerous AIs are producing this log message, I'm a little concerned, but the messages don't seem to clarify much.
Image
I am using the default vehicles (no GRFs in that department), and vehicles never set to expire. Are you aware of what produces that, or why, given all vehicles should be available, especially given the year is now into the 2100s.

One thing I note, is that a lot of AIs seem to build speculatively, and then do not delete after itself when it changes its mind, or they leave an odd junction or depot hanging around. To avoid this happening to me, is there a way of detecting if a piece of track (or say just a 'tile') has anything scheduled to go over it or if its unused?

What would be the expected fix for a vehicle that has gotten lost (AIEvent.ET_VEHICLE_LOST), or rather, what would people consider 'sensible' option for an AI? other than panic stations, of course.

I hope you don't mind me spurting questions out, but I guess that's how you learn!

_________________
Image
Worst Behaved IRC Member of 2008, 2009 & 2010 - Go Me!


Top
   
 Post subject: Re: Some AI questions
PostPosted: Thu May 09, 2019 3:56 am 
Offline
Graphics Moderator
Graphics Moderator
User avatar

Joined: Mon Sep 13, 2004 1:21 pm
Posts: 5379
Location: The Moon
I'd say "walk before you can run", but in this case you're trying to win a dance competition before your legs have grown.

Start here, with a basic main.nut and info.nut. Get an AI working that can build an HQ, set its name and colour. Then start small - experiment building things, removing things, placing signs, writing to the debug log, etc. Use the pathfinder to build a rail line between two points. The questions you're asking are good questions, but they're about five levels deeper than where you're at right now.

_________________
Pikkarail.com blog | Patreon
Current development: UKRS3 - Av9.8 - TaI32 - CivilAI
Dev reference: NML Specs - NewGRF Specs - Savegame Internals - NoAI API - NoGo API


Top
   
 Post subject: Re: Some AI questions
PostPosted: Thu May 09, 2019 1:05 pm 
Online
Tycoon
Tycoon
User avatar

Joined: Sat Jan 22, 2005 7:31 pm
Posts: 6509
Location: Wakefield, West Yorkshire
That's normal for me, I always ask as many questions as I can think of, so I know for later on, or so I know if its worth bothering with or not at all. There's no point wasting time if its too complex or will take too long to achieve vs the end result.

Given I am working from another AI, and not the tutorial (whoever wrote that managed to write it in the slowest most boring way possible), I've already figured quite a bit out, far more than I managed to learn from staring at the tutorial for a few hours. The questions in my most recent post refer to things that are either not handled, or handled differently in each AI i've looked at, so i don't know what is 'expected' so to say, plus personal experience of playing with lots of AIs over the past 2 weeks to get a feel for how they typically behav,e and any mistakes that commonly occur with some (in the case of things getting left behind when they change their mind)
I learn much better when learning from an example I can tinker with until I have learnt enough to redo it, than starting from scratch (unless the example i was learning from can just be reworked), it's how I've learnt all the (programming) languages I know how to do to date. Not everyone can do the whole 'from scratch thing', we all learn differently.

_________________
Image
Worst Behaved IRC Member of 2008, 2009 & 2010 - Go Me!


Top
   
 Post subject: Re: Some AI questions
PostPosted: Fri May 10, 2019 6:18 am 
Offline
Engineer
Engineer

Joined: Sun May 12, 2013 10:28 pm
Posts: 94
Location: Argentina
Redirect Left wrote:
Where can I find further details on things in AIEvents, I found https://noai.openttd.org/api/1.9.0/classAIEvent.html - but it doesn't specify the exact triggers, or perhaps exact definitions. My main wonder is ET_COMPANY_IN_TROUBLE. Does that refer to my company, another company, what are the triggers that determines if your company (or someone elses) is "in trouble".


Look at https://noai.openttd.org/api/1.9.0/clas ... ouble.html
And check the AIEventCompanyInTrouble() function.

Quote:
I note numerous AIs are producing this log message, I'm a little concerned, but the messages don't seem to clarify much.
Image
I am using the default vehicles (no GRFs in that department), and vehicles never set to expire. Are you aware of what produces that, or why, given all vehicles should be available, especially given the year is now into the 2100s.


That usually happens with vehicles that don't fit the service requirements (speed, load, cargo or type of station). It depends on how do you restrict your own AI.

Quote:
One thing I note, is that a lot of AIs seem to build speculatively, and then do not delete after itself when it changes its mind, or they leave an odd junction or depot hanging around. To avoid this happening to me, is there a way of detecting if a piece of track (or say just a 'tile') has anything scheduled to go over it or if its unused?


Only if it is already owned: https://noai.openttd.org/api/1.9.0/clas ... 6de7625bcd

Quote:
What would be the expected fix for a vehicle that has gotten lost (AIEvent.ET_VEHICLE_LOST), or rather, what would people consider 'sensible' option for an AI? other than panic stations, of course.


It depends on type of vehicle. If it is a normal road vehicle, maybe its route was broken by other competitor, or just by your own AI. Or can be a bad constructed route. If your script cannot fix the issue, then it should send the vehicle to depot and sell it, if even it can find a route to depot! In case of trains, it can happens when a train gets stuck in a jammed junction, or waiting behind a neverchanging red light. If a ship, it usually happens when it enter a dock in a narrow bay or canal, and doesn't have enought space to turn. It will find the correct way fast and there is no concern about that, a human player can fix it by terraforming or building more space for canals, just to avoid the bothering message. Other case for ships is another player terraforming aggresively and closing exits, the only way to avoid that is building canals over sea and lakes to ensure the route is not broken (used buoys are automatically locked)


Top
   
 Post subject: Re: Some AI questions
PostPosted: Tue May 14, 2019 3:17 am 
Online
Tycoon
Tycoon
User avatar

Joined: Sat Jan 22, 2005 7:31 pm
Posts: 6509
Location: Wakefield, West Yorkshire
Hi HGus, many thanks for your details reply it helped a lot.

I've now got a simple AI up and running, and hopefully I can improve upon it to a point i'm happy to release it. It currently makes quite poor financial choices, so i'll check out the financial stuff next time i am playing with it.

Whilst playing around with loads of AIs on BaNaNas, it's surprising how many of them they are, but then how many of them seem to be by people who haven't logged in on this forum for over a year or so, so may be abandoned :(

_________________
Image
Worst Behaved IRC Member of 2008, 2009 & 2010 - Go Me!


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

All times are UTC


Who is online

Users browsing this forum: Google Adsense [Bot] and 1 guest


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-2019 phpBB Limited

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