[1.0.0] more trains fit between signals than the preview shows on c

Bugs that are actually features.
Post Reply
sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

[1.0.0] more trains fit between signals than the preview shows on c

Post by sparr »

Code: Select all

0eNqlltuOmzAQhl+l8k1vAPlsnGeo1N5XUcUSK7FE7AhItlHEu9cEQkp3sg3OHcaeb37PQZ4LequO5lBb16LVBdnSuwatfl5QY7euqPp/7flg0ArZ1uxRglyx71d1YSvUJci6jfmNVqRbJ8i41rbWDPbXxfmXO+7fTB0OTJblsT6ZTXoFJOjgm2DjXe8ocFImaYLOaMVkHugbW5ty2CZd8gFKZ3LScldYl47CITTJxABX4WuO5wCeTfjKl37vW3syIJeNVJlhJoiQtIf72gZeMZzEyTV+TW/z7v0maOcd4JJPLps23Gm7ax8H6uaVQSAxgXpOiErrD3BMJkoSfI5yEQKQMkKbgLSpCJCCQHkESEMgfa/Oot769L3YBttPMDl7nOq+yKw7hT++DmfdsaoAlwQvF58TSDwhESSwaAiNIIEpJmxpRDV+OaIRzZODdUVEBAksLBLRNBrOckTXaDjL+eLcqJdzoyPUg5VFI/pGg1mmEX2jwSxTujCiHPNXI0rZYvUcg5VFeQQJrCwqIkhwluXT8wIfOATPH3QBUdWzLzrPOCccSypu9ExhRqBs4ZxJRbUQklGKtVIqZ/R69uObD981f/auCo9q5PyuFKIu6Tg1ctmcy6ChCM+Hrk/GLZ7dosf+Hbeg7LAF/ahuitX/I8EWvGpKPOKG+bYpd2ZzrMYB915B/Zr9tT/Mz9Ms9cO05sv3r99MEdq5W/cK57ZUPW+8Hooq7Nzn9gSdTN0MOnPCFddKKoKlkF33B94f0mc=

Code: Select all

