gelignAIte

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
gelignite
Engineer
Engineer
Posts: 5
Joined: 13 Dec 2010 23:48
Contact:

gelignAIte

Post by gelignite » 16 Dec 2010 12:08

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.
Last edited by gelignite on 16 Dec 2010 21:50, edited 3 times in total.

Brumi
President
President
Posts: 904
Joined: 18 Jul 2009 17:54

Re: gelignAIte

Post by Brumi » 16 Dec 2010 12:21

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.
Attachments
Unnamed, 12th Apr 1951.png
(172.09 KiB) Downloaded 2 times

gelignite
Engineer
Engineer
Posts: 5
Joined: 13 Dec 2010 23:48
Contact:

Re: gelignAIte

Post by gelignite » 16 Dec 2010 12:57

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?

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

Re: gelignAIte

Post by Lord Aro » 16 Dec 2010 13:08

nice!

1 recommendation: upgrade to 1.0 API, the 0.7 API is now getting a little dated :wink:
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

gelignite
Engineer
Engineer
Posts: 5
Joined: 13 Dec 2010 23:48
Contact:

Re: gelignAIte

Post by gelignite » 16 Dec 2010 13:59

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.)

Yexo
Tycoon
Tycoon
Posts: 3653
Joined: 20 Dec 2007 12:49

Re: gelignAIte

Post by Yexo » 16 Dec 2010 15:36

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.

gelignite
Engineer
Engineer
Posts: 5
Joined: 13 Dec 2010 23:48
Contact:

Re: gelignAIte

Post by gelignite » 16 Dec 2010 21:35

Heh, the trams look funny. :)
Well, should be working now. A new version is online. Thank you all for your feedback.

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 9 guests