Custom airports (version 2.1 including minigame!)

Got an idea for OpenTTD? Post it here!

Moderator: OpenTTD Developers

User avatar
Dimme
Transport Coordinator
Transport Coordinator
Posts: 277
Joined: 30 Jul 2008 12:42
Location: Trondheim, Norway

Custom airports (version 2.1 including minigame!)

Post by Dimme » 31 Jul 2008 12:49

aug. 26.:

Version 2.1:
CustomAirport201.zip
zip file containing executable JAR-file.
(205.41 KiB) Downloaded 1769 times
Bug fixes:
  • Problem with handling reservations on some airports, this resultet in among other things that that the validator kicked in on some correctly placed airports. (Zuu)
  • Resetting the money and number of planes/helicopters when restarting game.
Known issues:
  • The pathfinder cannot find paths that crosses an end of a runway from which an aircraft can start take-off.
  • It is possible to delete the terminals. My idea for OTTD is that a terminal is a station, so that if you create two separate terminals, they will act as separate stations; you will then need a bus route or something between them if playing with cargodest. (As in RL).
aug. 9.:

New version 2.0 ready :)



New features:
  • A minigame, somewhat inspired by tower-defense. You have to make a number of planes and helicopters land and take-off in order to get to the next level. Building your airport costs money. You get 10% interest on saved money per level, plus 5000.
  • A validator that checks if your airport is allowed. It does not stop airports that has no runway or no helipad, as that should be allowed.
  • It is now possible to build terminal buildings. This is regulated so that airports will look more natural.
Bugfix:
The problem in point 8 in the proof stated in another post; it is no longer possible to get deadlocks due to an entire roundabout being filled with aircraft.

I'm happy if anyone displays their most efficient airports, as a target is to make the most efficient airports look natural :)

jul. 31.:

As this is my first post in the forum, I should probably introduce myself. I have played OTTD for about half a year, and TTDPatch before that. I have also been reading this forum since early this spring, and I must say that I'm very impressed with the way the game progresses, and all the work that is being done :D

Now, on to the subject:
The idea of building custom airports have been discussed several times, but ATM Ricks newGRF (air)ports is the closest we get (when that is ready). Some of the main arguments against trying to implement a system that makes the player able to build airports from scratch themselves, are the following:
  • It would be very difficult to implement in a clean way. (A total rewrite of the airport system is needed)
  • Users will create airports with deadlocks all the time, and complain about it in the forum.
  • The system needs to be made so that the most efficient airports also look natural (e.g. doesn't have ten runways next to each other).
I have made a system that solves most of the deadlock-problem. It also makes airports look natural, at least I hope so :) It is based on that an aircraft occupies one tile (or two when moving), and it uses arrowed tarmac tiles to control ground movement (the arrows can be removed after costruction is over). The system is a little comparable to the PBS system for trains; aircraft can move freely in the direction of the arrows, but when moving against them they must reserve all the way to a 'safe' tile. When moving perpendicular to the arrows it must first check whether any other aircraft has reserved a path in the opposite direction. Only gates, helipads, hangars and certain runway tiles are considered 'safe' tiles.
small airport.png
An airport with two runways
small airport.png (6.71 KiB) Viewed 17305 times
All routes are calculated after construction is finished, so the aircraft must follow the directions they get from the 'tower'.

Anyway, it is easier for you to test it and then ask me than for me to explain everything at once... Attached is the source code (java), and a JAR-file that can be executed if you have java runtime.
large airport.png
A larger airport, note that it does't have to be as clean as this, but that makes it more efficient.
large airport.png (10.01 KiB) Viewed 17306 times
I don't know C/C++, so I made it from scratch with java. I'm planning on learnig C++, but if anyone else is interested in this feature, feel free to try to use my ideas and implement it in OTTD (probably quite an immense job).

And please try to get the aircraft stuck forever! (It should only be possible if you make a totally lame airport, without either tarmac or gates).
Last edited by Dimme on 26 Aug 2008 19:42, edited 4 times in total.

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

Re: Custom airports (new idea!)

Post by Yexo » 31 Jul 2008 13:02

Wow, impressive job on implementing this! Very good work. I played a bit with it and ahve two feature requests:
1) The ability to demoslish things again after you built them.
2) The ability to go back to building mode after testing.
And some bug reports:
1) It is possible to build two objects over eachother (mostly things over a runway)
2) After minimizing the application and restoring again, it resizes to full-screen, and becomes very slow
3) the build buttons don't move when resizing (an alternative is to disable resizing completely).

I would really like this feature, if implemented correctly, and it seems you've made a very good start.