0eNqtl92O2jAQhV+l8k1vQuT/H55hpfa+QlUWLDZSiFES2CKUd69DWHahbusj7aVj+4tnzhkncybPzcHvu7odyPJM6nVoe7L8cSZ9vW2rZno2nPaeLEk9+B0pSFvtplFX1Q0ZC1K3G/+LLNm4Kohvh3qo/bz/Mjj9bA+7Z9/FBbed60N39JvFBVCQfejjntBOL4qchTC0ICeylExH+qbu/Hqe5mPxB5TfoE1Yh10Y6qNPMbUrGVdXriqlEnEY8aGrI7Ga19KSaW6tc9ZwQQWljgrBqbjsnILvJ95rCJv4YjkmjiNux+mHGN72ZfhrlNpcTyPuoxQJrLxL+uIqTAoqy7cgRanuwSoBVtnnldxdweb/qmgAa/KxBsCqfKwFsCIf6wAsy8cyms9lgGaMAVxANMYBLqAaEwAXkI1JgIvoBtQaRXTTeVegpKI0ylh2VxoP91/qolOpi44BtUgRtwDFSBG3ANVIAbdwoBop4Bb+4WtZdduweK22cW3iync6U9b2GB+FLq5pD02Temd+pQoHOJQDX0UHeIVLgAt4havc3Fv3abnXQCyIPw3ARfyZX6cxSwDXAVzAK4Jma8o/S1PBgFgAfwqgTi3gFQHUqQW8ImRu7o16yL0undPUxYmECNJZKZVW8XddWe2Mos5opTPFyf8cCwMYWACFbBADA4VsEDPZzN5CcnvrLexjb6FTZJdLpvpf5NhW9usXvzk0177y/TdnGvMP83Pb+mYR8t0P/su3r0++ikYYV9MZ7/cynb95Nf8ZxZn3drkgR9/1c24tk0ZGAxpGownH8TcRQfA1
These two blueprints both fit six cars, but the preview when hovering the station or signal only shows 5 (even when the option is set higher than 5, that's just a coincidence, the bug also appears with other lengths)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13198
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by Rseding91 »

Looking at it my guess is: the position rendering and the actual train positions are 2 different pieces of code and so the preview isn't representative of what actually happens when you put a train on it.

I don't know if one of the other developers wants to go tinker with it more or call it 'good enough' so i'll leave this for them.
If you want to get ahold of me I'm almost always on Discord.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2240
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by boskid »

Not a bug.

You can place 6 rolling stocks and the 6th one does not register as being inside of the adjacent rail segment because of the rail joint placement (they are not at the absolute ends of rolling stock but are 1 unit inside) however the rail segment has length of 41.84 meaning that part of the rolling stock collision box would be outside of that rail segment. Moving last rail joint back by 1 unit leads to different rail block so the 6th spot is not rendered.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by sparr »

I'm not sure why you think this is not a bug. Everything you described about the internal mechanisms doesn't seem to be actually important from a player point of view. Six cars can stop in that block without causing the previous block to turn signals red, and that's what matters to me as someone laying out my rail network. When would these other things matter?

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2240
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by boskid »

Without this check something like this could happen:
89185-no-check.png
89185-no-check.png (147.28 KiB) Viewed 3399 times
I do not want this to happen so the joint is moved 1 unit more to check if the rolling stock will be entirely inside of a single rail block.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by sparr »

The point of this bug report is that the check is faulty. The current implementation of the check reports that a rolling stock will not be entirely inside a rail block when it actually will be. I definitely don't have enough insight into the game code to understand why it's wrong, I can just see in the game that it is wrong.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2240
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by boskid »

No. It is 0.16 of distance outside of current block. End of the rolling stock is at the point A while the block ends at the point B.
89185-detailed.png
89185-detailed.png (196.21 KiB) Viewed 3330 times
If you want to measure the length of the segment yourself, use this command by pointing onto a rail between a train stop and a signal (no junctions or other signals in between as they will split rail segment into multiple smaller ones)

Code: Select all

/c game.print(game.player.selected.get_rail_segment_length())
If it shows you less than 42, train visualisation will not show 6 boxes. On the first blueprint it shows 41.84208 so there will be at most 5 boxes from train visualisation. Second blueprint after adding missing diagonal rail shows 42.6705 so there are 6 boxes from train visualisation.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by sparr »

Thank you for helping explain how the current calculation works.

That does not change the fact that the current calculation does not match the relevant game mechanics.
Screenshot-2020-10-02-231810.png
Screenshot-2020-10-02-231810.png (511.03 KiB) Viewed 3289 times
Notice the green signal. When the train stops in the given position, the block behind it is not occupied according to the signal and routing algorithms, and another train will be able to enter that block. If it's following the stopped train, it will move right up against it, nose to tail. If there's an intersection crossing the cyan segment then trains will drive through it. As far as I can tell, that's the only thing that really matters. I can't find any practical game effect of the calculation you're describing.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2240
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by boskid »

sparr wrote:
Sat Oct 03, 2020 6:20 am
That does not change the fact that the current calculation does not match the relevant game mechanics.
I know, and it is intended to not follow them. You are right that the block behind is not occupied by that train since the last rail joint is within block ahead with a 0.842 of distance to spare. However the last rolling stock box is not rendered because the rolling stock box itself would be outside of the current block.
89185-box-outside-of-block.png
89185-box-outside-of-block.png (147.53 KiB) Viewed 3275 times
In this case train is also able to have all its joints within a single block so following your logic the box should be rendered. However the box itself is clearly outside of current block and is misleading and is not always guaranteed the train will leave the block behind because the rail joint is exactly at the transition so it may not transition to the next rail block yet.

If you want to squeeze every possible bit of rail distance accepting some trains artifacts, you may use the get_rail_segment_length() ruler and if it shows more than 41 (but not 41 exactly), the train should fit entirely inside of that rail segment and release the block behind, however the 6th box will not be rendered until the get_rail_segment_length() gets up to 42.
89185-box-within-block-but-gfx-not.png
89185-box-within-block-but-gfx-not.png (381.71 KiB) Viewed 3275 times

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by sparr »

Why doesn't the internal code use >41 instead of >=42? That's what I still don't understand. What would break or be inaccurate if we did that?

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2240
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by boskid »

sparr wrote:
Sat Oct 03, 2020 6:29 pm
Why doesn't the internal code use >41 instead of >=42? That's what I still don't understand. What would break or be inaccurate if we did that?
Because it would look bad when box would stick out of the block.

User avatar
Therax
Filter Inserter
Filter Inserter
Posts: 470
Joined: Sun May 21, 2017 6:28 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by Therax »

I'm with sparr here. Functionality trumps appearance. If 6 wagons fit in the block without spilling into the next block, there should be 6 frames shown, even if they visually spill past the train signal.

If it's desired that the frames don't spill past the signal for cosmetic reasons, then the logic for occupied blocks should be adjusted to account for the physical wagon size (collision box) rather than using only train joint locations.
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by sparr »

With 2.0 introducing new rail functionality, a lot of us intense rail optimizers are going to be taking a fresh crack at a whole new assortment of layouts. Having to manually check whether trains fit in blocks (instead of relying on the visualization) is going to jump back to the top of my tediousness list.

User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 596
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by Gergely »

What about this case?
Example 1
Visualization shows 4 units
What1.png
What1.png (531.19 KiB) Viewed 823 times
Example 2
Visualization shows 5 units
What2.png
What2.png (560.06 KiB) Viewed 823 times

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2240
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by boskid »

Gergely wrote:
Sun Nov 26, 2023 8:04 pm
What about this case?
I am not seeing anything interesting with this case. Diagonal straight rail has front and back signal positions overlapping and so the signal binding logic is implemented to choose if a signal is binding to the front or to the back. If one of those is not possible (because there is also curved rail nearby forcing a merge of diagonal straight rail and next diagonal straight rail) then it will choose the other position but if both are possible the the signal is binding to the back of diagonal straight rail. When there are 5 spots rendered it is simply signal binding to the back of the diagonal rail causing the rail segment with a train inside to be longer by 1.41 and so there is enough distance to fit 5 spots with the required margin.

User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 596
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by Gergely »

boskid wrote:
Sun Nov 26, 2023 8:10 pm
Gergely wrote:
Sun Nov 26, 2023 8:04 pm
What about this case?
Diagonal straight rail has front and back signal positions overlapping and so the signal binding logic is implemented to choose if a signal is binding to the front or to the back. If one of those is not possible (because there is also curved rail nearby forcing a merge of diagonal straight rail and next diagonal straight rail) then it will choose the other position but if both are possible the the signal is binding to the back of diagonal straight rail. When there are 5 spots rendered it is simply signal binding to the back of the diagonal rail causing the rail segment with a train inside to be longer by 1.41 and so there is enough distance to fit 5 spots with the required margin.
I was about to post a similar problem of there being an inconsistency when I mirror a track.
What3.png
What3.png (422.08 KiB) Viewed 811 times
What4.png
What4.png (340.83 KiB) Viewed 811 times
But yeah, after reading your explanation I came to understand this has to do with the logic having to choose between either end of the diagonal track.
Yeah5.png
Yeah5.png (1.09 MiB) Viewed 811 times
Therefore the blocks are split at different heights.
Yeah6.png
Yeah6.png (1.08 MiB) Viewed 811 times
Actually both stations appear to fit a 5-length train while leaving the neutral block intact. How do I compute the required rail segment length for any train?

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2240
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by boskid »

You can check available length by measuring rail segment length (assuming there are no merges or splits in the middle) using the command mentioned above:

Code: Select all

/c game.print(game.player.selected.get_rail_segment_length())
As for the length a train needs to fit entirely inside of such segment: Lets introduce arriveDistance = 2 (distance between position where train stop binds and front joint of a train), jointDistance = 4 (distance between joints of same rolling stock) and connectionDistance = 3 (distance between 2 rolling stocks that have a connection). After arrival the train will need `arriveDistance + N*jointDistance + (N-1)*connectionDistance` to fit. For example a train with 3 rolling stocks will need a rail segment of at least 20. It is not guaranteed last rail joint will pass the transition if the segment has length of exactly 20 so usually it must be slightly more. Visualisation takes a margin of 1 for this so if a segment has length of 21, there will be 3 boxes rendered. If the segment length is between 20 and 21 the train may fit but the visualisation will no longer draw 3rd spot.

computeraddict
Fast Inserter
Fast Inserter
Posts: 110
Joined: Sat Oct 07, 2023 6:44 am
Contact:

Re: [1.0.0] more trains fit between signals than the preview shows on c

Post by computeraddict »

As I understand it the discrepancy comes from the rail cars being visually longer than the space they take up in a block, and the block visualizer using the visual bounding box instead of the pathfinding bounding box.

Could the visualizer cheat and squish the previewed bounding boxes by a fraction so that it is car-count accurate without overflowing into blocks it isn't supposed to? Or could the visualized boxes just be shrunk to be accurate to their pathfinding joints and the visual overhang of real stock beyond the joint bounding box be ignored? I think ignoring the graphics extending past the joint boundaries like the pathfinding system does is preferable to misrepresenting capacity of blocks by a system that is designed for visualizing the capacity of blocks.

Post Reply

Return to “Not a bug”