author | unC0Rr |
Fri, 03 Feb 2023 14:44:33 +0100 | |
branch | transitional_engine |
changeset 15916 | e82de0410da5 |
child 15918 | 9bd828451d77 |
permissions | -rw-r--r-- |
15916
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
1 |
#[derive(Debug, PartialEq, Clone, Copy)] |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
2 |
pub enum SymmetryTransform { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
3 |
Id, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
4 |
Flip, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
5 |
Mirror, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
6 |
FlipMirror, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
7 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
8 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
9 |
#[derive(Debug, PartialEq, Clone, Copy)] |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
10 |
pub enum RotationTransform { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
11 |
Rotate0(SymmetryTransform), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
12 |
Rotate90(SymmetryTransform), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
13 |
Rotate180(SymmetryTransform), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
14 |
Rotate270(SymmetryTransform), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
15 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
16 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
17 |
impl Default for RotationTransform { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
18 |
fn default() -> Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
19 |
RotationTransform::Rotate0(SymmetryTransform::Id) |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
20 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
21 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
22 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
23 |
impl SymmetryTransform { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
24 |
pub fn mirror(&self) -> Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
25 |
use SymmetryTransform::*; |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
26 |
match self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
27 |
Id => Mirror, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
28 |
Flip => FlipMirror, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
29 |
Mirror => Id, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
30 |
FlipMirror => Flip, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
31 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
32 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
33 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
34 |
pub fn flip(&self) -> Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
35 |
use SymmetryTransform::*; |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
36 |
match self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
37 |
Id => Flip, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
38 |
Flip => Id, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
39 |
Mirror => FlipMirror, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
40 |
FlipMirror => Mirror, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
41 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
42 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
43 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
44 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
45 |
impl RotationTransform { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
46 |
pub fn new() -> Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
47 |
Self::default() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
48 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
49 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
50 |
pub fn mirror(self) -> RotationTransform { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
51 |
match self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
52 |
RotationTransform::Rotate0(s) => RotationTransform::Rotate0(s.mirror()), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
53 |
RotationTransform::Rotate90(s) => RotationTransform::Rotate270(s.mirror()).simplified(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
54 |
RotationTransform::Rotate180(s) => { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
55 |
RotationTransform::Rotate180(s.mirror()).simplified() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
56 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
57 |
RotationTransform::Rotate270(s) => RotationTransform::Rotate90(s.mirror()), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
58 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
59 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
60 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
61 |
pub fn flip(self) -> RotationTransform { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
62 |
match self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
63 |
RotationTransform::Rotate0(s) => RotationTransform::Rotate0(s.flip()), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
64 |
RotationTransform::Rotate90(s) => RotationTransform::Rotate90(s.flip()), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
65 |
RotationTransform::Rotate180(s) => RotationTransform::Rotate180(s.flip()).simplified(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
66 |
RotationTransform::Rotate270(s) => RotationTransform::Rotate270(s.flip()).simplified(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
67 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
68 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
69 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
70 |
pub fn rotate90(self) -> RotationTransform { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
71 |
match self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
72 |
RotationTransform::Rotate0(s) => RotationTransform::Rotate90(s), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
73 |
RotationTransform::Rotate90(s) => RotationTransform::Rotate180(s).simplified(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
74 |
RotationTransform::Rotate180(s) => RotationTransform::Rotate270(s).simplified(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
75 |
RotationTransform::Rotate270(s) => RotationTransform::Rotate0(s), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
76 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
77 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
78 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
79 |
pub fn rotate180(self) -> RotationTransform { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
80 |
match self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
81 |
RotationTransform::Rotate0(s) => RotationTransform::Rotate180(s).simplified(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
82 |
RotationTransform::Rotate90(s) => RotationTransform::Rotate270(s).simplified(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
83 |
RotationTransform::Rotate180(s) => RotationTransform::Rotate0(s), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
84 |
RotationTransform::Rotate270(s) => RotationTransform::Rotate90(s), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
85 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
86 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
87 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
88 |
pub fn rotate270(self) -> RotationTransform { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
89 |
match self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
90 |
RotationTransform::Rotate0(s) => RotationTransform::Rotate270(s).simplified(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
91 |
RotationTransform::Rotate90(s) => RotationTransform::Rotate0(s), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
92 |
RotationTransform::Rotate180(s) => RotationTransform::Rotate90(s), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
93 |
RotationTransform::Rotate270(s) => RotationTransform::Rotate180(s).simplified(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
94 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
95 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
96 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
97 |
fn simplified(self) -> Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
98 |
match self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
99 |
RotationTransform::Rotate0(s) => RotationTransform::Rotate0(s), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
100 |
RotationTransform::Rotate90(s) => RotationTransform::Rotate90(s), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
101 |
RotationTransform::Rotate180(s) => RotationTransform::Rotate0(s.flip().mirror()), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
102 |
RotationTransform::Rotate270(s) => RotationTransform::Rotate90(s.flip().mirror()), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
103 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
104 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
105 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
106 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
107 |
#[cfg(test)] |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
108 |
mod tests { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
109 |
use super::{RotationTransform::*, SymmetryTransform::*, *}; |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
110 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
111 |
// I totally wrote all of this myself and didn't use ChatGPT |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
112 |
#[test] |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
113 |
fn test_default() { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
114 |
let rt = RotationTransform::new(); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
115 |
assert_eq!(rt, Rotate0(Id)); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
116 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
117 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
118 |
#[test] |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
119 |
fn test_mirror() { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
120 |
let rt = Rotate90(Flip); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
121 |
let mirrored = rt.mirror(); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
122 |
assert_eq!(mirrored, Rotate90(Id)); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
123 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
124 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
125 |
#[test] |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
126 |
fn test_flip() { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
127 |
let rt = Rotate180(Mirror); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
128 |
let flipped = rt.flip(); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
129 |
assert_eq!(flipped, Rotate0(Id)); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
130 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
131 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
132 |
#[test] |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
133 |
fn test_rotate90() { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
134 |
let rt = Rotate0(Id); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
135 |
let rotated = rt.rotate90(); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
136 |
assert_eq!(rotated, Rotate90(Id)); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
137 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
138 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
139 |
#[test] |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
140 |
fn test_rotate180() { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
141 |
let rt = Rotate90(Mirror); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
142 |
let rotated = rt.rotate180(); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
143 |
assert_eq!(rotated, Rotate90(Flip)); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
144 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
145 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
146 |
#[test] |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
147 |
fn test_rotate270() { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
148 |
let rt = Rotate180(Flip); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
149 |
let rotated = rt.rotate270(); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
150 |
assert_eq!(rotated, Rotate90(Flip)); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
151 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
152 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
153 |
#[test] |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
154 |
fn test_simplified() { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
155 |
let rt = Rotate180(Id); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
156 |
let simplified = rt.simplified(); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
157 |
assert_eq!(simplified, Rotate0(FlipMirror)); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
158 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
159 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
160 |
#[test] |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
161 |
fn test_rotation_chain() { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
162 |
assert_eq!( |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
163 |
RotationTransform::default(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
164 |
RotationTransform::default() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
165 |
.rotate90() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
166 |
.rotate90() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
167 |
.rotate90() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
168 |
.rotate90() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
169 |
); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
170 |
assert_eq!( |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
171 |
RotationTransform::default().rotate90(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
172 |
RotationTransform::default() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
173 |
.rotate180() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
174 |
.rotate90() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
175 |
.rotate180() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
176 |
); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
177 |
assert_eq!( |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
178 |
RotationTransform::default().rotate180(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
179 |
RotationTransform::default() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
180 |
.rotate180() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
181 |
.rotate270() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
182 |
.rotate90() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
183 |
); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
184 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
185 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
186 |
#[test] |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
187 |
fn test_combinations_chain() { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
188 |
assert_eq!( |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
189 |
RotationTransform::default(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
190 |
RotationTransform::default() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
191 |
.flip() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
192 |
.rotate180() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
193 |
.flip() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
194 |
.rotate180() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
195 |
); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
196 |
assert_eq!( |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
197 |
RotationTransform::default(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
198 |
RotationTransform::default() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
199 |
.mirror() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
200 |
.rotate180() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
201 |
.mirror() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
202 |
.rotate180() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
203 |
); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
204 |
assert_eq!( |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
205 |
RotationTransform::default(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
206 |
RotationTransform::default() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
207 |
.rotate90() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
208 |
.flip() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
209 |
.rotate90() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
210 |
.mirror() |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
211 |
); |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
212 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
diff
changeset
|
213 |
} |