Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sat Jul 21, 2018 10:52 pm

All times are UTC




Post new topic  Reply to topic  [ 17 posts ] 
Author Message
PostPosted: Sun Oct 23, 2016 9:49 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 23, 2016 9:37 pm
Posts: 7
Hi everyone,
I'd like to show you a simple AI, I've been working on for the past few days. It operates 2 types of vehicles which need the simplest infrastructure:
  • Helicopters - AI follows the old trick I always used in the past when playing with my siblings: demolish 1 tile directly in the city center, build a heliport there and connect it with the nearest city.
  • Ferries - I found A*-based pathfinders really slow when working with larger water distances, so I wrote my own 2. One follows a straight line, the other one follows the coast.

Features include:
  • autoreplacing vehicle model when the new, better model appears
  • selling unprofitable vehicles
  • autoreplacing old vehicles with new ones

AI starts building heliports when helidepot becomes available. You can use multiple instances of this AI on the same map. I tested it only with the standard GRF and it did OK even with only ferries available.

Download: https://github.com/mmuszkow/HeliFerry/archive/master.zip
The code is available on my github: https://github.com/mmuszkow/HeliFerry


Top
   
PostPosted: Mon Dec 12, 2016 8:27 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Fri Nov 21, 2014 12:39 pm
Posts: 223
Location: The Granite City.
Why does the AI build Heliports on the roads ? It has done this at 50 towns in this game , can be a annoying having to build roads around them .


Attachments:
Antarctica Railways, 03-09-1980.png [1.07 MiB]
Not downloaded yet
Top
   
PostPosted: Mon Dec 12, 2016 8:45 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Tue Oct 20, 2015 7:05 pm
Posts: 231
Seems interesting, how do I install it into the game?


Top
   
PostPosted: Mon Dec 12, 2016 10:05 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Fri Nov 21, 2014 12:39 pm
Posts: 223
Location: The Granite City.
Either from the first post or check online content from the title screen or https://bananas.openttd.org/en/ai/.


Top
   
PostPosted: Tue Dec 13, 2016 5:48 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4644
Location: home
piratescooby wrote:
Why does the AI build Heliports on the roads ? It has done this at 50 towns in this game , can be a annoying having to build roads around them .
You have magic bulldozer enabled?

_________________
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.


Top
   
PostPosted: Tue Dec 13, 2016 6:30 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Fri Nov 21, 2014 12:39 pm
Posts: 223
Location: The Granite City.
Magic on , this is the first time the AI has chose to do this ,also building service stations on the peaks of mountains , bought the company out to see what it would do .Built a Heliport next to another one , very strange .


Attachments:
Antarctica Railways, 09-09-1986.png [1.46 MiB]
Not downloaded yet
Top
   
PostPosted: Tue Dec 13, 2016 6:44 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4644
Location: home
piratescooby wrote:
Magic on , this is the first time the AI has chose to do this ,also building service stations on the peaks of mountains , bought the company out to see what it would do .Built a Heliport next to another one , very strange .

What do you mean, "very strange"?

Switching on magic bulldozer enables removal of anything, for everybody.
You can remove anything, but any other entity, such as AIs or town authorities can do that too.

Looking for an empty spot in the middle of a town is hopeless anyway, so likely it just tries to remove random tiles or so until it works.
With magic bulldozer any tile will work. Very convenient!

_________________
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.


Top
   
PostPosted: Tue Dec 13, 2016 11:22 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Fri Nov 21, 2014 12:39 pm
Posts: 223
Location: The Granite City.
I just find it strange that a AI will build on a road tile and not an empty ground tile , just booted up a rnd game and let the AI run , mostly flat ground ,100% airports built in the towns on road tiles .Surely the coding could be changed so the AI does not do this sort of behaviour .


Top
   
PostPosted: Tue Dec 13, 2016 11:51 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4644
Location: home
It's probably the center city tile which is tried first.

Of course it can be changed. On the other hand, it's a valid play style in your game.

Would you stop building in a certain way if another company is bothered by it, but the rules allow it?

