Skip to content

Commit

Permalink
fix unnecessary else statement
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed May 4, 2023
1 parent 7324872 commit 0fffc59
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions maze.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,20 @@ func (maze *Maze) Undo() {
if point.Equal(next) {
// Previous point was not found (for example: the start point)
break
} else {
// Move backward
point = next
// If there's another path which has not been visited, stop the procedure
count := 0
for _, direction := range Directions {
if maze.Directions[next.X][next.Y]&direction != 0 {
count++
}
}
// The path we came from, we visited once and another
if count > 2 {
break
}
// Move backward
point = next
// If there's another path which has not been visited, stop the procedure
count := 0
for _, direction := range Directions {
if maze.Directions[next.X][next.Y]&direction != 0 {
count++
}
}
// The path we came from, we visited once and another
if count > 2 {
break
}
}
// Move back the cursor
maze.Cursor = point
Expand Down

0 comments on commit 0fffc59

Please sign in to comment.