Chopper - Helicopter 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

Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Chopper AI - Now serving all cargos!

Post by Terkhen »

Thanks for the release!
Marbs wrote:To destroy an airport there have to be no helicopters at it, so Chopper would either have to send the helicopters to another depot to get them out the way, or sell the helicopters. It would be useful to have some kind of "close airport" option to make helicopters simply circle above until the airport is reopened. The airport could then be demolished and replaced, however there is a small chance this could fail (someone else building in the way really fast or building an airport nearby that raises the noise level). If it failed Chopper might have lost a valuable spot.
You are looking for the features implemented at the close airports and the upgrade airports patches. I don't think that you can imitate that behaviour using only AI code, though.

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4554
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Chopper AI - Now serving all cargos!

Post by Zuu »

When you replace your airports you will have to re-route your helicopters elsewhere. Or in case you work connection-based you could park them in the hangar of the other airport/helidepot. You could have a special airport/heliport used to store helicopters when you replace an airport. Using conditional orders you could still have the two stations that the connection consists of in the orders so that the connection is not lost if the game is saved and then loaded in the middle of an upgrade process.

In my PAXLink AI I will need to solve how to make the AI not trying to set up a connection with a special storage airport. You might have the same problem.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

User avatar
Marbs
Engineer
Engineer
Posts: 14
Joined: 22 Aug 2006 16:19
Location: Garden of England

Re: Chopper AI - Now serving all cargos!

Post by Marbs »

Airport replacing works! Here you can see that a large (city) airport has been replaced with a smaller, higher capacity and quieter helistation. I achieved this by making Chopper temorarily reroute the helicopters going to the station that needs to be replaced to a holding station, and then once the station has been upgraded they are set free again!
large_replaced_with_helistation.PNG
large_replaced_with_helistation.PNG (167.09 KiB) Viewed 3695 times
However, this has brought to attention one possible problem I did not forsee. The catchment area is now much smaller. If airports only took one cargo, it would be a simple matter of scanning through the tiles to find the best place to place the new airport, but unfortunately some airports will be used for multiple cargos, freight, mail, passengers etc. For example, if the station being replaced is between a coal mine and a town, the new station with a smaller catchment might only be in the coal mine catchment afterwards, and thus any passenger helicopters going to that station will not be able to load or unload.

Currently this just means over the course of the next year or so, the helicopter will become very unprofitable and get removed, however I'd prefer to have a cleaner solution to the problem.

One solution could be to use distant join stations to make Chopper build a train/bus/lorry station in each corner of where the old airport was, in order to retain the original catchment size, however this seems like an ugly solution:
large_replaced_with_helistation2.PNG
large_replaced_with_helistation2.PNG (167.97 KiB) Viewed 3695 times
Rather than try and retain the original catchment, I could make Chopper check which cargos the new station accepts, and then sell any helicopters visiting that station that can no longer do their cargo on that route. However that could mean that a profitable route is wasted.

Perhaps the best solution would be to check what cargos the station should accept/produce, then try and place it accordingly, and if complete catchment cannot be achieved then place the station near just one cargo, and build another station next to the other cargo, and send the appropriate helicopters to that other new station instead. However this defeats the main reason for upgrading the airport which is to lower the noise level to allow more airports to be built; this method just uses up that freed noise.

Whatever happens, expect a new release of Chopper soon :D

User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

Re: Chopper - Helicopter AI

Post by 1009 »

You might also want to consider evaluating at what place of the original airport the catchment area for the newer (smaller) airport covers the most tiles of the desired goods. That way you'll be placing the new airports closer to your city, contrary to what's shown in your attachment.

User avatar
Marbs
Engineer
Engineer
Posts: 14
Joined: 22 Aug 2006 16:19
Location: Garden of England

Re: Chopper - Helicopter AI

Post by Marbs »

Eliandor wrote:You might also want to consider evaluating at what place of the original airport the catchment area for the newer (smaller) airport covers the most tiles of the desired goods. That way you'll be placing the new airports closer to your city, contrary to what's shown in your attachment.
I've now improved it so that each tile is given a value depending on the accepted/produced cargo, and the highest value is the best. All these calculations are done before the old airport is destroyed, and so replacing the airport with a new one is almost instantanious, meaning there is almost no chance of any competitor being able to build in the way! :D (However, there is a tiny tiny chance that the game will be saved in the gap between the old airport being destroyed, and the new one being built. If that game is loaded then Chopper will end up with some aircraft forever waiting in a hangar with invalid orders because the station was never replaced, but the chance of this is near impossible...)
large_replaced_with_helistation3.PNG
large_replaced_with_helistation3.PNG (130.22 KiB) Viewed 3632 times
I think the next main thing that needs improving is how Chopper starts a game off, especially an early game when there is only the airship available. The current problem is that the airship is quite expensive, slow and not very profitable, and so Chopper will waste quite a bit of money constructing new routes, only to demolish them again because they are not making enough profit (though they are making a small profit). I think perhaps I should change it so that in the first few years (or whilst loan/money is below a certain threshold), as long as the profit is positive the route shouldn't be demolished. Once Chopper has got a solid income he can then worry about finding the most profitable route possible.