_________________
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.


Top
   
PostPosted: Tue Dec 13, 2016 12:26 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Fri Nov 21, 2014 12:39 pm
Posts: 223
Location: The Granite City.
Getting used to it , just switch to other company ,demolish a block or two of buildings and build a road around .Not so bad at the coast ,seem to build along the route of the road .


Top
   
PostPosted: Tue Dec 13, 2016 10:14 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 23, 2016 9:37 pm
Posts: 7
piratescooby wrote:
Why does the AI build Heliports on the roads ? It has done this at 50 towns in this game , can be a annoying having to build roads around them .
Cause it can, even without the magic bulldozer cheat and hostile town council attitude to area restructuring. To be precise, AI demolishes tile in the exact city center and builds there a heliport, in many cases this happens to be a road tile. I was happy with that cause:
- demolishing road doesn't cause the city population to decrease, demolishing building does
- it breaks the road AIs who don't react to the road network change for their existing routes

On the other hand, for a human player such behavior can be indeed annoying. I updated the .zip from the first post, to omit roads when demolishing space for heliport. It's not on bananas yet (and I'm not sure if I will include that change in "stable" version).

piratescooby wrote:
also building service stations on the peaks of mountains
Are there any disadvantages of that? Helidepots are used only to build, upgrade or replace old vehicles (which happens ~once/20-25 years).

piratescooby wrote:
Built a Heliport next to another one , very strange
Not really, you have 2 AIs which use the exact same strategy. Both of these heliports will have great passengers "production".


Top
   
PostPosted: Wed Dec 14, 2016 4:52 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Fri Nov 21, 2014 12:39 pm
Posts: 223
Location: The Granite City.
Thanks for the update , enjoy watching the Zeps landing in the center of town ,going to set up with VTOLs grf in the next game ,a Martian scenario , should be fun .


Top
   
PostPosted: Fri Dec 23, 2016 7:37 am 
Offline
Engineer
Engineer

Joined: Sun May 12, 2013 10:28 pm
Posts: 89
Location: Argentina
mjm wrote:
To be precise, AI demolishes tile in the exact city center and builds there a heliport, in many cases this happens to be a road tile.


From the beginning, cities are build around a road tile in the center, no matters what algorithm you choose (original, improved, 2x2 or 3x3). So demolishing exactly that tile will always break the network for small towns, mostly at beginning of game when most towns still don't have more than a crossroad, or in islands. It would be gently if you change that behaviour, or at least add a new setting to the script.

Good work. Thank you.


Top
   
PostPosted: Fri Dec 23, 2016 6:00 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sun Feb 21, 2010 12:15 am
Posts: 1023
Location: Fitzroy North - 96
HGus wrote:
mjm wrote:
To be precise, AI demolishes tile in the exact city center and builds there a heliport, in many cases this happens to be a road tile.


From the beginning, cities are build around a road tile in the center, no matters what algorithm you choose (original, improved, 2x2 or 3x3). So demolishing exactly that tile will always break the network for small towns, mostly at beginning of game when most towns still don't have more than a crossroad, or in islands. It would be gently if you change that behaviour, or at least add a new setting to the script.

Good work. Thank you.


Furthermore, towns grow from the center tile road - if this road tile is missing, the town cannot grow at all, so will generally shrink over time.

_________________
Image
Trolleybi! Trucks and Buses -- Docklands -- Unspooled -- MLSS


Top
   
PostPosted: Sun Feb 25, 2018 1:09 am 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Feb 26, 2015 12:52 am
Posts: 212
I'm taking HeliFerry into an aircraft only competition. It builds profitable routes, but it's always working too close to the loan limit, triggering bankrupt warnings on month transitions.

The attached savegame provided is the last month it was alive. Next month it banktupts.


Attachments:
HeliFerry, 1st Sep 1988.sav [2.51 MiB]
Downloaded 17 times

_________________
Formerly known as Samu
Top
   