Mchl
Director
Director
Posts: 611
Joined: 05 Jan 2007 15:50
Location: Poland
Contact:

Re: Custom airports (new idea!)

Post by Mchl » 31 Jul 2008 13:56

You might want to contact richk67 who's already done some work on custom airports. It'd be shame, if you try to reinvent the wheel ;)

Also see: http://www.tt-forums.net/viewtopic.php?f=33&t=33163

[edit]

Oh yeah... just noticed... you know that :P

User avatar
Dimme
Transport Coordinator
Transport Coordinator
Posts: 277
Joined: 30 Jul 2008 12:42
Location: Trondheim, Norway

Re: Custom airports (new idea!)

Post by Dimme » 31 Jul 2008 16:37

Yexo wrote:Wow, impressive job on implementing this! Very good work. I played a bit with it and ahve two feature requests:
1) The ability to demoslish things again after you built them.
2) The ability to go back to building mode after testing.
And some bug reports:
1) It is possible to build two objects over eachother (mostly things over a runway)
2) After minimizing the application and restoring again, it resizes to full-screen, and becomes very slow
3) the build buttons don't move when resizing (an alternative is to disable resizing completely).

I would really like this feature, if implemented correctly, and it seems you've made a very good start.
Thank you :D and thanks for the bug reports :)

I am aware that there are several issues with the gui, due to me not caring too much about it, as the main purpose was just to prove that it is possible to do this. I will, however, try to improve it a little more before I start reading the OTTD code and learning C++. Another thing is that the pathfinder I made is just some recursion I came up with myself, so I should learn aystar as well... And I am not really much of a programmer. I just took java as a subject once, so I'm really not sure that I can manage to make such a huge patch myself, at least not to the devs satisfaction!

So, take this as a suggestion! I will surely work more with it, but don't expect progress to be very rapid. As I said, anyone with more experience is welcome to give it a try, I can help you with deciding the rules of movement so they become consistent :)
Try my modular airports minigame!

Image

Mchl
Director
Director
Posts: 611
Joined: 05 Jan 2007 15:50
Location: Poland
Contact:

Re: Custom airports (new idea!)

Post by Mchl » 31 Jul 2008 19:41

I played a bit with your application and quite enjoyed it. :)

Somehow I can't stop simulation once it's started. Another thing is that the app stays on on top of all other windows.


I'm running Sun's Java SE 6 Update 10 Beta on Vista.

Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4718
Joined: 09 Sep 2007 05:03
Location: home

Re: Custom airports (new idea!)

Post by Alberth » 01 Aug 2008 08:02

Really nice approach, very simple and elegant.

Next step may be to generate the underlying state machine as used in the NewGRF Airports branch. That would assist in writing the GRF files for the new airports. Even if your code ends up in OpenTTD eventually, it seems like a good direction, since that code will also be using the same state machine approach.

Last but not least, it may be possible to feed the state machine into a model checker like Spin that can search for deadlocks in a systematic way. (So you know there is no deadlock rather than just suspecting it.)

User avatar
Dimme
Transport Coordinator
Transport Coordinator
Posts: 277
Joined: 30 Jul 2008 12:42
Location: Trondheim, Norway

Re: Custom airports (new idea!)

Post by Dimme » 01 Aug 2008 10:24

Thank you all for the feedback!

I have updated the first post with a new version, new features (thanks to Yexo):
  • It is possible to resume building after testing.
  • You can erase things. Note that to erase runways you must click on one of the end tiles.
Bug fixes:
  • It is no longer possible to build over another object, you must erase it first. (Yexo)
  • The window is no longer resizeable, this also solves the problem with the game going slower when you minimize and restore. (Yexo)
  • The app doesn't always stay on top anymore. (Mchl)
Alberth wrote:Really nice approach, very simple and elegant.

Next step may be to generate the underlying state machine as used in the NewGRF Airports branch. That would assist in writing the GRF files for the new airports. Even if your code ends up in OpenTTD eventually, it seems like a good direction, since that code will also be using the same state machine approach.

Last but not least, it may be possible to feed the state machine into a model checker like Spin that can search for deadlocks in a systematic way. (So you know there is no deadlock rather than just suspecting it.)
Some nice tips there, thanks :)

It would be really nice if it is possible to use much of what is made in the NewGRF approach, generating the state GRF code can even be done in java, so that is a very good idea for me to begin with, when NewGRF Airports is ready. It is not intended to be used that way, so there are probably some issues. E.g. it will need a lot of 'areas' for only a small airport, as it makes one 'area' per tile.

