Skip to content

Commit 7d2db2d

Browse files
committed
DLL: disable redundant FlexFly, OST, RHW metarule adjacencies
1 parent c6b7d0c commit 7d2db2d

4 files changed

Lines changed: 24 additions & 96 deletions

File tree

src/main/scala/module/Adjacencies.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ trait Adjacencies { this: RuleGenerator =>
128128
* - OxD | OxD,
129129
* - DxO | DxO,
130130
* - DxD | DxD.
131+
*
132+
* Update for DLL-based adjacencies: This function now only covers *inner*
133+
* adjacencies of multitile networks, i.e. both crossing networks belong to
134+
* the same multitile network.
131135
*/
132136
def createAdjacentIntersections(main: Network, base: Network, minor: Network): Unit = { // minor is the first (left) crossing network
133137
assert(intersectionAllowed(main, minor))
@@ -136,7 +140,7 @@ trait Adjacencies { this: RuleGenerator =>
136140

137141
val seen = collection.mutable.Set.empty[(Network, Int)]
138142

139-
for ((adjacent, dirs) <- adjacentNetworks(minor)) {
143+
for ((adjacent, dirs) <- multitileNetworks.getOrElse(minor, Seq.empty)) {
140144
val (ns1, nw1, ws1) = if (dirs == NSNS || dirs == NSSN) (NS, NW, WS) else (SN, WN, SW)
141145
val (ns2, es2, ne2) = if (dirs == NSNS || dirs == SNNS) (NS, ES, NE) else (SN, SE, EN)
142146

src/main/scala/module/RhwRuleGenerator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class RhwRuleGenerator(var context: RuleTransducer.Context) extends RuleGenerato
143143
}
144144
}
145145
}
146-
// inside multi-tile intersection and adjacent intersections
146+
// inside multi-tile intersection
147147
createAdjacentIntersections(main, base, minor)
148148
createRules()
149149
}

src/main/scala/module/flexfly/FlexFlyRuleGenerator.scala

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ class FlexFlyRuleGenerator(var context: RuleTransducer.Context) extends RuleGene
8181
Rules += main~orient(T6) * R3F0 & minor~WE~EW | main~orient(NW) & (base ~> minor)~WE~EW // stability
8282
Rules += main~orient(T6) * R3F0 | main~orient(NW) & minor~WE~EW | main~orient(T6) * R3F0 & minor~WE~EW | % // T6 < OxD
8383

84-
// Now we consider cases involving two adjacent crossing networks
85-
for ((other, directions) <- adjacentNetworks(minor)
84+
// Now we consider cases involving two adjacent crossing networks.
85+
// Due to DLL-based adjacencies, we only need to consider the *inner* adjacencies of multitile networks, if any.
86+
for ((other, directions) <- Adjacencies.multitileNetworks.getOrElse(minor, Seq.empty)
8687
if other.isRhw && other != Dirtroad && other.height == minor.height && !deactivated(other)) {
8788
val (minDir, otherDir) = directions match {
8889
case NSNS => (NS, NS)
@@ -113,20 +114,21 @@ class FlexFlyRuleGenerator(var context: RuleTransducer.Context) extends RuleGene
113114

114115
// crossing of a third network with two adjacent FlexFlys
115116
// (These are not strictly needed if starters are used, so we try to cut down the large number of adjacencies to a useful subset)
116-
for {
117-
third <- RhwNetworks
118-
if third.height != main.height && third.height != minor.height && !deactivated(third)
119-
if third.height <= 2 && orient == o2 && orient == orientations(0) // limits adjacencies to inside curves
120-
base <- third.base
121-
dir <- directionsWithShoulderNorth(third)
122-
} /*do*/ {
123-
Rules += minor~o2(T3) * R0F1 & third~dir | main~orient(T3) * R0F0 | % | main~orient(T3) * R0F0 & third~dir // 4-tile gap
124-
Rules += minor~o2(T3) * R3F0 & third~dir | main~orient(T3) * R3F1 | % | main~orient(T3) * R3F1 & third~dir // 2-tile gap
125-
Rules += minor~o2(T1) * R3F0 & third~dir | main~orient(T1) * R3F1 | % | main~orient(T1) * R3F1 & third~dir // 0-tile gap
126-
Rules += minor~o2(T3) * R0F1 | main~orient(T3) * R0F0 & third~dir | minor~o2(T3) * R0F1 & third~dir | % // 4-tile gap
127-
Rules += minor~o2(T3) * R3F0 | main~orient(T3) * R3F1 & third~dir | minor~o2(T3) * R3F0 & third~dir | % // 2-tile gap
128-
Rules += minor~o2(T1) * R3F0 | main~orient(T1) * R3F1 & third~dir | minor~o2(T1) * R3F0 & third~dir | % // 0-tile gap
129-
}
117+
// (disabled, as these are redundant with DLL-based adjacencies)
118+
// for {
119+
// third <- RhwNetworks
120+
// if third.height != main.height && third.height != minor.height && !deactivated(third)
121+
// if third.height <= 2 && orient == o2 && orient == orientations(0) // limits adjacencies to inside curves
122+
// base <- third.base
123+
// dir <- directionsWithShoulderNorth(third)
124+
// } /*do*/ {
125+
// Rules += minor~o2(T3) * R0F1 & third~dir | main~orient(T3) * R0F0 | % | main~orient(T3) * R0F0 & third~dir // 4-tile gap
126+
// Rules += minor~o2(T3) * R3F0 & third~dir | main~orient(T3) * R3F1 | % | main~orient(T3) * R3F1 & third~dir // 2-tile gap
127+
// Rules += minor~o2(T1) * R3F0 & third~dir | main~orient(T1) * R3F1 | % | main~orient(T1) * R3F1 & third~dir // 0-tile gap
128+
// Rules += minor~o2(T3) * R0F1 | main~orient(T3) * R0F0 & third~dir | minor~o2(T3) * R0F1 & third~dir | % // 4-tile gap
129+
// Rules += minor~o2(T3) * R3F0 | main~orient(T3) * R3F1 & third~dir | minor~o2(T3) * R3F0 & third~dir | % // 2-tile gap
130+
// Rules += minor~o2(T1) * R3F0 | main~orient(T1) * R3F1 & third~dir | minor~o2(T1) * R3F0 & third~dir | % // 0-tile gap
131+
// }
130132
}
131133
createRules()
132134
}

src/main/scala/module/onslope.scala

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -29,84 +29,6 @@ trait Onslope { this: RuleGenerator with Curve45Generator =>
2929
Rules += onslope | (Dirtroad ~> upper)~EW // OST > upper
3030
Rules += rhw2Slope | upper~EW | onslope | % // OST < upper
3131
Rules += (Dirtroad ~> lower)~EW | onslope // lower < OST
32-
Rules += onslope | (Dirtroad ~> upper)~CW // OST > upper stub
33-
Rules += (Dirtroad ~> lower)~EC | onslope // lower stub < OST
34-
35-
// adjacencies
36-
for (minor <- (RhwNetworks - Rhw10c - L1Rhw10c - L2Rhw10c) ++ (BaseNetworks - Subway) ++ NwmNetworks ++ GlrNetworks + Str + Hsr + L2Hsr) { // crossing network
37-
if (intersectionAllowed(upper, minor)) {
38-
if (hasRightShoulder(minor)) {
39-
Rules += onslope | (Dirtroad ~> upper)~EW & minor~NS // OST > upper crossing minor
40-
Rules += rhw2Slope | upper~EW & minor~NS | onslope | % // OST < upper crossing minor
41-
}
42-
if (hasLeftShoulder(minor)) {
43-
Rules += onslope | (Dirtroad ~> upper)~EW & minor~SN // OST > upper crossing minor
44-
Rules += rhw2Slope | upper~EW & minor~SN | onslope | % // OST < upper crossing minor
45-
}
46-
}
47-
if (intersectionAllowed(lower, minor)) {
48-
if (hasRightShoulder(minor)) {
49-
Rules += (Dirtroad ~> lower)~EW & minor~SN | onslope // lower crossing minor < OST
50-
Rules += lower~EW & minor~SN | rhw2Slope | % | onslope // lower crossing minor > OST
51-
}
52-
if (hasLeftShoulder(minor)) {
53-
Rules += (Dirtroad ~> lower)~EW & minor~NS | onslope // lower crossing minor < OST
54-
Rules += lower~EW & minor~NS | rhw2Slope | % | onslope // lower crossing minor > OST
55-
}
56-
}
57-
}
58-
59-
// OST adjacent to 45 degree curves
60-
if (isSingleTile(main)) { // curves adjacent to OSTs only seem useful for tight setups with single-tilers
61-
if (hasSharpCurveBase(upper, inside=false) && hasSharpCurve(upper, inside=false)) {
62-
Rules += onslope | (Dirtroad ~> upper)~(+2,0,-13,0) // OST > R0 upper
63-
Rules += rhw2Slope | upper~(+2,0,-13,0) | onslope | % // OST < R0 upper
64-
Rules += lower~(+11,0,-2,0) | rhw2Slope | % | onslope // R0 lower > OST
65-
Rules += (Dirtroad ~> lower)~(+11,0,-2,0) | onslope // R0 lower < OST
66-
}
67-
if (hasSharpCurveBase(upper, inside=true) && hasSharpCurve(upper, inside=true)) {
68-
Rules += onslope | (Dirtroad ~> upper)~(+2,0,-11,0) // OST > R0 upper
69-
Rules += rhw2Slope | upper~(+2,0,-11,0) | onslope | % // OST < R0 upper
70-
Rules += lower~(+13,0,-2,0) | rhw2Slope | % | onslope // R0 lower > OST
71-
Rules += (Dirtroad ~> lower)~(+13,0,-2,0) | onslope // R0 lower < OST
72-
}
73-
if (hasR1CurveBase(upper) && hasR1Curve(upper, inside=false)) {
74-
Rules += onslope | (Dirtroad ~> upper)~(+2,0,-123,0) // OST > R1 upper
75-
Rules += rhw2Slope | upper~(+2,0,-123,0) | onslope | % // OST < R1 upper
76-
}
77-
if (hasR1CurveBase(lower) && hasR1Curve(lower, inside=false)) {
78-
Rules += lower~(+121,0,-2,0) | rhw2Slope | % | onslope // R1 lower > OST
79-
Rules += (Dirtroad ~> lower)~(+121,0,-2,0) | onslope // R1 lower < OST
80-
}
81-
if (hasR1CurveBase(upper) && hasR1Curve(upper, inside=true)) {
82-
Rules += onslope | (Dirtroad ~> upper)~(+2,0,-121,0) // OST > R1 upper
83-
Rules += rhw2Slope | upper~(+2,0,-121,0) | onslope | % // OST < R1 upper
84-
}
85-
if (hasR1CurveBase(lower) && hasR1Curve(lower, inside=true)) {
86-
Rules += lower~(+123,0,-2,0) | rhw2Slope | % | onslope // R1 lower > OST
87-
Rules += (Dirtroad ~> lower)~(+123,0,-2,0) | onslope // R1 lower < OST
88-
}
89-
}
90-
if (main == Mis || main == Rhw4) { // FlexFly curves
91-
Rules += rhw2Slope | upper~(+2,0,-213,0) | onslope | % // OST < FlexFly upper
92-
Rules += rhw2Slope | upper~(+2,0,-211,0) | onslope | % //
93-
Rules += lower~(+211,0,-2,0) | rhw2Slope | % | onslope // FlexFly lower > OST
94-
Rules += lower~(+213,0,-2,0) | rhw2Slope | % | onslope //
95-
}
96-
97-
// OST adjacent to OST
98-
if (upper.height <= maxHeight - 1) {
99-
// +L1
100-
val onslopeUpL1 = (height+levelDiff+1)~main~EC & upper~CW
101-
Rules += onslope | rhw2SlopeL1 | % | onslopeUpL1 // lower > upper
102-
Rules += rhw2Slope | onslopeUpL1 | onslope | % // lower < upper
103-
}
104-
if (upper.height <= maxHeight - 2) {
105-
// +L2
106-
val onslopeUpL2 = (height+levelDiff+2)~main~EC & upper~CW
107-
Rules += onslope | rhw2SlopeL2 | % | onslopeUpL2 // lower > upper
108-
Rules += rhw2Slope | onslopeUpL2 | onslope | % // lower < upper
109-
}
11032
}
11133
}
11234

0 commit comments

Comments
 (0)