Friday Facts #377 - New new rails

Regular reports on Factorio development.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2313
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Friday Facts #377 - New new rails

Post by boskid »

glenjimen wrote:
Wed Jun 05, 2024 5:45 pm
All rail pieces are buildable on a 2x2 grid so it is not possible to have them misaligned by 1 tile.

glenjimen
Manual Inserter
Manual Inserter
Posts: 4
Joined: Wed Jun 05, 2024 1:22 am
Contact:

Re: Friday Facts #377 - New new rails

Post by glenjimen »

So I was playing around with the new rail geometry in AutoCAD and things seemed to be lining up pretty well.
track knot.PNG
track knot.PNG (112.72 KiB) Viewed 948 times
A couple of times I thought I had found issues, but I realized I had made illegal moves, usually straight track sections an odd number of tiles long. If I restricted myself to building only on a 2x2 grid as boskid said, then everything seemed to line up as intended.

Then I stumbled onto this and couldn't find my mistake.
missalinement.PNG
missalinement.PNG (108.8 KiB) Viewed 948 times
The track seemed to be offset by half it's width without a way to make them line up. I had to stare at it a while before I realized I was just looking at overlapping parallel tracks at 30 degrees. The same thing exists at 60 degrees, and at 45 degrees they're right up against each other, not quite overlapping.

Here is the same problem in a more organized manner.
offset overlap.PNG
offset overlap.PNG (84.24 KiB) Viewed 948 times
If you restrict the starting point for 30 & 60 degree rails to a 2x2 grid, then the nearest parallel rails end up overlapping by about 50%. So maybe restrict 30 & 60 degree rails to a 4x4 grid? But then that S-bend of track on the right-hand side can only connect every 3rd parallel track, so maybe a 6x6 grid is better?

Honestly this problem looks pretty close to the original issue you were trying to solve, just rotated 30 degrees.
[Edit : Image was not loading correctly]
fff-377-rail-S.png
fff-377-rail-S.png (293.04 KiB) Viewed 773 times
Two intermediate tracks that the S-Bend cannot connect.

Is my analysis flawed? How does your development build handle this so far? I don't have a good solution in mind, hopefully someone will reply back and point out a boneheaded mistake I made. I really like your new new rail plan so far, and I hope it can be as good as possible on release!

User avatar
Yodo
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Dec 30, 2023 4:27 pm
Contact:

Re: Friday Facts #377 - New new rails

Post by Yodo »

glenjimen wrote:
I'm not quite sure what's happening, but there won't be 30- and 60-degree rails, but 22.5, 45, and 67.5 degrees. You can also use https://mods.factorio.com/mod/fake-new-rails to test layouts, but it will let you build 45-degree rails on a 1x1 grid, instead of the 2x2 that it is supposed to be. I'm not sure if the elevated rails are accurate though. There is no collision simulated in the mod either way.


I was wondering if this quirk will be fixed (click for Reddit post):
Image

The image is old, but I'm pretty sure it still exists in Factorio 1.1. The quirk is that the curved rails, while longer (visually and as measured by train movement), use less materials to build than diagonal rails. I'm not sure if this also happens with orthogonal vs curvy rails, but I think it might.
Have you considered using flow routers instead of balancers?

glenjimen
Manual Inserter
Manual Inserter
Posts: 4
Joined: Wed Jun 05, 2024 1:22 am
Contact:

Re: Friday Facts #377 - New new rails

Post by glenjimen »

Bone headed mistake #1 identified!
@ Yodo You're half right, the angles aren't 30, 45 & 60. But they also aren't 22.5, 45 & 67.5. Revisiting my high school trig (and double checking in AutoCAD) the actual angles are 26.57, 45 & 63.43.
IntermediatAngles.png
IntermediatAngles.png (45.47 KiB) Viewed 667 times
However, the geometry I presented is still correct even though I was saying the wrong angles. And the angled S-Bend problem still exists, as well as the overlapping track problem. Is there something built into these new new rails that prevents this from being an issue?

glenjimen
Manual Inserter
Manual Inserter
Posts: 4
Joined: Wed Jun 05, 2024 1:22 am
Contact:

Re: Friday Facts #377 - New new rails

Post by glenjimen »

Apologies for the double-post.
I'm managed to confuse myself even more! How can the new new rails follow the rule of only being built on a 2x2 grid if the individual puzzle pieces are an odd numbers of tiles tall & wide? Even when building 45 degree rails, you have to first build to 26.5* then to 45*. Assuming you start horizontal at 0*, you first build over 5 tiles & down 1 to 26.5*. Then over 4 & down 3 to 45*. That's a total of over 9 & down 4.
Are the new new rails able to be built on a 1x1 grid? Or is there some other limiting mechanic?
fff-377-curve-v3-dimensions.png
fff-377-curve-v3-dimensions.png (90.38 KiB) Viewed 617 times

