Page 1 of 1

gelignAIte

Posted: 16 Dec 2010 12:08
by gelignite
Hi everybody,

this - gelignAIte - is both my try to write an AI and to get familiar with Squirrel. I didn't take that much care of highly performed source code (so you may find things which might be done more efficient) but just wrote the AI I had imagined - a small AI that tinkers around on the map while not really competing with me so I'll win even on difficult level. :P

Description:
Small, simple and non-competitive AI, that will build 1 passenger-service (2 buses) and 1 mail-service (4 trucks). The passenger-service is constructed in the biggest town on the map right after starting the AI. The mail-service will be build only if the following preconditions are fulfilled:
- Loan is less or equal than 20 % of maximum loan and
- the town to build the service in (the biggest town on the map at that point of time) has >= 9k inhabitants

Features are:
- Updating stations (moving outwards (from town center) in dependency of count of inhabitants) every five years after inauguration to a max distance of 16 tiles
- Renew aged vehicles
- Replace crashed/lost vehicles
- Replace/Upgrade vehicles by newer models/engines
- Funds managing: Take loan where required, repay where possible.

Download:
It is available via http://bananas.openttd.org/en/ai/.

Known issues:
- I didn't yet figure why but it may occur that the AI crashes on loading. I encountered that a few times but couldn't reproduce it. If someone encounters it and knows what's going on, I'd be pleased to hear from you.

Have fun with it.
geli


P.S.
Note(s):
I wrote the AI on a default installation and tested it only on that "default", "snow" and "desert" type of map. (What is the correct naming of those?) The AI shouldn't work on the "toyland" type as there seems to be no "PASS"enger service available. I didn't play that to verify because I don't like that type. As I have a default installation I couldn't test whether there are problems with other GRFs. Let me know if there's something wrong and I'll see what I can do.

Re: gelignAIte

Posted: 16 Dec 2010 12:21
by Brumi
Welcome to the forums! :)
I tried your AI, but it doesn't build any buses, only the stations if a tram set is present. Make sure you exclude trams when you choose the correct vehicle.

Re: gelignAIte

Posted: 16 Dec 2010 12:57
by gelignite
Thanks for the info. I didn't use any different sets so i didn't encounter that phenomenon. :?

Before asking thousands of questions now I think it would be best and easiest I install a tram set. The problem is, I don't know what I have to install. Is it a certain scenario or a special NewGRF i need to have trams?

Re: gelignAIte

Posted: 16 Dec 2010 13:08
by Lord Aro
nice!

1 recommendation: upgrade to 1.0 API, the 0.7 API is now getting a little dated :wink:

Re: gelignAIte

Posted: 16 Dec 2010 13:59
by gelignite
Lord Aro wrote:nice!

1 recommendation: upgrade to 1.0 API, the 0.7 API is now getting a little dated :wink:
Thank you. I'm not sure I understand that correctly. I've now added GetAPIVersion() to info.nut that will return "1.0". Is this what you meant? Or is there something else you noticed that I still miss?

While I've written the AI I'd always looked at 1.0.4 and 1.0.5 API docs, so I thought I'm using the 1.0 API already - though I started with an old tutorial. (I'll update it on BaNaNaS as soon as I've an idea how to solve the tram issue.)

Re: gelignAIte

Posted: 16 Dec 2010 15:36
by Yexo
In the main menu, go to online content and download for example the generic tram set. Now open the newgrf settings, click "add", select the grf you've just downloaded. After doing that start a new game and you'll have trams.

Re: gelignAIte

Posted: 16 Dec 2010 21:35
by gelignite
Heh, the trams look funny. :)
Well, should be working now. A new version is online. Thank you all for your feedback.