It doesn't handle the waiting circle for airborne aircraft correctly either. I have a suggestion that will solve this (or at least make a nice addition to the game): is it possible to make the aircraft 'pathfinder' in OpenTTD reserve a time (slot) for landing on the next airport when the aircraft is just airborne, and then adjust speed so it reaches the slot exactly? The waiting circle can still be used if something unexpected (like a crash, or the calculated speed being too low) occurs. Then one waiting circle per runway won't look so bad, as there seldom will be planes circling. It should be possible to do this with one witing circle per airport as well, and still keep efficiency at a high level.

I will take a look at Spin. Please continue testing however :)
Try my modular airports minigame!

Image

Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4718
Joined: 09 Sep 2007 05:03
Location: home

Re: Custom airports (new idea!)

Post by Alberth » 01 Aug 2008 10:54

Waiting airplanes also just move from point to point just as they do with the tarmac. Points are just further apart from each other, there are no blocks to reserve, and the last point is connected to the first so they fly in circles.

Planes don't use a path-finder afaik. They always move to 'the next point' in their list in a pseudo-straight line. Ie from the last point of the outgoing runway to the first point in the waiting loop of the next airfield. (where 'first point' can be different depending on where you are coming from).

W.r.t. Spin: If you need help, I'll be glad to give you a hand, I've done it before (not always with succes however, unfortunately).

To reduce the number of blocks, if you add the ability to state that one should claim certain tarmac tiles together, a user can make smart dcisions on where to reduce the block count.

Finally, I had some trouble getting planes to leave; do you take into account that a plane may have to taxi on the runway (in my case over the entire runway) before it is in position to take off?
(For some reason, I cannot run your program any-more, it aborts with an error)

Last but not least: Could you please add some explanation on how to run and/or compile your program (in a README or so)?

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

Re: Custom airports (new idea!)

Post by Yexo » 01 Aug 2008 11:32

Running the program is just double starting the jar file (assuming you have a recent version of java installed.)

Nice and fast update. One small bug: if you delete a helipad tile, there will still land helicopters on it. (whatever you build over it.

Mchl
Director
Director
Posts: 611
Joined: 05 Jan 2007 15:50
Location: Poland
Contact:

Re: Custom airports (new idea!)

Post by Mchl » 01 Aug 2008 14:37

Yexo wrote:
Nice and fast update. One small bug: if you delete a helipad tile, there will still land helicopters on it. (whatever you build over it.
But they will not lift off.

User avatar
Dimme
Transport Coordinator
Transport Coordinator
Posts: 277
Joined: 30 Jul 2008 12:42
Location: Trondheim, Norway

Re: Custom airports (new idea!)

Post by Dimme » 02 Aug 2008 10:22

Yexo wrote: One small bug: if you delete a helipad tile, there will still land helicopters on it. (whatever you build over it.
Fixed, updated first post.
Alberth wrote: To reduce the number of blocks, if you add the ability to state that one should claim certain tarmac tiles together, a user can make smart dcisions on where to reduce the block count.
Adding that ability will make the airport less efficient, not necessarily consistent anymore (which is really important). I think it is better just to let it be as it is, even though it limits the size of the airport.
Alberth wrote: Finally, I had some trouble getting planes to leave; do you take into account that a plane may have to taxi on the runway (in my case over the entire runway) before it is in position to take off?
Yes, I do, it is however ATM not allowed to move directly from one runway to another, or directly between gate and runway (may be added later). In heavy traffic, aircraft may (and quite often do) get stuck, due to that their path needs to be totally clear before they can reserve it (especially if you use only landing-runways). This is not IMO a deadlock, as they get to move when traffic becomes less dense, it is also a result of bad airport design. I will try to fix this by letting aircraft stuck this way update their orders from time to time, to check for alternatives.
Alberth wrote: Last but not least, it may be possible to feed the state machine into a model checker like Spin that can search for deadlocks in a systematic way. (So you know there is no deadlock rather than just suspecting it.)
Before a lot of work is put into that, I will attempt to prove that it is consistent (actually, while doing so, I realised it is not, but it can be corrected). So, here it is:

Proof of consistency!

1) Movement to hangar from tarmac is always possible, as the hangar has unlimited space.
2) Movement to gate/helipad from tarmac is possible as long as the gate/helipad is reserved by the aircraft, which is always the case.
3) Movement to take-off-runway from tarmac will always be possible, as any aircraft there always will fly away.
4) Movement with arrows is one-directional, in the sense that movement in the opposite direction first must be reserved.
5) Movement perpendicular to arrows is temporarily one-directional, as it is made sure by reservation that no aircraft can move in the opposite direction until the aircraft that reserves has passed the reserved two tiles (actually it is the movement from one tile to another that is reserved).
6) Movement on a one-directional route (including both case 4 and 5) that does not 'bite itself in the tail' (is not a circle) can be considered a queue, a queue will always move as long as the front of the queue moves.
7) The front of a queue will move due to points 1, 2 and 3 which are the only allowed front ends of a queue, in all other cases the entire route must be reserved.
8 ) Movement on a one-directional route that 'bites itself in the tail' is not consistent (remember that even though the same aircraft never will move around the full circle, the circle might get totally filled up with aircraft, so that none of them can move). This must be checked for. If this case is found, it is possible to let all the aircraft in the circle move simultaneously. I have not done this yet (I discovered the case yesterday when working on this proof) and it is probably not possible to do this kind of check when made for NewGRF. Note that I didn't manage to reproduce this in practice, as it probably demands a larger than 20*20 airport, which is the limit of my gui. Also note that one measure has been taken to limit the occurence of this, and make traffic in general less dense: to exit from gate, runway, helipad or hangar, it is demanded to reserve at least the first two tiles of movement.
9) Reserved movement to a tile from which the above points guarantees free movement is always possible when no traffic is in the way.
10) Movement from gate, helipad, runway or hangar must always be reserved according to 9. Note that if the first movement ends in the queue, only reservation of this tile is necessary, reservation is done for the first two tiles anyway, due to reasons stated in point 8.
11) Movement to landing-runway to take off demands reservation of the entire route, and is therefore possible when no traffic :wink:
12) Landing is only possible on helipads and landing-runways. The entire runway/helipad must be clear and reserved in advance.
13) Takeoff can be done from both kinds of runway, and demands reservation of the entire runway.
14) Movement on runway when landed is possible, but demands reservation according to 9.
15) Movement on runway in order to take off is possible, as long as reservation to the end of the runway where take-off starts is done.
16) Crossing runways is possible as long as reservation that assures that the aircraft gets off the runway is present (must be done according to 9)
17) Points 11-16 makes it possible to have several aircraft on the runway at the same time, as long as no plane is taking off or landing.