PostPosted: Mon Feb 26, 2018 4:36 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Feb 26, 2015 12:52 am
Posts: 212
Testing only ships, it crashed immediately on start. cpu evaluator

Code:
dbg: [script] [0] [I] 0.7 API compatibility in effect:
dbg: [script] [0] [I]  - AITown::GetLastMonthProduction's behaviour has slightly changed.
dbg: [script] [0] [I]  - AISubsidy::GetDestination returns STATION_INVALID for awarded subsidies.
dbg: [script] [0] [I]  - AISubsidy::GetSource returns STATION_INVALID for awarded subsidies.
dbg: [script] [0] [S] Your script made an error: excessive CPU usage in valuator function
dbg: [script] [0] [S]
dbg: [script] [0] [S] *FUNCTION [GetCoastTilesCloseToCity()] heliferry-3\ferry.nut line [85]
dbg: [script] [0] [S] *FUNCTION [GetCoastTileClosestToCity()] heliferry-3\ferry.nut line [98]
dbg: [script] [0] [S] *FUNCTION [Valuate()] NATIVE line [-1]
dbg: [script] [0] [S] *FUNCTION [BuildFerryRoutes()] heliferry-3\ferry.nut line [337]
dbg: [script] [0] [S] *FUNCTION [Start()] heliferry-3\main.nut line [42]
dbg: [script] [0] [S]
dbg: [script] [0] [S] [tiles] INSTANCE
dbg: [script] [0] [S] [city] 770170
dbg: [script] [0] [S] [cargo_id] 0
dbg: [script] [0] [S] [range] 20
dbg: [script] [0] [S] [town] 186
dbg: [script] [0] [S] [this] TABLE
dbg: [script] [0] [S] [cargo_id] 0
dbg: [script] [0] [S] [range] 20
dbg: [script] [0] [S] [town] 186
dbg: [script] [0] [S] [this] TABLE
dbg: [script] [0] [S] [towns] INSTANCE
dbg: [script] [0] [S] [ferries_built] 0
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [new_helis] 0
dbg: [script] [0] [S] [passengers_cargo] 0
dbg: [script] [0] [S] [loan_limit] 500000
dbg: [script] [0] [S] [maintenance] INSTANCE
dbg: [script] [0] [S] [ferry] INSTANCE
dbg: [script] [0] [S] [heli] INSTANCE
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] Your script made an error: excessive CPU usage in valuator function
dbg: [script] [0] [S]
dbg: [script] [0] [S] *FUNCTION [BuildFerryRoutes()] heliferry-3\ferry.nut line [337]
dbg: [script] [0] [S] *FUNCTION [Start()] heliferry-3\main.nut line [42]
dbg: [script] [0] [S]
dbg: [script] [0] [S] [towns] INSTANCE
dbg: [script] [0] [S] [ferries_built] 0
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [new_helis] 0
dbg: [script] [0] [S] [passengers_cargo] 0
dbg: [script] [0] [S] [loan_limit] 500000
dbg: [script] [0] [S] [maintenance] INSTANCE
dbg: [script] [0] [S] [ferry] INSTANCE
dbg: [script] [0] [S] [heli] INSTANCE
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] The script died unexpectedly.
One of the running scripts crashed. Please report this to the script author with a screenshot of the AI/Game Script Debug Window


Attachments:
HeliFerry, 1st Feb 1950.sav [1.02 MiB]
Downloaded 16 times

_________________
Formerly known as Samu
Top
   
PostPosted: Wed Mar 07, 2018 11:27 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 23, 2016 9:37 pm
Posts: 7
Looking through the changelog, I think this "fix" from 1.7.0
Quote:
- Fix: [Script] Kill scripts, when a non-suspendable valuator call takes way too long [FS#6473] (r27594)
causes that. The valuator it crashes on is a simple check if a tile is a coast tile. HeliFerry (and also ShipAI) relies heavily on valuators to improve performance for the water-related algorithms, so there are probably many more places in the code I'd need to debug & rewrite. I don't have the time for that now, so the only solution is to disable the use of ferries in the AI settings.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


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

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