YAPF - Testers needed!

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

Post Reply
KUDr
OpenTTD Developer
OpenTTD Developer
Posts: 219
Joined: 11 Jan 2006 21:36
Location: Czech Republic

Post by KUDr »

R2: yes, I agree. Just not sure how to achieve that with just a pathfinder (normally it should find the shortest way). I am now thinking about path driven signals (the next step towards new PBS) where this behavior can be a side effect of negotiation between trains heading to the same junction (the cost of that shorter path will be temporarily higher because of another train that is planning to use the path that whould cause the conflict). In such case the train driver will choose the path that is not the best only for him but that is the best for the current traffic situation (like in real life - where there is a traffic dispatcher).

Any other idea how to achieve similar behavior would be appreciated. We can find an easier way how to do that.
User avatar
mart3p
Tycoon
Tycoon
Posts: 1030
Joined: 31 Oct 2005 21:00
Location: UK

Post by mart3p »

I have been having a problem with road vehicles when using YAPF. The sceenshot shows a test game that illustrates the problem. The vehicle always takes the route with all the bends rather than the faster straight route.

This problem causes my vehicles to follow a zigzag route through towns instead of following the straight bypasses that I have built around them. :(

At present there is no setting for a “road curve penalty” (as there is for NPF) perhaps it should be added.
Attachments
YAPF Road Vehicle Problem.png
YAPF Road Vehicle Problem.png (47.48 KiB) Viewed 8037 times
Image
KUDr
OpenTTD Developer
OpenTTD Developer
Posts: 219
Joined: 11 Jan 2006 21:36
Location: Czech Republic

Post by KUDr »

mart3p: yes, you are right. Probably I missed something in the cost calculation. I will revisit RV YAPF soon and will look at it. Thanks for that comment.
Tiberius
Engineer
Engineer
Posts: 86
Joined: 17 Sep 2004 03:15

Post by Tiberius »

The train mysteriously decided to use the already-occupied platform while there's another platform available ... making presignal useless. Not sure what caused this.
Attachments
TR Freight, 21st Jun 1983.png
TR Freight, 21st Jun 1983.png (74.19 KiB) Viewed 8001 times
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Post by richk67 »

Tiberius wrote:The train mysteriously decided to use the already-occupied platform while there's another platform available ... making presignal useless. Not sure what caused this.
You need to use 2 way signals on the platform entrances. As well as two way, they also mean "choose between".
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
sc79
Director
Director
Posts: 586
Joined: 22 Feb 2005 09:51

Post by sc79 »

2-way signals arnt necessary for NPF or YAPF.
KUDr
OpenTTD Developer
OpenTTD Developer
Posts: 219
Joined: 11 Jan 2006 21:36
Location: Czech Republic

Post by KUDr »

Tiberius: I hope you don't expect me to work on it without reproducible case with savegame and .cfg ...
User avatar
Brianetta
Tycoon
Tycoon
Posts: 2566
Joined: 15 Oct 2003 22:00
Location: Jarrow, UK
Contact:

Post by Brianetta »

Looks like normal NTP behaviour to me. Sure YAPF was actually on for trains?
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED
Tiberius
Engineer
Engineer
Posts: 86
Joined: 17 Sep 2004 03:15

Post by Tiberius »

To richk67:
Thanks. Changing entrance signals to 2-way signals fixes this problem indeed. What I don't understand is the implication of path selection of 2-way signals: Those signals will NEVER be passed reverse. I thought if there's a need of distinction, then it should use another signal type or so to make it more verbose.

To KUDr:
This game uses LOTS of GRF files so I think it may not helpful for debugging. I'll try reproduce this problem and pack a savegame + GRF for you, maybe start again with clean MiniIN later and try reproduce it again.
User avatar
XeryusTC
Tycoon
Tycoon
Posts: 15415
Joined: 02 May 2005 11:05
Skype: XeryusTC
Location: localhost

Post by XeryusTC »

Tiberius wrote:To richk67:
Thanks. Changing entrance signals to 2-way signals fixes this problem indeed. What I don't understand is the implication of path selection of 2-way signals: Those signals will NEVER be passed reverse. I thought if there's a need of distinction, then it should use another signal type or so to make it more verbose.
Red 2 way signals are indentified as dead end by YAPF, this means that a train will never go there unless there is no other choise (which you can prevent with pre-signals).
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image
KUDr
OpenTTD Developer
OpenTTD Developer
Posts: 219
Joined: 11 Jan 2006 21:36
Location: Czech Republic

Post by KUDr »

Tiberius: theoretically it can be YAPF bug related to the first station tile position (where you started to build the station from). If you can reproduce it without newgrf with only trunk (nightly) build i will appreciate that a lot. I am currently working on another bug (MP desync) caused by YAPF cache.

thanks, KUDr
User avatar
mart3p
Tycoon
Tycoon
Posts: 1030
Joined: 31 Oct 2005 21:00
Location: UK

Post by mart3p »

I have found a bug when using YAPF for road vehicles. Vehicles trying to find a depot, can be sent to an opponent's depot if that is nearest. In the attached test savegame, one of the AI's buses (green vehicle 4) is continually trying to enter one of my depots. It is unable to enter so loops around and tries again.

If I switch off YAPF for road vehicles, it fixes the problem.

This is a great way of sabotaging the opponent's road vehicles but I‘m sure it‘s not intended. ;)

I’m using the nightly build at r5508.
Attachments
Find Depot Bug, 12th Sep 2013.sav
(83.49 KiB) Downloaded 359 times
Find Depot Bug, 17th Sep 2013.png
Find Depot Bug, 17th Sep 2013.png (19.34 KiB) Viewed 8612 times
Image
Panzerfather
Engineer
Engineer
Posts: 2
Joined: 16 Jul 2006 19:23

Post by Panzerfather »

Got a bug which ends in a fatal error:
openttd: yapf/hashtable.hpp:228: void CHashTableT<Titem_, Thash_bits_>::Push(Titem_&) [with Titem_ = CYapfRailNodeT<CYapfNodeKeyExitDir>, int Thash_bits_ = 10]: Assertion `&slot.Find(new_item.GetKey()) == __null' failed.
Added the savegame, the game crashes around the 8th October.
Attachments
Wolf Inc, 1. Okt 2000.sav
Savegame
(1.92 MiB) Downloaded 314 times
User avatar
mart3p
Tycoon
Tycoon
Posts: 1030
Joined: 31 Oct 2005 21:00
Location: UK

Post by mart3p »

KUDr: While working on my patch to implement drive-through road vehicle stops, I came across a few problems with YAPF. Some, I have already reported in posts above, but I thought it might be useful for you to see the solutions I came up with. I'm not sure that my changes/hacks are the correct way to fix these problems, but thought they might at least show you where the problems are.

1. Road vehicles preferring bends (as reported above).
Making the cost for road bends YAPF_TILE_LENGTH + 2 seems to work ok. Of course it would be best to make '2' a 'road_curve_penalty' config setting.

2. Road vehicles finding opponents depot (as reported above).
I added a line to FindNearestDepot in yapf_road.cpp, that returns false if the depot found, is not owned by the vehicle's owner. It would be better to only search for the owner's depots in the first place but I couldn't see an easy way of doing that.

Code: Select all

 Node& n = Yapf().GetBestNode();
   TileIndex depot_tile = n.m_segment_last_tile;
   assert(IsTileDepotType(depot_tile, TRANSPORT_ROAD));
+  if (!IsTileOwner(depot_tile, (Owner)v->owner)) return false;
   Depot* ret = GetDepotByTile(depot_tile);
   return ret;
3. Multistop problem.
In function YapfRoadVehDistanceToTile in yapf_road.cpp, the scaling of the distance returned by the function is 10 times what it should be. There is a TODO note already in the code regarding this.

Code: Select all

// TODO: change road YAPF unit from 10 to YAPF_TILE_LENGTH
To determine which road stop bay to use, Multistop uses the returned distance plus a weighting based on the number of vehicles already using the bay. Because the returned distance is 10 times the correct value, this has the predominant effect. Replacing the values of 10 with YAPF_TILE_LENGTH, fixes the problem.

4. The goto depot command is not always working for road vehicles.
This is not a YAPF problem but effects YAPF's depot finding. See bug report at: http://bugs.openttd.org/task/249 There is a note in the code in SetOriginFromVehiclePos:

Code: Select all

// sometimes the roadveh is not on the road (it resides on non-existing track)
// how should we handle that situation?
- this bug is why it happens.
Image
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

Thank you for the comment on SourceForge mart3p. I will leave this up for KUDr to look over and fix when he comes back.

Please also close any bugreports then.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
Luckz
Engineer
Engineer
Posts: 20
Joined: 02 Aug 2006 03:48
Location: CGN / VLN

Post by Luckz »

mart3p wrote:2. Road vehicles finding opponents depot (as reported above).
I added a line to FindNearestDepot in yapf_road.cpp, that returns false if the depot found, is not owned by the vehicle's owner. It would be better to only search for the owner's depots in the first place but I couldn't see an easy way of doing that.
But what if you enable the option to let vehicles actually use other players' depots? IMO it would be advisable to have it check for that option.
User avatar
mart3p
Tycoon
Tycoon
Posts: 1030
Joined: 31 Oct 2005 21:00
Location: UK

Post by mart3p »

Luckz: I presume you are referring to the "Allow depot sharing" option for the subsidiaries patch in the MiniIN. My bug report above is relating to the trunk code which doesn't have this option.

But thanks for pointing this out anyway. I will check if depot sharing is working using YAPF in the MiniIN and I'll post a MiniIN fix if a change is required.
Edit: I've checked the MiniIN code and YAPF depot finding does check the "depot sharing" option.
Image
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

mart3p wrote:2. Road vehicles finding opponents depot (as reported above).
I added a line to FindNearestDepot in yapf_road.cpp, that returns false if the depot found, is not owned by the vehicle's owner.
r5897
mart3p wrote:4. The goto depot command is not always working for road vehicles.
This is not a YAPF problem but effects YAPF's depot finding
r5898

I've added these two fixes as KUDr seems away for a very long time and didn't feel appropiate to wait any longer as there are working fixes for these. When you (KUDr) get back, you can refine these commits if you like.

Thank you mart3p for the patches.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
suikerpluimpje
Engineer
Engineer
Posts: 18
Joined: 03 Apr 2006 09:51
Location: Enschede (The Netherlands)

Post by suikerpluimpje »

I've bin using yapf for a savegamae with more then 800 vehicles, and the started to slow down after about 750 vehicles.

With the normal pathfinding meganism, the game would have been unplayable.

I realy like YAPF.

Now, the only thing I need to do is find a way to create highway's...
Attachments
Flunningville Transport, 18 Jan 2059.png
Flunningville Transport with more then 800 vehicles
(112.83 KiB) Downloaded 232 times
Sorry for my english, I'm dutch...
KUDr
OpenTTD Developer
OpenTTD Developer
Posts: 219
Joined: 11 Jan 2006 21:36
Location: Czech Republic

Post by KUDr »

mart3p: thanks a lot for your hard work on YAPF. Just fixed the
2. Road vehicles finding opponents depot (r6160)
so, that it doesn't fail to find the depot if opponent's depot is closer.

the rest I'll check soon (hopefully)

Edit: done (r6162-3, r6164)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Eddi and 2 guests