diff --git a/src/main.rs b/src/main.rs index 33fe909..1d5d7e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -144,7 +144,51 @@ impl Cube { self.r.apply_l(u_bl, u_bm, u_br); } - // TODO: B + fn b(&mut self) { + self.b.rotate(); + let (u_tl, u_tm, u_tr) = (self.u.tl, self.u.tm, self.u.tr); + self.u.apply_t(self.r.tr, self.r.mr, self.r.br); + self.r.apply_r(self.d.br, self.d.bm, self.d.bl); + self.d.apply_b(self.l.tl, self.l.ml, self.l.bl); + self.l.apply_l(u_tr, u_tm, u_tl); + } + + // TODO: efficient counter-clockwise + fn up(&mut self) { + self.u(); + self.u(); + self.u(); + } + + fn dp(&mut self) { + self.d(); + self.d(); + self.d(); + } + + fn lp(&mut self) { + self.l(); + self.l(); + self.l(); + } + + fn rp(&mut self) { + self.r(); + self.r(); + self.r(); + } + + fn fp(&mut self) { + self.f(); + self.f(); + self.f(); + } + + fn bp(&mut self) { + self.b(); + self.b(); + self.b(); + } } fn main() { @@ -214,4 +258,16 @@ mod tests { assert_eq!(c.r.tl, Color::Y); assert_eq!(c.b, Face::new(Color::B)); } + + #[test] + fn test_b() { + let mut c = Cube::new(); + c.b(); + assert_eq!(c.b, Face::new(Color::B)); + assert_eq!(c.u.tl, Color::O); + assert_eq!(c.l.bl, Color::Y); + assert_eq!(c.d.br, Color::R); + assert_eq!(c.r.tr, Color::W); + assert_eq!(c.f, Face::new(Color::G)); + } }