distance between ships
Moderator: OpenTTD Developers
- HackaLittleBit
- Director
- Posts: 550
- Joined: 10 Dec 2008 16:08
- Location: tile 0x0000
distance between ships
Hello
A new try
Improved ship movement.
Reason:
Try to eliminate ships moving through each other as much as possible.
Workings:
Ship looks on new tile and one further to see if there is ship.
If encountered speed is divided by 4.
Only if plain water tiles are available on new tile, and on next tile if new track would be followed, the ship will change course.
The ship will then turn extra 45º from original course.
If there is no space to move out of the way, normal direction is maintained, albeit with reduced speed.
This forces player to choose placing of buoy's and dock's more carefully.
Very large amounts of ships requires more maneuvering space.
In that case it is advised to create route with buoy's for both directions.
If ships encounter each other in narrow channels (1 tile), or there is no space to turn away (coast or end of map etc.), speed will be reduced and they will glide over each other (old behavior).
This is done to avoid loop situation. (Ships endlessly turning in circle)
3 tiles from destination tile (buoy, dock etc.) ships have "normal" behavior.
This is done for game play.
Some time penalty is a result of all these changes so maybe some tinkering in ships earnings/costs is desirable.
If ship is stopped it will not be detected by other ships. (Avoid sabotage)
When ship has TRACK_BIT_WORMHOLE (Aqua ducts) this patch has no effect.
I had nicest results with NPF but YAPF is best option.
Resolved:
This time no desyncs problems.
Bugs:
Not known.
Path finder is not affected by this patch because rectification to direction are made after the pathfinder is called.
(I may be wrong here so please correct me if so.)
At this moment the new behavior is active when 90º turns are forbidden for trains and ships.
(See _settings_game.pf.forbid_90_deg line in patch)
You can change it in advanced settings, vehicles, routing, Forbid trains and ships to make 90º turns.
Please have fun and report any problems.
Regards
P.S. Wouldn't it be nice to earn some money with ships
EDIT: This post was edited to improve story.
and will be the place to find most up to date patch
Regards HackaLittleBit
A new try
Improved ship movement.
Reason:
Try to eliminate ships moving through each other as much as possible.
Workings:
Ship looks on new tile and one further to see if there is ship.
If encountered speed is divided by 4.
Only if plain water tiles are available on new tile, and on next tile if new track would be followed, the ship will change course.
The ship will then turn extra 45º from original course.
If there is no space to move out of the way, normal direction is maintained, albeit with reduced speed.
This forces player to choose placing of buoy's and dock's more carefully.
Very large amounts of ships requires more maneuvering space.
In that case it is advised to create route with buoy's for both directions.
If ships encounter each other in narrow channels (1 tile), or there is no space to turn away (coast or end of map etc.), speed will be reduced and they will glide over each other (old behavior).
This is done to avoid loop situation. (Ships endlessly turning in circle)
3 tiles from destination tile (buoy, dock etc.) ships have "normal" behavior.
This is done for game play.
Some time penalty is a result of all these changes so maybe some tinkering in ships earnings/costs is desirable.
If ship is stopped it will not be detected by other ships. (Avoid sabotage)
When ship has TRACK_BIT_WORMHOLE (Aqua ducts) this patch has no effect.
I had nicest results with NPF but YAPF is best option.
Resolved:
This time no desyncs problems.
Bugs:
Not known.
Path finder is not affected by this patch because rectification to direction are made after the pathfinder is called.
(I may be wrong here so please correct me if so.)
At this moment the new behavior is active when 90º turns are forbidden for trains and ships.
(See _settings_game.pf.forbid_90_deg line in patch)
You can change it in advanced settings, vehicles, routing, Forbid trains and ships to make 90º turns.
Please have fun and report any problems.
Regards
P.S. Wouldn't it be nice to earn some money with ships
EDIT: This post was edited to improve story.
and will be the place to find most up to date patch
Regards HackaLittleBit
- Attachments
-
- harbor.png (74.35 KiB) Viewed 14203 times
-
- ships_movement_24115_v5.patch
- (2.15 KiB) Downloaded 318 times
Last edited by HackaLittleBit on 12 May 2012 14:33, edited 1 time in total.
- jonty-comp
- Tycoon
- Posts: 2542
- Joined: 22 Oct 2005 16:05
- Location: Chesterfield, England
- Contact:
Re: distance between ships
A good idea! I've just patched it into r16000 (woo milestone) and the ships definitely make an effort to not run into each other. Only one ship can dock at a time, and the other ships flit about a bit like they're not quite sure where to go. The larger ships still clip a bit because they cover more than one tile, but I guess that's fairly easily remedied by just increasing the distance they keep apart.
All in all, I'd say it's definitely better than the default behaviour!
All in all, I'd say it's definitely better than the default behaviour!
- Attachments
-
- These ships are all going to the same place from the same place, but they've spread out into a nice little fleet.
- Frahattan Springs Transport, 1940-03-10.png (6.87 KiB) Viewed 14088 times
-
- As you see they circle around the docks a bit when in a confined space. Perhaps a waiting area or something like that is in order.
- Frahattan Springs Transport, 1940-06-10.png (22.36 KiB) Viewed 14091 times
JontySewell.net | twitter | last.fm | tumblr | YouTube | RaW 1251AM
Re: distance between ships
I'd suggest removing the behaviour when at a dock otherwise ships are at an even bigger disadvantage over other vehicles.
Jon
Re: distance between ships
the proper solution is to give docks a state machine similar to airports. and to give ships significantly higher capacity, so you just won't need as many.
also, i can imagine ships of different width (1/2 tile (similar to road vehicles), 1 tile (what they are now) and 2 tiles (for ocean liners. those probably won't fit into the current locks))
also, i can imagine ships of different width (1/2 tile (similar to road vehicles), 1 tile (what they are now) and 2 tiles (for ocean liners. those probably won't fit into the current locks))
Re: distance between ships
Hmm ... something like my NewGRF ( http://www.tt-forums.net/viewtopic.php?f=36&t=33030 ) with very large ships?Eddi wrote:the proper solution is to give docks a state machine similar to airports. and to give ships significantly higher capacity, so you just won't need as many.
Slight problem would be - with current ships, the are rarely used. If we decrease their effectivity by disallowing "stacking" ... they won't get more favorite means of transport :)
If you need something, do it yourself or it will be never done.
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
-
- Tycoon
- Posts: 1828
- Joined: 10 Jul 2006 00:43
- Location: Spain
Re: distance between ships
Awesome idea, but We will need larger docks.hackalittlebit wrote:Hello
Tried to improve ship behavior a bit.
wanted to have some distance between ship while sailing and tried to avoid collisions between them.
( Head on collision will make them blow their horns.)
Regards HackaLittleBit
Sorry if my english is too poor, I want learn it, but it isn't too easy.
- [list][*]Why use PNG screenshots in 8 bpp games.
[*]Caravan site New Industry. · Spain set. · Some spanish trains for locomotion[*]Favourites:GRVTS · ECS · FIRS
Re: distance between ships
Currently with ships it is somewhat like with airports - you can have only one dock per station, like with airports.
I think that if we add this patch, allowing more docks to be built in one station would become a must (like you can build more bus or lorry stations). Well, that will require changes in some game logic and probably also ship's pathfinder.
I think that if we add this patch, allowing more docks to be built in one station would become a must (like you can build more bus or lorry stations). Well, that will require changes in some game logic and probably also ship's pathfinder.
If you need something, do it yourself or it will be never done.
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
Re: distance between ships
IMHO, cargo like coal or oil should have zero dependence on delivery time (i.e. a completely flat payment rate curve). so if some cargos have the only goal to transport lots, not fast, then ships get a lot more interesting for these cargos (especially if you can put several train loads of cargo into one ship)Bilbo wrote:If we decrease their effectivity by disallowing "stacking" ... they won't get more favorite means of transport
Re: distance between ships
Hmm ... I think the payment curve can't be defined as completely flat in NewGRF, but I think you can have it completely flat for 637 days, with slow decrease after that (well, while the coal does not decay, waiting 2 years for your shipment isn't good either)Eddi wrote:IMHO, cargo like coal or oil should have zero dependence on delivery time (i.e. a completely flat payment rate curve). so if some cargos have the only goal to transport lots, not fast, then ships get a lot more interesting for these cargos (especially if you can put several train loads of cargo into one ship)
May be interesting to make some NewGRF with very flat curves, very islandish maps and high capacity ships. I bet most people will then use ships to transport cargo :)
If you need something, do it yourself or it will be never done.
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
- andythenorth
- Tycoon
- Posts: 5658
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: distance between ships
Nice patch - I haven't tried it but the screenshots and description give the idea. Ships need some attention lavished on them
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Re: distance between ships
Nice idea, simple and very effective.
I played with it a little and found a 'new' problem, ships can now deadlock, see pic
The bottom-right ship wants to go to the top-left, while the two top-left ships want to go the to the bottom-right.
Of course this happens as soon as ships cannot move onto each other, so it was to be expected.
In a canal, I don't think it is a problem. A player is (or should be) smart enough not to push ships in two directions through a single tile canal (after taking the picture, I widened the canal to two tiles, and the ships-jam resolved itself).
I haven't tested it, but I expect the problem to also happen in a lock, which is bad as a user cannot widen a lock.
I played with it a little and found a 'new' problem, ships can now deadlock, see pic
The bottom-right ship wants to go to the top-left, while the two top-left ships want to go the to the bottom-right.
Of course this happens as soon as ships cannot move onto each other, so it was to be expected.
In a canal, I don't think it is a problem. A player is (or should be) smart enough not to push ships in two directions through a single tile canal (after taking the picture, I widened the canal to two tiles, and the ships-jam resolved itself).
I haven't tested it, but I expect the problem to also happen in a lock, which is bad as a user cannot widen a lock.
- Attachments
-
- boats trying to pass each other.
- boats_deadlock.png (19.84 KiB) Viewed 13683 times
- HackaLittleBit
- Director
- Posts: 550
- Joined: 10 Dec 2008 16:08
- Location: tile 0x0000
Re: distance between ships
Alberth
Change
to
This was just a quick hack.
If you look at the code you will see that ships only will try to move out of the way of each other when trackbit set to 3 way.
If they have the behavior that you describe it is because of bad track bits I guess.
Trackbits I am missing in OpenTTD:
Any reason for that developers?
I will submit this code to flyspray soon.
I am not intending to do anything more with it, so if you want to use or change it feel free
Change
Code: Select all
if (v->direction == ReverseDir(u->direction)) PlayShipSound(v); // imminent frontal collision :)
Code: Select all
if (v->direction == ReverseDir(u->direction)) return NULL; // no frontal collision :)
This was just a quick hack.
If you look at the code you will see that ships only will try to move out of the way of each other when trackbit set to 3 way.
If they have the behavior that you describe it is because of bad track bits I guess.
Trackbits I am missing in OpenTTD:
Code: Select all
TRACK_BIT_FORK_NE = TRACK_BIT_UPPER | TRACK_BIT_RIGHT, ///< "Arrow" to the north-east
TRACK_BIT_FORK_SE = TRACK_BIT_LOWER | TRACK_BIT_RIGHT, ///< "Arrow" to the south-east
TRACK_BIT_FORK_SW = TRACK_BIT_LOWER | TRACK_BIT_LEFT, ///< "Arrow" to the south-west
TRACK_BIT_FORK_NW = TRACK_BIT_UPPER | TRACK_BIT_LEFT, ///< "Arrow" to the north-west
TRACK_BIT_SWITCH_R_NE = TRACK_BIT_X | TRACK_BIT_RIGHT, ///< "Arrow" to the north-east
TRACK_BIT_SWITCH_R_SE = TRACK_BIT_Y | TRACK_BIT_RIGHT, ///< "Arrow" to the south-east
TRACK_BIT_SWITCH_R_SW = TRACK_BIT_X | TRACK_BIT_LEFT, ///< "Arrow" to the south-west
TRACK_BIT_SWITCH_R_NW = TRACK_BIT_Y | TRACK_BIT_LEFT, ///< "Arrow" to the north-west
TRACK_BIT_SWITCH_L_NE = TRACK_BIT_X | TRACK_BIT_UPPER, ///< "Arrow" to the north-east
TRACK_BIT_SWITCH_L_SE = TRACK_BIT_Y | TRACK_BIT_LOWER, ///< "Arrow" to the south-east
TRACK_BIT_SWITCH_L_SW = TRACK_BIT_X | TRACK_BIT_LOWER, ///< "Arrow" to the south-west
TRACK_BIT_SWITCH_L_NW = TRACK_BIT_Y | TRACK_BIT_UPPER, ///< "Arrow" to the north-west
I will submit this code to flyspray soon.
I am not intending to do anything more with it, so if you want to use or change it feel free
- HackaLittleBit
- Director
- Posts: 550
- Joined: 10 Dec 2008 16:08
- Location: tile 0x0000
Re: distance between ships
Forgot this one
if you want the ships quiet around the dock:
add this code
Regards HackaLittleBit
if you want the ships quiet around the dock:
add this code
Code: Select all
if (v->cur_speed == 0 ) return NULL;
Re: distance between ships
Alberth wrote:Nice idea, simple and very effective.
I played with it a little and found a 'new' problem, ships can now deadlock, see pic
The bottom-right ship wants to go to the top-left, while the two top-left ships want to go the to the bottom-right.
Of course this happens as soon as ships cannot move onto each other, so it was to be expected.
In a canal, I don't think it is a problem. A player is (or should be) smart enough not to push ships in two directions through a single tile canal (after taking the picture, I widened the canal to two tiles, and the ships-jam resolved itself).
I haven't tested it, but I expect the problem to also happen in a lock, which is bad as a user cannot widen a lock.
That's not a problem, that's a feature!
Just build 2 tiles wide canals as you should do if ships sink when crashing on each other
Trains and vehicles can deadlock, why not ships too?
This will make you think on what you are doing instead of just place a line of water
Go ahead hackalittlebit!
- HackaLittleBit
- Director
- Posts: 550
- Joined: 10 Dec 2008 16:08
- Location: tile 0x0000
- HackaLittleBit
- Director
- Posts: 550
- Joined: 10 Dec 2008 16:08
- Location: tile 0x0000
Re: distance between ships
By the way;
Forgot to mention JacobD88 it was his suggestion.
Sorry JacobD88
Forgot to mention JacobD88 it was his suggestion.
see http://www.tt-forums.net/viewtopic.php?p=760939#p760939Looks like he's got very long docks on there... Maybe supporting multiple ships (that don't overlap) just speculation
Sorry JacobD88
Re: distance between ships
I modified the code as you suggested, and had another try. I don't like the result very much, ships avoid each other, except when they run into each other frontally.
While playing, I found another feature, see the picture. The ship at the left is leaving, the ship at the right must go to the docks. However, the latter cannot turn left due to the presence of the left ship, and so they move away from the dock together.... (probably until the left ship turns or so, but I didn't wait for that).
If you want the 'non-colliding_ships_bug.sav' file, send me a PM.
About deadlocking ships in locks: Limiting the number of ships in a lock to 1 may be a big step forward already. It can still break when you have several locks after each other, but that does not happen very often.
Wolf01: I completely agree with your view, except that the player should have the ability to fix the situation. With locks some extra care may be needed.
hackalittlebit: I have not yet studied the track code, so I don't really understand how your patch works. As for the missing combinations, apparently nobody needed them enough to add them.
While playing, I found another feature, see the picture. The ship at the left is leaving, the ship at the right must go to the docks. However, the latter cannot turn left due to the presence of the left ship, and so they move away from the dock together.... (probably until the left ship turns or so, but I didn't wait for that).
If you want the 'non-colliding_ships_bug.sav' file, send me a PM.
About deadlocking ships in locks: Limiting the number of ships in a lock to 1 may be a big step forward already. It can still break when you have several locks after each other, but that does not happen very often.
Wolf01: I completely agree with your view, except that the player should have the ability to fix the situation. With locks some extra care may be needed.
hackalittlebit: I have not yet studied the track code, so I don't really understand how your patch works. As for the missing combinations, apparently nobody needed them enough to add them.
- Attachments
-
- right ship cannot turn
- wrong_direction.png (26.51 KiB) Viewed 13475 times
- HackaLittleBit
- Director
- Posts: 550
- Joined: 10 Dec 2008 16:08
- Location: tile 0x0000
Re: distance between ships
PLS send me the sav.
How the code works is very simple.
I look 2 tiles ahead (new tile + 1)when ship found on that tile turn to left side to avoid collision.
only works when 3way track bit set. (In theory, you should have space to move).
other track bit combination's are ignored.
The whole thing happens only when entering new tile and after the trackfinder has determined the route.
Anyway thanks for testing.
Regards HackaLittleBit
How the code works is very simple.
I look 2 tiles ahead (new tile + 1)when ship found on that tile turn to left side to avoid collision.
only works when 3way track bit set. (In theory, you should have space to move).
other track bit combination's are ignored.
The whole thing happens only when entering new tile and after the trackfinder has determined the route.
Anyway thanks for testing.
Regards HackaLittleBit
Re: distance between ships
I think we'll need some one-way locks and perhaps specifying some routes in the canal to be one-way, otherwise there will be always risk of deadlock - imagine fast ship overtaking a slow ship and from other side, another fast ship. We can have deadlock quite easily ....
If you need something, do it yourself or it will be never done.
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
- HackaLittleBit
- Director
- Posts: 550
- Joined: 10 Dec 2008 16:08
- Location: tile 0x0000
Re: distance between ships
This feature has been recognized as bug.Alberth wrote:While playing, I found another feature, see the picture. The ship at the left is leaving, the ship at the right must go to the docks. However, the latter cannot turn left due to the presence of the left ship, and so they move away from the dock together.... (probably until the left ship turns or so, but I didn't wait for that).
insert this code PLS.
Code: Select all
if (v->cur_speed <= u->cur_speed) v->cur_speed >>= 1; // go half speed to let other ship pass
Who is online
Users browsing this forum: Google Adsense [Bot] and 41 guests