~nybble/langtons-termite

a391bc2ed241b9518cf0e1abc21bc6c581a950b1 — Steve Sprang 3 months ago 771112f
Stop passing orientation to step() method.
1 files changed, 5 insertions(+), 5 deletions(-)

M src/world.rs
M src/world.rs => src/world.rs +5 -5
@@ 210,8 210,8 @@ impl World {
        self.x %= self.width;
    }

    fn step(&mut self, orientation: Cardinal) {
        match orientation {
    fn step(&mut self) {
        match self.orientation {
            N => self.step_north(),
            S => self.step_south(),
            E => self.step_east(),


@@ 222,7 222,7 @@ impl World {
            //    N        N | E
            //  W-+-E  =>  --+--
            //    S        W | S
            match orientation {
            match self.orientation {
                N => self.step_west(),
                S => self.step_east(),
                E => self.step_north(),


@@ 236,7 236,7 @@ impl World {

        // turn around and move forward one cell
        self.orientation = self.orientation.flip();
        self.step(self.orientation);
        self.step();
    }

    pub fn move_termite(&mut self) -> (usize, usize) {


@@ 257,7 257,7 @@ impl World {
        *byte ^= mask;

        // move forward one cell
        self.step(self.orientation);
        self.step();

        // return the affected char coordinates
        (char_x, char_y)