One other thing I should probably improve at some point is the levelling of land for an airport. Currently Chopper only knows how to lower land, not raise it, and will only attempt to flatten the land if it is just a small difference in height. This works relatively well for the helistation, helidepot and heliport since they are very small and do not need a large area of land to be flattened, but the small and large airport are substantially bigger and on a rough hilly scenario, Chopper will often not find a spot for them.

Oh, and Chopper now builds an HQ :D
Chopper HQ.PNG
Chopper HQ.PNG (125.7 KiB) Viewed 3635 times
The HQ is built next to the central airport. The central airport is the first airport created in the game, and is were helicopters are sent to get them out the way. It is also used to build the helicopters if no other depots exist, for example if you start Chopper in the year 1963 when the heliport becomes available, it is very likely that the routes will use only heliports (which has no hangar), because the helidepot and helistation do not become available for another few years after; and so a hangar is needed somewhere to build the aircraft.

No new version of Chopper just yet, but should be soon(ish).

User avatar
1009
Engineer
Engineer
Posts: 81
Joined: 22 Mar 2009 07:24
Location: Haarlem, The Netherlands
Contact:

Re: Chopper - Helicopter AI

Post by 1009 »

Awesome, that's what I meant.
To prevent the save happening between the destroying of the old Airport and the construction of the new one: how about adding a tasklist to your AI, as a stack, saveable? That way he won't forget what he was doing. :)

Blustuff
Engineer
Engineer
Posts: 112
Joined: 21 Aug 2008 09:37
Location: France

Re: Chopper - Helicopter AI

Post by Blustuff »

Eliandor wrote:how about adding a tasklist to your AI, as a stack, saveable? That way he won't forget what he was doing. :)
What if there is a save/load between the task being added ? You need to solve the atomicity problem I mentioned on this forum before. When you want to atomically add a list to another list, you can make a copy of the first list, add the second to the copy and assign the result to the variable to be saved. Hopefully the last assignment is a single bytecode instruction and thus atomic. This is much trouble for a save/load feature.

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

Re: Chopper - Helicopter AI

Post by Yexo »

Blustuff wrote:
Eliandor wrote:how about adding a tasklist to your AI, as a stack, saveable? That way he won't forget what he was doing. :)
What if there is a save/load between the task being added ? You need to solve the atomicity problem I mentioned on this forum before. When you want to atomically add a list to another list, you can make a copy of the first list, add the second to the copy and assign the result to the variable to be saved. Hopefully the last assignment is a single bytecode instruction and thus atomic. This is much trouble for a save/load feature.
AFter a sleep you have at least 5000 ticks where your AI is not suspended. Unless you execute a DoCommand function in which case your Ai will be suspended immediately.

Blustuff
Engineer
Engineer
Posts: 112
Joined: 21 Aug 2008 09:37
Location: France

Re: Chopper - Helicopter AI

Post by Blustuff »

Yexo wrote:AFter a sleep you have at least 5000 ticks where your AI is not suspended. Unless you execute a DoCommand function in which case your Ai will be suspended immediately.
Will it still be true in the next versions of OpenTTD ?

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

Re: Chopper - Helicopter AI

Post by Yexo »

Blustuff wrote:
Yexo wrote:AFter a sleep you have at least 5000 ticks where your AI is not suspended. Unless you execute a DoCommand function in which case your Ai will be suspended immediately.
Will it still be true in the next versions of OpenTTD ?
Everything can be changed, but I see no reason why this would be changed. Don't count on exactly 5000 ticks, but after a sleep you'll have plenty of ticks to copy some lists.

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Chopper - Helicopter AI

Post by petert »

I found a strange error, I was told to put the screenshot here.
Attachments
Rafingbourne Bridge Transport, 31st Jan 2025.png
(80.5 KiB) Downloaded 1 time

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4554
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Chopper - Helicopter AI