I know this is not an easy proof, but I think it is correct (please challenge!) :wink:
Sorry for jpg-images.
rules of movement.jpg
For movement from left to right, cases 1 are considered movement with, cases 2 perpendicular to, and cases 3 against the arrows.
rules of movement.jpg (17.85 KiB) Viewed 16826 times
queue.jpg
A queue such as this, only demands reservation of the next tile, as long as the target is a gate, a helipad, a hangar or a takeoff-runway.
queue.jpg (9.08 KiB) Viewed 16830 times
Attachments
over runway.png
Here, aircraft 1 has just landed, and aircraft 2 can cross the runway in order to get to the take-off runway. It must reserve off the runway.
over runway.png (4.42 KiB) Viewed 16840 times
Try my modular airports minigame!

Image

Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4718
Joined: 09 Sep 2007 05:03
Location: home

Re: Custom airports (new idea!)

Post by Alberth » 02 Aug 2008 14:22

Hmm, previous attempt failed, let's try again :)

I don't understand 5, could you explain the rule that you use for perpendicular movement please?

As for 8, yes it happens.
In the city airport there is a triangle where you can get deadlock. See the picture.

As far as I can see, the solution to this problem to have 1 plane claim 2 blocks,at the same time and release the first one when leaving. In this way, there is always room to move.
Attachments
city-airport-circle.png
city airport with new tarmac tiles, and red triangle where deadlock may happen
city-airport-circle.png (63.24 KiB) Viewed 16773 times

User avatar
Dimme
Transport Coordinator
Transport Coordinator
Posts: 277
Joined: 30 Jul 2008 12:42
Location: Trondheim, Norway

Re: Custom airports (new idea!)

Post by Dimme » 02 Aug 2008 18:52

Alberth wrote:Hmm, previous attempt failed, let's try again :)
Sorry about that, not so easy to explain it :)
Alberth wrote: I don't understand 5, could you explain the rule that you use for perpendicular movement please?
I can try! There are two kinds of reservations: The 'normal' one which is rather trivial, reserves a tile so that it can be used by a specific aircraft only, it is shown as a small square in the upper left corner of the tile. The other kind of reservation involves the movement between two tiles, plane '2' reserves that it is going to move from one tile to the next, at some point in its route. It is still legal for other aircraft to move between the two tiles, but only in the same direction as plane '2', reservation and reservation-check is done before leaving gate/helipad/runway/hangar. This kind of reservation does not block movement of other aircraft as much as the 'normal' one, but is necessary in order to make sure no two aircraft will meet, wanting to go to the tile the other one is at. This kind of reservation is marked with a square in the middle between the two tiles (I should probably have used arrows in stead, to make it clearer).
reservations.png
Plane number one uses ordinary reservation to reserve it's route, plane number 2 uses the other kind of reservation, to make sure no aircraft can move in the opposite direction.
reservations.png (6.01 KiB) Viewed 16717 times
Alberth wrote: As for 8, yes it happens.
In the city airport there is a triangle where you can get deadlock. See the picture.

