distance between ships

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: distance between ships

Post by HackaLittleBit »

Bilbo wrote:I think we'll need some one-way locks
Test and See that it is no problem those locks.

Regards HackaLittleBit
Attachments
ships_16018.patch
(2.26 KiB) Downloaded 161 times
User avatar
SirXavius
Transport Coordinator
Transport Coordinator
Posts: 302
Joined: 28 Jun 2006 18:25
Location: Florida

Re: distance between ships

Post by SirXavius »

I always drool a little with anticipation when hackalittle assembles a patch. And this one has some very good implications for making ships more appealing. One of the things i always hated was their utter disregard for each other! :twisted:

I have actually just begun using ships, and in one instance i've thought about using double canals just to keep the ships clear of each other. So now that they have to avoid each-other, that just means the player has to employ a little strategy. But it would be nice to have a good ship .grf, that makes them more competitive with trains and planes (and has more than a few vessels).

Now, since patches are out of my grasp, i shall begin my period of fasting and deep meditation for the bugs to be exterminated and the code to be incorporated into the trunk.......ohhhhmmmmmm
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: distance between ships

Post by HackaLittleBit »

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
Attachments
ships_movement_24115_v5.patch
(2.15 KiB) Downloaded 146 times
Last edited by HackaLittleBit on 15 Apr 2012 17:04, edited 3 times in total.
Supercheese
Tycoon
Tycoon
Posts: 1660
Joined: 16 Dec 2007 22:24
Location: Idaho, USA

Re: distance between ships

Post by Supercheese »

HackaLittleBit wrote:P.S. Wouldn't it be nice to earn some money with ships ;)
We can't already?! :o :P
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: distance between ships

Post by HackaLittleBit »

Small change.

I forgot to tell that by smart placing of the bouy's many collisions can be avoided.
See pic's for difference.
Without patch
Image
With patch
Image
Test game used ottdcoop 122

Thanks

Edit: See this post for most up to date pach

EDIT: took out some non relevant info.
Attachments
with.png
with.png (88.92 KiB) Viewed 771 times
without.png
without.png (71.8 KiB) Viewed 771 times
Last edited by HackaLittleBit on 15 Apr 2012 15:34, edited 2 times in total.
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: distance between ships

Post by HackaLittleBit »

And here after some repositioning of buoy's
Image
Attachments
repos.png
repos.png (101.55 KiB) Viewed 771 times
User avatar
supermop
Tycoon
Tycoon
Posts: 1104
Joined: 21 Feb 2010 00:15
Location: Fitzroy North - 96

Re: distance between ships

Post by supermop »

This is so cool! Can you adjust the amount of space the ships prefer to leave clear? (parameter?)

Neat work!
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: distance between ships

Post by HackaLittleBit »

supermop wrote:Neat work!
Thanks
supermop wrote: Can you adjust the amount of space the ships prefer to leave clear? (parameter?)
No. Not really necessary , after some time ships regulate distance.
It is fun to play with though.
handrake
Engineer
Engineer
Posts: 55
Joined: 26 Mar 2012 10:23

Re: distance between ships

Post by handrake »

Wouldn't this patch burden PF in one way or another? I don't know how much, but I'm sure there's going to be some.
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: distance between ships

Post by HackaLittleBit »

handrake wrote:Wouldn't this patch burden PF in one way or another
Small change is made after PathFinder.(See ChooseShipTrack func)
Only when entering new tile PathFinder is called.

So no known negative effects.

Regards.
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: distance between ships

Post by HackaLittleBit »

Small update to patch.

See this post for full updated story and patch

From now on you can find there most up to date patch always in that post.

Changes: Code style and little code optimization.
I can not find bugs anymore so report them please.

HackaLittleBit
User avatar
kyosuke1989
Transport Coordinator
Transport Coordinator
Posts: 273
Joined: 24 Mar 2008 13:04
Location: Finland

Re: distance between ships

Post by kyosuke1989 »