Post by Zuu »

If you have the game available and can reproduce the error, can you post a new screenshot where the numbers at the end of all the four long rows are visible. The first one is usually the most important one since it tells you which row and in which file the error occurred.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Chopper - Helicopter AI

Post by petert »

Well, I can't reproduce the error in r17718, so sorry that I posted.

User avatar
Menno
Tycoon
Tycoon
Posts: 1190
Joined: 05 Feb 2005 14:35
Location: Netherlands, Utrecht

Re: Chopper - Helicopter AI

Post by Menno »

I tried a game with Chopper v7 among other AI's.
It performed not so good. It builds 1 or 2 choppers, realizes they don't make profit, sells them, sits on the rest of the money, then slowly goes bankrupt. Chopper only picked up when the Boeing Vertol became available.
Difficulty settings were slightly easier than medium, startdate 1977, max initial loan 200,000 GBP.
See attached save game.
OpenTTD 0.7.3
NewGRFs: OpenGFX, better vehicles names, Av8 1.501

(I will post comparable posts in the other AI's topics)
Attachments
AI game.sav
(658.84 KiB) Downloaded 81 times
*hmz*

User avatar
Marbs
Engineer
Engineer
Posts: 14
Joined: 22 Aug 2006 16:19
Location: Garden of England

Re: Chopper - Helicopter AI

Post by Marbs »

@petert
Thanks for the bug report, but unfortunately I can't really see where the problem is exactly without the code line numbers. Hopefully though that bug is just a one off.

@Menno
Unfortunately sometimes it seems it is impossible to make a profit using helicopters (e.g. using the airship from pre-1950). However in v9 I have been working on improving how Chopper starts a game, so that he expands cautiously and doesn't waste money building stations that will go unused for years. Hopefully this will fix some of the bankruptcy problems, but Chopper often struggles when the speed factor is less then 1/1 :(

Chopper definitely can perform well when good helicopters are available, but I hope to make Chopper simply be able to survive in any situation. It seems though that this may be impossible, so I may have to resort to giving Chopper a backup plan for when things go horribly wrong, such as build some airplanes. But that defeats the purpose of this AI.

Edit: I saw you used v7, there is a v8 of Chopper on the last post of the first page. v8 can start any time earlier than 1976, so if you do decide to have another AI game, you can start at 1950 if you want :)

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

Re: Chopper - Helicopter AI

Post by Lord Aro »

Lord Aro wonders why there has been no new version of this AI... :?:
(only posted because Marbs was online only about 2 weeks ago)
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

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

Re: Chopper - Helicopter AI

Post by Kogut »

Chopper requires the helidepot and heliport to be available, and for there to be at least one helicopter available.
Why not when heliport and random airport?
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD

User avatar
Marbs
Engineer
Engineer
Posts: 14
Joined: 22 Aug 2006 16:19
Location: Garden of England

Re: Chopper - Helicopter AI

Post by Marbs »

Braaaaaaaains...
That's right, I've resurrected this ancient topic back from the dead! :D

Sadly this is just a very minor update, however it has been an essential one, as you shall see below.

Changes:
-Fixed a fatal bug where all vehicles only got assigned one order (which made the AI immensely useless).
-Fixed another bug where playing with Chopper on a "lazy" attitude caused him to error almost instantly.
-You may have noticed I skipped releasing versions 8 & 9. That is because I didn't get around to releasing them at the time I wrote them (about 2 years ago :P).

What is next for Chopper? It seems to me that playing a helicopter only company on the default aircraft speed of 1/4 makes it impossible to survive, let alone profit, until near the year 2000 (though NewGRFs will help). Even at 1/1 Chopper will just break even on a good day.

I think that the only way forward is to expand from only using helicopters, but to try and keep to the spirit of Chopper. Ultimately I'd like this AI to help grow towns but without interfering with the other players too much. For this I plan an intracity road network. Busses could simply take routes within cities, helping the city grow and balancing off the burden of helicopter transport, perhaps even assisting by transferring cargo to the heli-stations.

@Lord Aro
Sorry it took so long, but you can stop wondering now!


Chopper v10 is out on BaNaNaS.

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

Re: Chopper - Helicopter AI

Post by Lord Aro »

great :)
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

Strongpoint
Engineer
Engineer
Posts: 2
Joined: 24 Aug 2011 14:06

Re: Chopper - Helicopter AI

Post by Strongpoint »

Add intracity trams support and use busses only if there are no trams in GRF
That Ai should use not so popular tranportation methods :)

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 17 guests