As far as I can see, the solution to this problem to have 1 plane claim 2 blocks,at the same time and release the first one when leaving. In this way, there is always room to move.
The city-airport is 'handmade', so the state-machine is really quite different from mine. I use two different kinds of runways, one for takeoff only, and one primarily for landing. When you only have one runway, the one made primarily for landing must be used. This runway is not very flexible for takeoff-aircraft, as it demands aircraft to reserve the entire route from gate to the runway (rule 11) , this is to avoid the problem you stated, and similar ones. This is a more general way to avoid the problem then the one in the city-airport, and hence not as efficient. (it claims all the blocks on its way, not just 2 :wink: ) This is not a big problem, as feeding only one runway efficiently is easy anyway.

Thank you for asking specific questions :)
Try my modular airports minigame!

Image

User avatar
Dimme
Transport Coordinator
Transport Coordinator
Posts: 277
Joined: 30 Jul 2008 12:42
Location: Trondheim, Norway

Re: Custom airports (version 2.0 including minigame!)

Post by Dimme » 09 Aug 2008 12:41

Version 2.0 is now ready, it contains:

New features:
  • A minigame, somewhat inspired by tower-defense. You have to make a number of planes and helicopters land and take-off in order to get to the next level. Building your airport costs money. You get 10% interest on saved money per level, plus 5000.
  • A validator that checks if your airport is allowed. It does not stop airports that has no runway or no helipad, as that should be allowed.
  • It is now possible to build terminal buildings. This is regulated so that airports will look more natural.
Bugfix:
The problem in point 8 in the proof stated in another post; it is no longer possible to get deadlocks due to an entire roundabout being filled with aircraft.

File included in first post.
Try my modular airports minigame!

Image

Mchl
Director
Director
Posts: 611
Joined: 05 Jan 2007 15:50
Location: Poland
Contact:

Re: Custom airports (version 2.0 including minigame!)

Post by Mchl » 09 Aug 2008 13:25

Sooner or later you'll end up with Airport Tycoon. :wink:

User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Custom airports (version 2.0 including minigame!)

Post by CommanderZ » 09 Aug 2008 13:41

I can't wait to have this in OTTD :)

jaybud4
Engineer
Engineer
Posts: 116
Joined: 16 Feb 2008 06:13

Re: Custom airports (version 2.0 including minigame!)

Post by jaybud4 » 09 Aug 2008 16:46

This inside OTTD would be awesome, although very hard to implement...
Image
If you're bugged by anything I say/do: Please send me a PM. I don't always watch every thread I post in after I do so.

User avatar
Dimme
Transport Coordinator
Transport Coordinator
Posts: 277
Joined: 30 Jul 2008 12:42
Location: Trondheim, Norway

Re: Custom airports (version 2.0 including minigame!)

Post by Dimme » 09 Aug 2008 20:35

Mchl wrote:Sooner or later you'll end up with Airport Tycoon. :wink:
I know :) I have too many ideas. Some day, I should end up with a patch for OTTD that only contains the most essential...
CommanderZ wrote:I can't wait to have this in OTTD :)
Me too :D
jaybud4 wrote:This inside OTTD would be awesome, although very hard to implement...
Yes. Alberth suggested me to make it work as a GRF creating gui for NewGRF Airports, but I'm not sure that is possible. If it isn't, I guess a start will be to make a gui (and some simple graphics) to place the airport tiles, and then build the rest from there :) Won't happen immediately, though, I must learn a lot first :?
Try my modular airports minigame!

Image

User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: Custom airports (version 2.0 including minigame!)

Post by DJ Nekkid » 09 Aug 2008 20:46

there seem to be a bug, if the gridlock-detector pops in, the game wont reset. I.e. i can't get it to start/remove the error message

edit:

and sometimes dont the planes show up either :)
Member of the
ImageImage

User avatar
EXTspotter
Tycoon
Tycoon
Posts: 3122
Joined: 08 Jan 2008 18:51
Location: Salisbury, UK

Re: Custom airports (version 2.0 including minigame!)

Post by EXTspotter » 09 Aug 2008 21:58

I can't extract the file, it says there is an error in it.
Image
Image

Post Reply

Return to “OpenTTD Suggestions”

Who is online

Users browsing this forum: No registered users and 3 guests