-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathSamRuleGenerator.scala
More file actions
838 lines (729 loc) · 41.3 KB
/
SamRuleGenerator.scala
File metadata and controls
838 lines (729 loc) · 41.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
package com.sc4nam.module
import io.github.memo33.metarules.meta._
import syntax._, Network._, Flags._, Flag._, RotFlip._, Implicits._, group.SymGroup._
import NetworkProperties._
class SamRuleGenerator(var context: RuleTransducer.Context) extends RuleGenerator with Adjacencies with Stability {
private def reflections(rule: Rule[SymTile]): Seq[Rule[SymTile]] = {
Seq(
Rule(rule(2), rule(1), rule(2), rule(3)),
Rule(rule(3) * R2F0, rule(0) * R2F0, rule(3) * R2F0, rule(2) * R2F0)
)
}
private def createSamLarge45Curve(sam: Network): Unit = {
// large 45 curve (4x3)
// * (diag)
// * ,---------,---------,---------,---------,
// * | | | | |
// * | | 0 | 1 | 2 |
// * | | | | |
// * ;---------;---------;---------;---------;
// * | | | | |
// * ortho | 3 | 4 | 5 | |
// * | | | | |
// * '---------'---------'---------'---------'
// * ,---------,---------,---------,---------,
// * | | | | 3 |
// * | | 14| 1|1 |
// * | | 15 | 113 | |
// * ;---------;---------;---------;---------;
// * | | | 113 | |
// * ortho |2 111|111 11|11 | |
// * | | | | |
// * '---------'---------'---------'---------'
/*
The following code for the large 45 curve is organized like so:
First, the overide from the orthogonal side to the diagonal side is described, ordered left to right.
Then, the the diagonal to orthogonal direction follows, ordered from right to left.
To to and from tiles are annotated in-line. The necessary stability rules that apply to
that from and to tile combo (or its destabilized equivalent) follow indented thereafter.
*/
// ortho to diagonal (bottom row)
Rules += sam~WE | (Street ~> sam)~(2,0,111,0) // ortho to 3
Rules += sam~(2,0,111,0) | (Street ~> sam)~(111,0,11,0) // 3 to 4
Rules += sam~(2,0,111,0) | Street~(2,0,11,0) | % | sam~(111,0,11,0)
Rules += sam~(111,0,11,0) | (Street ~> sam)~(11,113,0,0) // 4 to 5
Rules += sam~(111,0,11,0) | sam~(11,3,0,0) | % | sam~(11,113,0,0)
Rules += sam~(111,0,11,0) | Street~(11,3,0,0) | % | sam~(11,113,0,0)
Rules += sam~(111,0,11,0) | Street~(1,3,0,0) | % | sam~(11,113,0,0)
// ortho to diagonal (bottom to top)
Rules += sam~(0,111,0,11) | (Street ~> sam)~(15,0,0,14) // 4 to 0
Rules ++= stabilize(sam~(0,2,0,11) | Street~(0,0,0,0) | sam~(0,111,0,11) | sam~(15,0,0,14))
Rules ++= stabilize(sam~(0,2,0,11) | Street~(15,0,0,14) | sam~(0,111,0,11) | sam~(15,0,0,14))
Rules += sam~(0,11,113,0) | (Street ~> sam)~(113,0,0,1) // 5 to 1
Rules += sam~(0,11,113,0) | Street~(3,0,0,1) | % | sam~(113,0,0,1)
// ortho to diagonal (top row)
Rules += sam~(0,0,14,15) | (Street ~> sam)~(0,0,1,113) // 0 to 1
Rules += sam~(0,0,14,15) | sam~(0,0,1,3) | % | sam~(0,0,1,113)
Rules += sam~(0,0,1,113) | (Street ~> sam)~(1,3,0,0) // 1 to 2
// diagonal to ortho (top row)
Rules += sam~(0,0,1,3) | (Street ~> sam)~(1,113,0,0) // 2 to 1
Rules += sam~(1,113,0,0) | (Street ~> sam)~(14,15,0,0) // 1 to 0
// diagonal to ortho (top to bottom)
Rules += sam~(0,1,113,0) | (Street ~> sam)~(113,0,0,11) // 1 to 5
Rules += sam~(0,1,113,0) | Street~(3,0,0,11) | % | sam~(113,0,0,11)
Rules += sam~(0,14,15,0) | (Street ~> sam)~(0,11,0,111) // 0 to 4
// diagonal to ortho (bottom row)
Rules += sam~(0,0,11,113) | (Street ~> sam)~(11,0,111,0) // 5 to 4
Rules += sam~(0,0,11,113) | Street~(11,0,2,0) | % | sam~(11,0,111,0)
Rules += sam~(0,0,11,113) | Street~(2,0,2,0) | % | sam~(11,0,111,0)
Rules += sam~(11,0,111,0) | (Street ~> sam)~(111,0,2,0) // 4 to 3
Rules += sam~(11,0,111,0) | sam~(WE) | % | sam~(111,0,2,0)
Rules += sam~(11,0,111,0) | Street~(WE) | % | sam~(111,0,2,0)
Rules += sam~(11,0,111,0) | Street~(11,0,2,0) | % | sam~(111,0,2,0)
Rules += sam~(111,0,2,0) | (Street ~> sam)~WE // 3 to ortho
// -------------
createRules()
}
private def createSam2x290Curve(sam: Network): Unit = {
// *
// * 2x2 90 Curve and optional diverter tiles
// * SAM diverter
// * ,---------,---------,---------, ,---------,
// * | | | | | 131 |
// * |2 2|2 133|133 | <-- -- --> |133 133|
// * | | | 131 | or | 131 |
// * ;---------;---------;---------; '---------'
// * | | 141 | 131 | ^
// * | | 143| | or |
// * | | | 2 | v
// * ;---------;---------;---------; ,---------, ,---------,
// * | | | 2 | | | | 131 |
// * | | | | |133 | + | 133|
// * | | | 2 | | 131 | | |
// * '---------'---------'---------' '---------' '---------'
// * SAM Street or Road
// * 2x2 90 Curve w/ optional t-int
// * ,---------,---------,---------,
// * | | 2 | |
// * | | | |
// * | | 2 | |
// * ;---------;---------;---------;
// * | | 2 | |
// * |2 2|2 133|133 | (diverter not possible w/ optional t-int)
// * | | | 131 |
// * ;---------;---------;---------;
// * | | 141 | 131 |
// * | | 143| |
// * | | | 2 |
// * ;---------;---------;---------;
// * | | | 2 |
// * | | | |
// * | | | 2 |
// * '---------'---------'---------'
// basic override
Rules += sam~WE | (Street ~> sam)~(2,0,133,0)
Rules += sam~(2,0,133,0) | (Street ~> sam)~(133,0,0,131)
Rules += sam~(0,0,131,133) | (Street ~> sam)~(131,0,2,0)
Rules += sam~(0,133,0,2) | (Street ~> sam)~(141,143,0,0)
// t-int variant
Rules += sam~WE | (Street ~> sam)~(2,2,133,0)
Rules += sam~(2,2,133,0) | (Street ~> sam)~(133,0,0,131)
Rules += sam~(0,0,131,133) | (Street ~> sam)~(131,2,2,0)
Rules += sam~(2,133,0,2) | (Street ~> sam)~(141,143,0,0)
// diverter overrides with continuances
Rules += sam~(2,0,133,0) | (Street ~> sam)~(133,0,0,131) & Street~(0,131,133,0) // half SAM, half street
Rules += sam~(0,0,131,133) & Street~(131,133,0,0) | (Street ~> sam)~(131,0,2,0)
Rules += sam~(2,0,133,0) | Street~(133,0,0,131) & sam~(0,131,133,0) | % | sam~(133,131,133,131) // full SAM
Rules += sam~(131,133,131,133) | (Street ~> sam)~(131,0,2,0)
Rules += sam~(2,0,133,0) | (Street ~> sam)~(133,0,0,131) & Road~(0,131,133,0) // half SAM, half road
Rules += sam~(0,0,131,133) & Road~(131,133,0,0) | (Street ~> sam)~(131,0,2,0)
// compensate for instability of street x road diverter
Rules += sam~(0,0,131,133) & Road~(131,133,0,0) | Street~WE & Street~CS | % | sam~(131,0,2,0)
Rules += sam~(0,0,131,133) & Road~(131,133,0,0) | sam~WE | % | sam~(131,0,2,0)
Rules += sam~(2,0,131,0) | sam~(2,2,0,0) & Road~(0,0,2,2) | % | sam~(131,133,0,0) & Road~(0,0,131,133)
Rules += sam~(0,2,0,131) | Street~WC | % | sam~(143,0,0,141)
// create continuation rules for the three exit points (curve end, curve end w/ t-int, t-int)
for (t <- Seq((131,0,2,0), (131,2,2,0), (0,131,2,2))) {
Rules += sam~t | (Street ~> sam)~WE
}
createRules()
}
private def createSamSCurve(sam: Network): Unit = {
//
// * SAM S-Curve (3x2)
// *
// * ,---------,
// * | 2 |
// * |2 153| optional t-int
// * | |
// * '---------'
// * ^
// * | or
// * v
// * ,---------,---------,---------,---------,---------,
// * | | | | | |
// * |2 2|2 153|153 |173 | |
// * | | | 161 | 181 | |
// * ;---------;---------;---------;---------;---------;
// * | | 181 | 161 | | |
// * | | 173| 153|153 2|2 2|
// * | | | | | |
// * '---------'---------'---------'---------'---------'
// *
// *
// basic override
// left to right top row
Rules += sam~WE | (Street ~> sam)~(2,0,153,0)
Rules += sam~(2,0,153,0) | (Street ~> sam)~(153,0,0,161)
Rules += sam~(153,0,0,161) | (Street ~> sam)~(173,0,0,181)
// top to bottom
Rules += sam~(0,153,0,2) | (Street ~> sam)~(181,173,0,0)
Rules += sam~(0,0,161,153) | (Street ~> sam)~(161,153,0,0)
Rules += sam~(0,0,181,173) | (Street ~> sam)~(0,2,0,153)
// left to right bottom row
Rules += sam~(0,181,173,0) | (Street ~> sam)~(0,161,153,0)
Rules += sam~(0,161,153,0) | (Street ~> sam)~(153,0,2,0)
// t-int variant
// left to right top row
Rules += sam~WE | (Street ~> sam)~(2,2,153,0)
Rules += sam~(2,2,153,0) | (Street ~> sam)~(153,0,0,161)
// top to bottom
Rules += sam~(2,153,0,2) | (Street ~> sam)~(181,173,0,0)
Rules += sam~(0,0,181,173) | (Street ~> sam)~(0,2,2,153)
// left to right bottom row
Rules += sam~(0,161,153,0) | (Street ~> sam)~(153,0,2,2)
// create adjacency rules for the three exit points (curve end, curve end w/ t-int, t-int)
for (t <- Seq((153,0,2,0), (153,0,2,2), (0,2,2,153))) {
Rules += sam~t | (Street ~> sam)~WE
}
}
private def createSamLarge90Curve(sam: Network): Unit = {
// *
// * (A) (B)
// * ,---------,---------,
// * | 2 | 2 | (optional t-ints)
// * |2 183|183 193|
// * | | 13 | * cannot be drawn side-by-side *
// * '---------'---------'
// * ^ ^
// * or | / | or
// * v v
// * ,---------,---------,---------,---------,---------,
// * | | | | | |
// * 0 |2 2|2 183|183 193|193 | |
// * | | | 13 | 194 | |
// * ;---------;---------;---------;---------;---------;
// * | | | 13 | | |
// * 1 | | | 82|82 |194 |
// * | | | | 82 | 191 |
// * '---------;---------;---------;---------;---------;
// * | | 82 | 191 |
// * 2 | | 11|11 (2)| <--.
// * | | | 181 | |
// * '---------;---------;---------; |-- optional t-ints
// * | | 181 | |
// * 3 | | (2)| <--'
// * | | 2 |
// * ;---------;---------;
// * | | 2 |
// * 4 | | |
// * | | 2 |
// * '---------'---------'
// *
// * 0 1 2 3 4
// basic override
// row 0 (left to right)
Rules += sam~WE | (Street ~> sam)~(2,0,183,0)
Rules += sam~(2,0,183,0) | (Street ~> sam)~(183,0,193,13)
Rules += sam~(183,0,193,13) | (Street ~> sam)~(193,0,0,194)
// row 0 (right to left)
Rules += sam~(0,194,193,0) | (Street ~> sam)~(193,13,183,0)
Rules += sam~(193,13,183,0) | (Street ~> sam)~(183,0,2,0)
// row 1 (left to right)
Rules += sam~(0,13,82,0) | (Street ~> sam)~(82,0,0,82)
Rules += sam~(82,0,0,82) | (Street ~> sam)~(194,0,0,191)
// row 1 (right to left)
Rules += sam~(0,191,194,0) | (Street ~> sam)~(0,82,82,0)
Rules += sam~(0,82,82,0) | (Street ~> sam)~(82,0,0,13)
// row 2 (left to right)
Rules += sam~(0,82,11,0) | (Street ~> sam)~(11,191,0,181)
// row 2 (right to left)
Rules += sam~(0,181,11,191) | (Street ~> sam)~(11,0,0,82)
// col 2 (top to bottom)
Rules += sam~(0,193,13,183) | (Street ~> sam)~(13,82,0,0)
// col 2 (bottom to top)
Rules += sam~(0,0,13,82) | (Street ~> sam)~(13,183,0,193)
// col 3 (top to bottom)
Rules += sam~(0,0,194,193) | (Street ~> sam)~(0,0,82,82)
Rules += sam~(0,0,82,82) | (Street ~> sam)~(82,11,0,0)
// col 3 (bottom to top)
Rules += sam~(0,0,82,11) | (Street ~> sam)~(82,82,0,0)
Rules += sam~(82,82,0,0) | (Street ~> sam)~(194,193,0,0)
// col 4 (top to bottom)
Rules += sam~(0,0,191,194) | (Street ~> sam)~(191,0,181,11)
Rules += sam~(191,0,181,11) | (Street ~> sam)~(181,0,2,0)
// col 4 (bottom to top)
Rules += sam~WE | (Street ~> sam)~(2,0,181,2)
Rules += sam~(2,0,181,0) | (Street ~> sam)~(181,11,191,0)
Rules += sam~(181,11,191,0) | (Street ~> sam)~(191,194,0,0)
// optional t-int type A
// row 0 (left to right)
Rules += sam~WE | (Street ~> sam)~(2,2,183,0)
Rules += sam~(2,2,183,0) | (Street ~> sam)~(183,0,193,13)
// row 0 (right to left)
Rules += sam~(193,13,183,0) | (Street ~> sam)~(183,0,2,2)
// col 4 (top to bottom)
Rules += sam~(191,0,181,11) | (Street ~> sam)~(181,2,2,0)
// col 4 (bottom to top)
Rules += sam~WE | (Street ~> sam)~(2,0,181,2)
Rules += sam~(2,0,181,2) | (Street ~> sam)~(181,11,191,0)
// optional t-int type B
// row 0 (left to right)
Rules += sam~(2,0,183,0) | (Street ~> sam)~(183,2,193,13)
Rules += sam~(183,2,193,13) | (Street ~> sam)~(193,0,0,194)
// row 0 (right to left)
Rules += sam~(0,194,193,0) | (Street ~> sam)~(193,13,183,2)
Rules += sam~(193,13,183,2) | (Street ~> sam)~(183,0,2,0)
// col 2 (top to bottom)
Rules += sam~(2,193,13,183) | (Street ~> sam)~(13,82,0,0)
// col 2 (bottom to top)
Rules += sam~(0,0,13,82) | (Street ~> sam)~(13,183,2,193)
// col 4 (top to bottom)
Rules += sam~(0,0,191,194) | (Street ~> sam)~(191,2,181,11)
Rules += sam~(191,2,181,11) | (Street ~> sam)~(181,0,2,0)
// col 4 (bottom to top)
Rules += sam~(2,0,181,0) | (Street ~> sam)~(181,11,191,2)
Rules += sam~(181,11,191,2) | (Street ~> sam)~(191,194,0,0)
/* create continuation rules for the four exit points
- curve end
- curve end w/ t-int type A
- t-int type A
- t-int type B
*/
for (t <- Seq((181,0,2,0), (181,2,2,0), (0,181,2,2), (11,191,2,181))) {
Rules += sam~t | (Street ~> sam)~WE
}
createRules()
}
private def createSamDiagSCurve(sam: Network): Unit = {
// *
// * diag tile
// * |
// * v
// * ,---------,---------,
// * | 1 | |
// * 0 | 3|3 |
// * | | 152 |
// * '---------;---------;---------,
// * | 152 | |
// * 1 | 154|154 |
// * | 1 | 1 |
// * ;---------;---------;
// * | 1 | 1 |
// * 2 | 154|154 |
// * | | 152 |
// * '---------;---------;---------,
// * | 152 | |
// * 3 | 3|3 | <- diag tile
// * | | 1 |
// * '---------'---------'
// *
// * 0 1 2 3
// *
Rules ++= reflections((Street ~> sam)~NE | (Street ~> sam)~(3,0,0,152))
Rules ++= reflections((Street ~> sam)~(0,0,152,3) | (Street ~> sam)~(152,154,1,0))
Rules ++= reflections((Street ~> sam)~(0,152,154,1) | (Street ~> sam)~(154,0,0,1))
Rules ++= reflections((Street ~> sam)~(152,154,1,0) | (Street ~> sam)~(1,154,0,0))
createRules()
}
private def createSamRoundabout(sam: Network): Unit = {
val connectionSegments: Seq[Segment] = Seq(
sam~NC,
Road~NC,
Onewayroad~NC
)
// base roundabout tiles (no connections)
val samBase = sam~(0,0,102,102)
val streetBase = Street~(0,0,102,102)
// SAM entry & exit rules
Rules ++= reflections((Street ~> sam)~WE | (Street ~> sam)~(0,0,102,102) & (Street ~> sam)~WC) // from & to orth
// Rules ++= reflections((Street ~> sam)~(0,1,13,0) | (Street ~> sam)~(13,0,102,102)) // from & to diag
// base tile to base tile
Rules += samBase | streetBase * R1F0 | % | samBase * R1F0
for (cSeg1 <- connectionSegments) {
// substitutions in case connection is SAM and tile must be pure street
val cSeg1From = if (cSeg1.network.base.exists(_ == Street)) Segment(Street, cSeg1.flags) else cSeg1
// base tile to connection tile
Rules += samBase | (streetBase & cSeg1From) * R0F1 | % | (samBase & cSeg1) * R0F1
Rules += samBase | (streetBase & cSeg1From) * R1F0 | % | (samBase & cSeg1) * R1F0
// connection tile to base tile
Rules += (samBase & cSeg1) | (streetBase * R0F1) | % | samBase * R0F1
Rules += (samBase & cSeg1) * R1F1 | (streetBase * R0F1) | % | samBase * R0F1
// connection tile to other connection tiles
for (cSeg2 <- connectionSegments) {
val cSeg2From = if (cSeg2.network.base.exists(_ == Street)) Segment(Street, cSeg2.flags) else cSeg2
Rules += (samBase & cSeg1) | (streetBase & cSeg2From) * R0F1 | % | (samBase & cSeg2) * R0F1
Rules += (samBase & cSeg1) * R1F1 | (streetBase & cSeg2From) * R0F1 | % | (samBase & cSeg2) * R0F1
Rules += (samBase & cSeg1) | (streetBase & cSeg2From) * R1F0 | % | (samBase & cSeg2) * R1F0
Rules += (samBase & cSeg1) * R1F1 | (streetBase & cSeg2From) * R1F0 | % | (samBase & cSeg2) * R1F0
}
}
createRules()
}
private def createSamTransitions(sam: Network): Unit = {
// convert base transition to SAM x Street transition
Rules += sam~WE | IdTile(0x5e5c0080, R0F0, (Road~(2,0,2,0)).symmetries) | % | sam~WC & Street~CE
// convert other SAM x Street transitions to SAM x SAM transitions
for (otherSam <- SamNetworks if otherSam != sam) {
Rules += sam~WE | (Street ~> sam)~WC & otherSam~CE
}
}
def start(): Unit = {
val SamNetworks = List(Sam1, Sam2, Sam3, Sam4, Sam5, Sam6, Sam7, Sam8, Sam9, Sam10, Sam11)
val CrossNetworks = List(
Road, Avenue, Onewayroad,
Rail, L1Dtr, L2Dtr, Lightrail, Monorail, Glr1, Glr2, Str,
Dirtroad/*, Rhw3, Mis, Rhw4, Rhw6s, Rhw8sm, Rhw8s, Rhw10s, Rhw12s, Rhw6cm, Rhw6c, Rhw8c,
L1Rhw2, L1Rhw3, L1Mis, L1Rhw4, L1Rhw6s, L1Rhw8sm, L1Rhw8s, L1Rhw10s, L1Rhw12s, L1Rhw6cm, L1Rhw6c, L1Rhw8c,
L2Rhw2, L2Rhw3, L2Mis, L2Rhw4, L2Rhw6s, L2Rhw8sm, L2Rhw8s, L2Rhw10s, L2Rhw12s, L2Rhw6cm, L2Rhw6c, L2Rhw8c,
L3Mis, L3Rhw4, L3Rhw6s, L4Mis, L4Rhw4, L4Rhw6s*/,
Tla3, Ave2, Ard3, Owr1, Owr3, Nrd4,
Tla5, Owr4, Owr5, Rd4, Rd6,
Ave6, Tla7m, Ave6m,
)
// rules which apply to all SAMs, including SAM-1
for (sam <- SamNetworks) {
// base ortho & stubs
Rules += sam~WE | (Street ~> sam)~WE // ortho
Rules += sam~WE | (Street ~> sam)~CW // ortho stub
// sharp 90
Rules += sam~WE | (Street ~> sam)~(2,2,0,0) // ortho to sharp 90
Rules += sam~(0,0,2,2) | (Street ~> sam)~WE // sharp 90 to ortho
// OxO
Rules += sam~WE | (Street ~> sam)~WE & (Street ~> sam)~NS // OxO from orth
Rules += sam~WE & sam~NS | (Street ~> sam)~WE // OxO continue
// OxO T
Rules += sam~WE | (Street ~> sam)~WE & (Street ~> sam)~NC // OxO T Thru-Side from orth
Rules += sam~WE & sam~NC | (Street ~> sam)~WE // OxO T Thru-Side continue
Rules += sam~WE | (Street ~> sam)~WC & (Street ~> sam)~NS // OxO T End-Side from orth
Rules += sam~CE & sam~NS | (Street ~> sam)~WE // OxO T End-Side continue
// SAM x SAM transitions
createSamTransitions(sam)
}
// rules which apply only to SAM-2+
for (sam <- SamNetworks if sam > Sam1) {
// base ortho & stubs
// (defined above for all SAMs)
// base diagonal & stubs
Rules += sam~SE | (Street ~> sam)~WN // diagonal
Rules += sam~SE | (Street ~> sam)~CNW // diagonal stub
// sharp 90
// (defined above for all SAMs)
// sharp diagonal 90 degree curve
Rules += sam~ES | (Street ~> sam)~WS
// orth-diag
Rules += sam~WE | (Street ~> sam)~(2,0,11,0) // from orth to bottom
Rules += sam~(2,0,11,0) | (Street ~> sam)~(11,3,0,0) // bottom to top
Rules += sam~(0,11,3,0) | (Street ~> sam)~WS // top to diag
Rules += sam~ES | (Street ~> sam)~(1,13,0,0) // from diag to top
Rules += sam~(0,1,13,0) | (Street ~> sam)~(13,0,2,0) // top to bottom
Rules += sam~(13,0,2,0) | (Street ~> sam)~WE // to orth
// orth-diag mini diagonal s-curve aka 'S' bend
Rules ++= reflections((Street ~> sam)~(0,0,11,3) | (Street ~> sam)~(11,0,11,0))
Rules ++= reflections((Street ~> sam)~(0,0,11,13) | (Street ~> sam)~(11,0,11,0))
// orth-diag kinked bend
Rules ++= reflections((Street ~> sam)~WE | (Street ~> sam)~(2,0,0,11))
Rules ++= reflections((Street ~> sam)~(0,1,13,0) | (Street ~> sam)~(13,0,0,2))
Rules ++= reflections((Street ~> sam)~(0,11,13,0) | (Street ~> sam)~(13,0,0,2))
// orth-diag sharp cutback
Rules ++= reflections((Street ~> sam)~WE | (Street ~> sam)~(2,11,0,0))
Rules ++= reflections((Street ~> sam)~(0,0,11,3) | (Street ~> sam)~(11,0,0,2))
// diagonal 90 degree curve blend tile
Rules ++= reflections((Street ~> sam)~(0,0,11,3) | (Street ~> sam)~(11,0,13,0))
// smoother 3x3 circle support
Rules ++= reflections((Street ~> sam)~(11,2,13,0) | (Street ~> sam)~(13,0,0,11))
Rules ++= reflections((Street ~> sam)~(11,0,13,0) | (Street ~> sam)~(13,0,0,11))
Rules ++= reflections((Street ~> sam)~(2,2,13,0) | (Street ~> sam)~(13,0,0,11))
Rules ++= reflections((Street ~> sam)~(2,0,13,0) | (Street ~> sam)~(13,0,0,11))
// complex curves
createSamLarge45Curve(sam)
createSam2x290Curve(sam)
createSamSCurve(sam)
createSamLarge90Curve(sam)
createSamDiagSCurve(sam)
// roundabouts
createSamRoundabout(sam)
// standard self-intersections
// OxO
// (defined above for all SAMs)
// OxO T
// (defined above for all SAMs)
// OxD & DxO
Rules += sam~WE | (Street ~> sam)~WE & (Street ~> sam)~ES // OxD from orth
Rules += sam~WE & sam~NW | (Street ~> sam)~WE // OxD orth continue
Rules += sam~ES | (Street ~> sam)~NW & (Street ~> sam)~NS // DxO from diag
Rules += sam~ES & sam~NS | (Street ~> sam)~NW // DxO diag continue
Rules += sam~WE & sam~ES | (Street ~> sam)~WE & (Street ~> sam)~NW // OxD / DxO across
// OxD T (orth thru, diag Terminating)
Rules += sam~(0,0,11,3) | (Street ~> sam)~(11,2,0,2) // OxD T from orth-diag top
Rules += sam~WE | (Street ~> sam)~(2,11,2,0) // OxD T from orth 1
Rules += sam~WE | (Street ~> sam)~(2,13,2,0) // OxD T from orth 2
Rules += sam~(2,11,2,0) | (Street ~> sam)~WE // OxD T to orth 1
Rules += sam~(2,13,2,0) | (Street ~> sam)~WE // OxD T to orth 2
Rules += sam~(0,2,11,2) | (Street ~> sam)~(11,3,0,0) // OxD T to orth-diag top
// DxO T (diag thru, orth Terminating)
Rules += sam~WE | (Street ~> sam)~(2,0,202,0) & (Street ~> sam)~ES // DxO T from orth
Rules += sam~ES | (Street ~> sam)~NW & (Street ~> sam)~(0,202,0,2) // DxO T from diag
Rules += sam~ES | (Street ~> sam)~NW & (Street ~> sam)~(0,202,0,0) // DxO T from diag to aux tile
Rules += sam~ES & sam~(2,0,202,0) | (Street ~> sam)~WN & (Street ~> sam)~(202,0,0,0) // DxO T across
Rules += sam~ES & sam~(0,0,202,0) | (Street ~> sam)~WN & (Street ~> sam)~(202,0,2,0) // DxO T across
Rules += sam~ES & sam~(0,2,0,202) | (Street ~> sam)~WN // DxO T to diag
Rules += sam~ES & sam~(0,0,0,202) | (Street ~> sam)~WN // DxO T to diag from aux tile
Rules += sam~SW & sam~(202,0,2,0) | (Street ~> sam)~WE // DxO T to orth
// DxD
Rules += sam~ES | (Street ~> sam)~NW & (Street ~> sam)~EN // DxD from diag
Rules += sam~ES & sam~EN | (Street ~> sam)~WS & (Street ~> sam)~WN // DxD across
Rules += sam~ES & sam~WS | (Street ~> sam)~WN // DxD to diag
// DxD T
Rules += sam~NE | (Street ~> sam)~(3,0,0,201) & (Street ~> sam)~ES // DxD T from end diag
Rules += sam~ES | (Street ~> sam)~NW & (Street ~> sam)~(0,201,3,0) // DxD T from thru diag
Rules += sam~ES | (Street ~> sam)~NW & (Street ~> sam)~(0,201,0,0) // DxD T from thru diag (aux tile)
Rules += sam~(0,1,203,0) & sam~ES | (Street ~> sam)~(203,0,0,0) & (Street ~> sam)~NW // DxD T across 1
Rules += sam~(0,0,203,0) & sam~ES | (Street ~> sam)~(203,0,0,1) & (Street ~> sam)~NW // DxD T across 2
Rules += sam~(0,201,3,0) & sam~NW | (Street ~> sam)~WS // DxD T to diag from end side
Rules += sam~(3,0,0,201) & sam~ES | (Street ~> sam)~NW // DxD T to diag from thru side
Rules += sam~(0,0,0,201) & sam~ES | (Street ~> sam)~NW // DxD T to diag from aux tile
// intersections involving the orth-diag curve
// from ortho
val orthDiagIntsFromOrtho = Seq(
// T ints
(2,11,2,0), (2,0,2,11),
(2,2,11,0), (2,11,0,2),
(2,0,11,2), (2,2,0,11),
(2,11,11,0),
(2,13,13,0),
(2,13,0,11),
// (2,11,0,13), // does not exist in SAM
// (2,11,0,11), // does not exist in SAM
// (2,13,0,13), // does not exist in SAM
// + Ints
(2,11,2,2), (2,13,2,2), (2,2,11,2)
)
for (t <- orthDiagIntsFromOrtho) {
Rules ++= reflections((Street ~> sam)~WE | (Street ~> sam)~t)
}
// from orth-diag top
val orthDiagIntsFromDiag = Seq(
// T ints
(11,2,0,2),
(11,0,2,2),
(11,2,2,0),
(11,11,0,2), (11,0,2,11),
(11,2,0,11), (11,11,2,0),
(11,2,13,0),
// + ints
(11,2,2,2)
)
for (t <- orthDiagIntsFromDiag) {
Rules ++= reflections((Street ~> sam)~(0,0,11,3) | (Street ~> sam)~t) // from orth-diag top
Rules ++= reflections((Street ~> sam)~(0,0,11,13) | (Street ~> sam)~t) // from blend curve
}
// special intersections with road and onewayroad
for (minor <- Seq(Road, Onewayroad)) {
// intersections
// dual ortho SAM intersecting diagonal road/owr
Rules ++= reflections((Street ~> sam)~WE | (Street ~> sam)~(2,2,0,0) & minor~ES)
Rules += sam~WE | (Street ~> sam)~(2,0,0,0) & minor~(0,2,2,2)
Rules += sam~WE | (Street ~> sam)~(2,2,0,0) & minor~(0,0,2,2)
Rules += sam~WE | (Street ~> sam)~(2,2,2,0) & minor~(0,0,0,2)
Rules += sam~WE | (Street ~> sam)~(2,2,0,2) & minor~(0,0,2,0)
Rules += sam~WE | (Street ~> sam)~(2,0,0,0) & minor~(0,2,2,0)
Rules += sam~WE | (Street ~> sam)~(2,2,0,0) & minor~(0,0,2,0)
Rules += sam~WE | (Street ~> sam)~(2,0,0,2) & minor~(0,2,0,0)
// continuations
Rules += sam~(0,0,2,2) & minor~(1,3,0,0) | (Street ~> sam)~WE
Rules += sam~(0,0,2,2) & minor~(2,2,0,0) | (Street ~> sam)~WE
Rules += sam~(0,2,2,2) & minor~(2,0,0,0) | (Street ~> sam)~WE
Rules += sam~(2,2,2,0) & minor~(0,0,0,2) | (Street ~> sam)~WE
Rules += sam~(0,0,2,2) & minor~(2,0,0,0) | (Street ~> sam)~WE
Rules += sam~(0,0,2,2) & minor~(0,2,0,0) | (Street ~> sam)~WE
// transitions
Rules += sam~WE | (Street ~> sam)~WC & minor~CE // orth transition
Rules += sam~SE | (Street ~> sam)~CNW & Road~CWN // diag transition (TODO: change Road to minor when OWR version is added)
Rules += sam~WE | (Street ~> sam)~WC & minor~CS // bending transition
Rules += sam~WE | (Street ~> sam)~WC & minor~CWN // bending transition 1
Rules += sam~WE | (Street ~> sam)~WC & minor~CES // bending transition 2
}
// special avenue configurations
// OxO Avenue ending at SAM
Rules ++= reflections((Street ~> sam)~WE | (Street ~> sam)~WE & Avenue~NC) // OxO End T Tile 1
Rules += sam~WE & Avenue~NC | (Street ~> sam)~WE & Avenue~CN // OxO End T Tile 2
// OxO Avenue ending at SAM w/ SAM continuing in direction of Avenue
Rules ++= reflections((Street ~> sam)~WE | (Street ~> sam)~(2,2,0,2) & Avenue~CE)
Rules ++= reflections((Street ~> sam)~WE | (Street ~> sam)~(2,0,2,2) & Avenue~NC)
// overrides between the 2 and 3 SAM connection variants
Rules ++= reflections((Street ~> sam)~(2,0,2,2) & Avenue~NC | (Street ~> sam)~WE & Avenue~CN)
Rules += sam~(2,0,2,2) & Avenue~NC | (Street ~> sam)~(2,0,2,2) & Avenue~CN
// Avenue 90 degree transition to SAM
Rules += sam~WE | (Street ~> sam)~(2,0,0,0) & Avenue~NC
// avenue orthogonal transition to SAM
Rules += sam~WE | (Street ~> sam)~WC & Avenue~EC
// standard intersections with other networks
for (minor <- CrossNetworks) {
if (isSingleTile(minor)) {
// OxO
Rules += sam~WE | (Street ~> sam)~WE & minor~NS~SN // OxO from orth
Rules += sam~WE & minor~NS~SN | (Street ~> sam)~WE // OxO continue
// OxD
Rules += sam~WE | (Street ~> sam)~WE & minor~ES~SE // OxD
Rules += sam~WE & minor~ES~SE | (Street ~> sam)~WE & minor~NW~WN // OxD Tile 2
Rules += sam~WE & minor~NW~WN | (Street ~> sam)~WE // OxD continue
for (minBase <- minor.base) {
// stability when minor is an override network
Rules += sam~WE & minor~ES~SE | (Street ~> sam)~WE & (minBase ~> minor)~NW~WN
Rules += sam~WE & (minBase ~> minor)~ES~SE | (Street ~> sam)~WE & minor~NW~WN
Rules += sam~WE & minor~ES~SE | sam~WE & (minBase ~> minor)~NW~WN
}
// OxD T
// Rules += sam~WE & minor~WN | Street~WN | % | sam~WC & sam~WN // OxD T
// DxO & DxD
if (!minor.isNwm) {
// DxO
Rules += sam~ES | (Street ~> sam)~NW & minor~NS // DxO
Rules += sam~NE & minor~WE | (Street ~> sam)~WS & minor~WE // DxO Tile 2
Rules += sam~ES & minor~NS | (Street ~> sam)~NW // DxO continue
if (minor.base.isDefined) for (minBase <- minor.base) {
// stability when minor is an override network
Rules += sam~NE & minor~WE | (Street ~> sam)~WS & (minBase ~> minor)~WE
Rules += sam~NE & (minBase ~> minor)~WE | (Street ~> sam)~WS & minor~WE
Rules += sam~NE & minor~WE | sam~WS & (minBase ~> minor)~WE
}
if (minor == Rail || minor == Str) {
// overide crossbucks helper tiles of the street DxO rail crossings to regular SAM
val crossbucks = IdTile(0x5f502a00, R3F1, noSymmetries)
Rules += sam~ES | crossbucks | % | sam~NW // from diag
Rules += sam~NE & minor~NS | crossbucks * R3F0 | % | sam~WS // to diag
}
// Rules += sam~ES & minor~WE | minor~WN | % | sam~WC & minor~WN // DxO T
// DxD
Rules += sam~ES | (Street ~> sam)~NW & minor~NE~EN // DxD
Rules += sam~SE & minor~NE~EN | (Street ~> sam)~NW & minor~WS~SW // DxD Tile 2
Rules += sam~SE & minor~WS~SW | (Street ~> sam)~NW // DxD continue
for (minBase <- minor.base) {
// stability when minor is an override network
Rules += sam~SE & minor~NE~EN | (Street ~> sam)~NW & (minBase ~> minor)~WS~SW
Rules += sam~SE & (minBase ~> minor)~NE~EN | (Street ~> sam)~NW & minor~WS~SW
Rules += sam~SE & minor~NE~EN | sam~NW & (minBase ~> minor)~WS~SW
}
}
// SAM end T intersections
if (minor == Road || minor == Onewayroad || minor == Avenue || minor.isNwm) {
// OxO T (sam end)
Rules += sam~WE | (Street ~> sam)~WC & minor~NS~SN
}
if (minor == Road || minor == Onewayroad) {
// DxO T (sam end)
Rules += sam~ES | Street~CNW & minor~NS | sam~(0,0,11,3) | sam~CNW & minor~NS // DxO T from Diag
Rules += sam~(0,0,11,3) | Street~CNW & minor~NS | sam~(0,0,11,3) | sam~CNW & minor~NS // DxO T from Orth-Diag Top
Rules += sam~ES | Street~WC & minor~NS | sam~(0,0,11,3) | sam~CNW & minor~NS // DxO T from Diag for Old-Style Diag Streets
Rules += sam~(0,0,11,3) | Street~WC & minor~NS | sam~(0,0,11,3) | sam~CNW & minor~NS // DxO T from Orth-Diag Top for Old-Style Diag Streets
Rules += sam~CEN & minor~WE | sam~CWS & minor~WE | sam~NE & minor~WE | sam~SW & minor~WE // DxO Ts into DxO + for Old-Style
Rules += sam~CEN & minor~WE | Street~CWS & minor~WE | sam~NE & minor~WE | sam~SW & minor~WE // DxO Ts into DxO + for Old-Style
Rules += sam~NE & minor~WE | sam~CWS & minor~WE | sam~NE & minor~WE | sam~SW & minor~WE // DxO Ts into DxO + for Old-Style
Rules += sam~NE & minor~WE | Street~CWS & minor~WE | sam~NE & minor~WE | sam~SW & minor~WE // DxO Ts into DxO + for Old-Style
// DxD T (sam end)
Rules += sam~ES | (Street ~> sam)~(1,203,0,0) & minor~EN // DxD T End 1
Rules += sam~(0,1,203,0) & minor~ES | (Street ~> sam)~(203,0,0,0) & minor~NW // DxD T End 2
Rules += sam~NE & minor~ES | sam~(203,0,0,0) & minor~NW | sam~(0,1,203,0) & minor~ES | % // DxD T End 2 Alt (Truncate stub)
Rules += sam~NE & minor~ES | minor~NW | sam~(0,1,203,0) & minor~ES | sam~(203,0,0,0) & minor~NW // DxD T End 2 Alt (Truncate and propagate)
Rules += sam~(0,1,203,0) & minor~ES | minor~NW | % | sam~(203,0,0,0) & minor~NW // DxD T End 2 Alt (Propagate SAM end)
}
}
if (isDoubleTile(minor)) {
// OxO
Rules ++= reflections((Street ~> sam)~WE | (Street ~> sam)~WE & minor~NS)
Rules += sam~WE & minor~NS | (Street ~> sam)~WE & minor~SN
// OxO T-intersections
Rules += sam~WE | (Street ~> sam)~WC & minor~NS // OxO Short T
if (minor == Avenue) {
Rules += sam~WE & minor~NS | (Street ~> sam)~WC & minor~SN // OxO Long T
}
if (minor.typ == AvenueLike && minor == Avenue) { // other possibilities like Owr4 not supported yet
// OxD
Rules += sam~WE | (Street ~> sam)~WC & minor~ES // OxD Short-T
Rules += sam~WE | (Street ~> sam)~WE & minor~ES // OxD start
Rules += sam~WE & minor~ES | (Street ~> sam)~WE & minor~SharedDiagRight // OxD middle
Rules += sam~WE & minor~SharedDiagRight | (Street ~> sam)~WE & minor~WN // OxD end
Rules += sam~WE & minor~WN | (Street ~> sam)~WE // OxD continue
// DxO
// DxO short T
Rules += sam~(0,0,11,3) | (Street ~> sam~CNW) & minor~NS // DxO short T
// DxO +
Rules += sam~ES | (Street ~> sam)~NW & minor~NS // DxO start
Rules += sam~EN & minor~EW | (Street ~> sam)~SW & minor~EW // DxO middle 1
Rules += sam~ES & minor~NS | (Street ~> sam)~NW & minor~SN // DxO middle 2
Rules += sam~EN & minor~WE | (Street ~> sam)~SW & minor~WE // DxO end
Rules += sam~ES & minor~SN | (Street ~> sam)~NW // DxO continue
// DxD
Rules += sam~ES | (Street ~> sam)~NW & minor~NE // DxD start
Rules += sam~EN & minor~ES | (Street ~> sam)~SW & minor~SharedDiagRight // DxD middle
Rules += sam~ES & minor~SharedDiagLeft | (Street ~> sam)~NW & minor~SW // DxD end
Rules += sam~ES & minor~SW | (Street ~> sam)~NW // DxD continue
} else { // not shared-tile diagonals (none yet)
// OxD
// DxO
// DxD
}
}
if (isTripleTile(minor)) {
// OxO
if (hasRightShoulder(minor)) { // outer tile rule
Rules ++= reflections((Street ~> sam)~WE | (Street ~> sam)~WE & minor~NS)
for (median <- Seq(Ave6m, Tla7m)) {
Rules ++= reflections((Street ~> sam)~WE & minor~NS | (Street ~> sam)~WE & median~NS) // outer to inner / inner to outer
}
}
// OxO short T (SAM end)
if (hasRightShoulder(minor)) { // no short Ts on median tiles
Rules ++= reflections((Street ~> sam)~WE | (Street ~> sam)~WC & minor~NS)
}
}
}
// Thru SAM T-intersections
val supportsSamThruTs = List(Road, Onewayroad, Tla3, Ave2, Ard3, Nrd4, Owr1)
for (minor <- supportsSamThruTs) {
// OxO T (sam thru)
Rules += sam~WE | (Street ~> sam)~WE & minor~NC~CN
Rules += sam~WE | (Street ~> sam)~WE & minor~CS~SC
// continue
Rules += sam~WE & minor~NC~CN | (Street ~> sam)~WE
Rules += sam~WE & minor~CS~SC | (Street ~> sam)~WE
if (! minor.isNwm) {
// OxD T (sam thru)
Rules += sam~WE | (Street ~> sam)~WE & minor~CWN
// continue
Rules += sam~WE & minor~CWN | (Street ~> sam)~WE
// DxO T (sam thru)
Rules += sam~SE | (Street ~> sam)~WN & minor~CE
// continue
Rules += sam~NE & minor~CS | (Street ~> sam)~SW
// DxD T (sam thru)
// Rules += sam~ES | (Street ~> sam)~NW & minor~(0,201,3,0) // DxD Thru T 1 pending base long T tile
// Rules += sam~ES | (Street ~> sam)~NW & minor~(0,201,0,0) // DxD Thru T 2 pending base long T tile
Rules += sam~ES | Street~NW & minor~CNE | % | sam~NW & minor~(0,201,3,0) // DxD Thru T 1
Rules += sam~ES | Street~NW & minor~CWS | % | sam~NW & minor~(203,0,0,1) // Temp DxD Thru T 2 (works with DxD Thru T 1-2 Alt)
// Rules += sam~ES & minor~(0,1,203,0) | (Street ~> sam)~NW & minor~(203,0,0,0) // DxD Thru T 1-2 pending base long T tile
// Rules += sam~NE & minor~(0,0,201,0) | (Street ~> sam)~WS & minor~(201,3,0,0) // DxD Thru T 2-1 pending base long T tile
Rules += sam~ES & minor~(0,1,203,0) | Street~NW | % | sam~NW & minor~(203,0,0,0) // DxD Thru T 1-2 Alt
Rules += sam~ES & minor~(0,1,203,0) | sam~NW | % | sam~NW & minor~(203,0,0,0) // DxD Thru T 1-2 Alt
Rules += sam~NE & minor~(0,0,201,0) | Street~WS & minor~CWN | % | sam~WS & minor~(201,3,0,0) // DxD Thru T 2-1
// truncate minor stub on tile 1
Rules += sam~ES & minor~EN | Street~NW | sam~ES & minor~(0,1,203,0) | sam~NW & minor~(203,0,0,0) // DxD T 2-1 Alt
Rules += sam~ES & minor~EN | sam~NW | sam~ES & minor~(0,1,203,0) | sam~NW & minor~(203,0,0,0) // DxD T 2-1 Alt
Rules += sam~ES & minor~EN | sam~NW & minor~(203,0,0,0) | sam~ES & minor~(0,1,203,0) | % // DxD T 2-1 Alt
// continue
Rules += sam~ES & minor~(3,0,0,201) | (Street ~> sam)~NW // DxD Thru T 1
Rules += sam~ES & minor~(0,0,0,201) | (Street ~> sam)~NW // DxD Thru T 2
}
}
createRules()
}
createRules()
}
}
// Compile individually with `sbt "runMain com.sc4nam.module.CompileSamCode"`.
object CompileSamCode extends AbstractMain {
lazy val resolve: IdResolver = new SamResolver orElse new RealRailwayResolver orElse new MiscResolver orElse new NwmResolver
val generator = new SamRuleGenerator(_)
lazy val file = new java.io.File("Controller/RUL2/09_SAM/Sec9_SAM_MetaGenerated.txt")
}