I discussed this feature with my friend (isn't here on TT-forums), and i think the current way of ships overlapping each other is ridiculous. This feature could hopefully be in trunk.
User avatar
FLHerne
Tycoon
Tycoon
Posts: 1543
Joined: 12 Jul 2011 12:09
Location: St Ives, Cambs, UK

Re: distance between ships

Post by FLHerne »

HackaLittleBit wrote: I can not find bugs anymore so report them please.
Is a no-bugs-found report any use? :D
Been using for quite some time now, looks great, no problems!
Temporary Permanent signature filling text. Content coming soon delayed indefinitely! Oh, and I have had a screenshot thread.
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer building robots; now I ring church bells.
Author of an incredibly boring stickied post about NewGRFs.
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: distance between ships

Post by HackaLittleBit »

Update Patch:

Ships can now pass on both sides of other ships to try to avoid collision.

How it works:
Ship checks 3 tiles in front
I collision imminent it will try to find a way to avoid.
The track that the pathfinder suggested is deducted and a new path is selected.
If it is not possible to use this new path nothing will be changed.

4 patches:

1. A dedicated setting to enable ship collision avoidance (Thanks JGR!)
2. Make pathfinder table available to for ships.
3. Try to avoid ship collisions
4. Handle ship collision detection on aqueducts.

+ savegame that I used for testing.

all in the attatched zipfle

Have fun!

P.S. for the time being I will leave the old patch on the first page

EDIT

I went a bit to wild with detection on aqueducts.
It was possible to crash the game by stopping when boat was on bridge.
So for now this has to be reverted. See second patch to do so.
the rest 98% works. ;-)
Attachments
trunk_avoid_ship_collision_v6.zip
(21.45 KiB) Downloaded 97 times
22764_no detection on aqueducts.patch
(1.16 KiB) Downloaded 96 times
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: distance between ships

Post by HackaLittleBit »

I think the patch does now what it was supposed to do from the beginning.
'Try to avoid collisions.'
In order not to disturb game play to much, they may still collide once a while.
I am happy with the result.
On aqueducts they detect each other also now.
I even think that the old pathfinder was introducing some random behaviour for ships.
This disappeared with the new pathfinders.
So here I give it back.

2 patches:
1: Try to avoid ship collision.
2: Settings (JGR)

P.S. If you want to play with old save games don't apply the settings patch.
For some reason I am not able to load old games after doing so.


Enjoy.
Attachments
svn_27967_ship_collision_v7.patch
(7.26 KiB) Downloaded 247 times
svn_27967 settings.patch
(4.66 KiB) Downloaded 97 times
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: distance between ships

Post by Wahazar »

What about docks? Are many ships waiting pile up (infinity dock capacity+hard to click proper ship) or are waiting queued till departure of another ship?
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: distance between ships

Post by HackaLittleBit »

Now they still make a nice pile.

Maybe if player would put a depot close by we could send the ships to the depot and load/unload only if place is available at the dock.
Dunno exactly what people want and what is possible.
Making a queue? Hmmmm I don't know.
xarick
Transport Coordinator
Transport Coordinator
Posts: 341
Joined: 26 Feb 2015 00:52

Re: distance between ships

Post by xarick »

How do I apply your patch with TortoiseSVN? I couldn't do it. It creates a 'b' folder
Formerly known as Samu
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: distance between ships

Post by HackaLittleBit »

1
svn_27967_ship_collision_v7.patch you could do by hand.
Most of it is just copy paste.
just take the + in front away

2
I can highly recommend tortoiseHG.
Just try it.
I use it on linux and I am very! happy. amazing tool.

3 make a patch with svn and have a look at that.
Then look what the differences are between hg and svn patch and then make the changes by hand.

I don't use svn for a long time so somebody with experience can help you better.
In the earlier days svn was more tolerant about hacking in a patch. I don't know how it is now.

success!
perverted monkey
Traffic Manager
Traffic Manager
Posts: 161
Joined: 02 Mar 2009 02:07

Re: distance between ships

Post by perverted monkey »

HackaLittleBit wrote:Now they still make a nice pile.
:(
HackaLittleBit wrote:Making a queue?
:D
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 20 guests