For reference, the old curves are an even number of tiles tall & wide.
fff-377-rail-S-dimensions.png
fff-377-rail-S-dimensions.png (295.06 KiB) Viewed 617 times

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

Re: Friday Facts #377 - New new rails

Post by boskid »

glenjimen wrote:
Mon Jul 01, 2024 9:20 pm
How can the new new rails follow the rule of only being built on a 2x2 grid if the individual puzzle pieces are an odd numbers of tiles tall & wide?
There are no contradictions there. Entity being buildable on 2x2 grid means that the entity snaps to positions that repeat every 2 tiles in X and Y direction but that does not restrict if X and Y coordinates are even or odd, up to being an even+odd pair or change depending on the direction of entity being built. Straight rails are buildable on 2x2 grid with X and Y both being odd, 45deg straight is buildable on 2x2 grid with X and Y being even. "22.5" straights are buildable on 2x2 grid where both X and Y are odd. Curve-B shape is buildable on 2x2 grid where X and Y are odd. Curve-A shape is buildable on 2x2 grid where one coordinate is even and one is odd (which one is even depends on the direction of the piece being built). There is also one piece you are missing which is where exactly i decided to locate the rail piece centers.

Below is screenshot with tile grid turned (there are 2 chunk borders visible) and exact entity positions.
p613475.png
p613475.png (559.53 KiB) Viewed 594 times

Nidan
Fast Inserter
Fast Inserter
Posts: 249
Joined: Sat Nov 21, 2015 1:40 am
Contact:

Re: Friday Facts #377 - New new rails

Post by Nidan »

glenjimen wrote:
Fri Jun 14, 2024 5:27 pm
The track seemed to be offset by half it's width without a way to make them line up. I had to stare at it a while before I realized I was just looking at overlapping parallel tracks at 30 degrees. The same thing exists at 60 degrees, and at 45 degrees they're right up against each other, not quite overlapping.
With an additional straight piece before starting the curve from the bottom you can connect the paths.
missalinement_edit.png
missalinement_edit.png (76.34 KiB) Viewed 579 times
Honestly this problem looks pretty close to the original issue you were trying to solve, just rotated 30 degrees.
Two intermediate tracks that the S-Bend cannot connect.

Is my analysis flawed? How does your development build handle this so far? I don't have a good solution in mind, hopefully someone will reply back and point out a boneheaded mistake I made. I really like your new new rail plan so far, and I hope it can be as good as possible on release!
Unless I miscounted, with 2.0 there'll be no intermediate tracks for 45° S-bends, while in 1.1 we have 3 intermediate tracks, so I'd call this an improvement.
offset_current.png
offset_current.png (1011.24 KiB) Viewed 579 times
For 26.6° and 63.3° orientations, it depends on the direction you make the S-bend in. If you transition to 0° or 90° you'll have two intermediate tracks, transitioning to 45° you'll only have a one track gap. But building 26.6° or 63.3° tracks directly adjacent has very limited usefulness as trains will collide; not sure whether a one track gap will work. Thus, limiting yourself to one out of every 2 (or 3) possible tracks saves rails with no throughput lost and should remove the need for most awkward S-bends.
boskid wrote:
Mon Jul 01, 2024 11:48 pm
Curve-A shape is buildable on 2x2 grid where one coordinate is even and one is odd (which one is even depends on the direction of the piece being built).
rail_center_edit.png
rail_center_edit.png (127.51 KiB) Viewed 579 times
This one is Curve-A? Just looking at your picture the position of reference point feels weird, as it's the only one with a dark lab tile to the top right. Combined with the even/odd coordinate depending on direction, wouldn't it make sense to move the reference point one tile to the right? That'd make both coordinates odd for all eight rotations, possibly simplifying the code, and match up with a "mirrored" version of Curve-B. Or is there a technical reason why that can't be done?

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

Re: Friday Facts #377 - New new rails

Post by boskid »

That is Curved-A rail. It can be told by the direction of rail at its ends: Curved-A connects straight with "22.5" when Curved-B connects "22.5" with 45deg.

From code point of view having even+odd causes absolutely no new problems. Game engine is already well prepared to handle this case the same as you can build 2x3 entities (like boilers) with one coordinate being an integer and second coordinate being offset by half - this is exactly the same code path just tile grid for rails is 2x2 while boilers are buildable on 1x1 grid.

All relevant pieces of rails code that need to know where rail ends are, are using a function which sum entity position and offsets from rail connection definitions for given shape+direction so they are unaffected by exact center position of entity. Effectively it does not matter where it is as long it is within collision bounding box and i am not going to change that anymore because it would require a migration.

From build snapping point of view you can consider Curved-A rail to be as if it was 2x4 entity snapping to 2x2 grid: half of 4 is 2, that coordinate will be even and half of 2 is 1, that coordinate will be odd.

Post Reply

Return to “News”