diff --git a/solver/bfs.go b/solver/bfs.go index c7a961f..38b06f6 100644 --- a/solver/bfs.go +++ b/solver/bfs.go @@ -107,7 +107,7 @@ func (s *BFSSolver) Solve(m *maze.Maze) *maze.SolvedMaze { } func (s *BFSSolver) addIfNotVisited(node *maze.Node, current_history []*maze.Node) { - if !wasVisited(node) { + if !visited(node) { new_history := make([]*maze.Node, len(current_history)+1) copy(new_history, current_history) new_history[len(current_history)] = node diff --git a/solver/dfs.go b/solver/dfs.go index af27105..78eb882 100644 --- a/solver/dfs.go +++ b/solver/dfs.go @@ -18,7 +18,7 @@ func (s *DFSSolver) Solve(m *maze.Maze) *maze.SolvedMaze { for current != end { current.Visited = true - left_visited, right_visited, up_visited, down_visited := wasVisited(current.Left), wasVisited(current.Right), wasVisited(current.Up), wasVisited(current.Down) + left_visited, right_visited, up_visited, down_visited := visited(current.Left), visited(current.Right), visited(current.Up), visited(current.Down) if left_visited && right_visited && up_visited && down_visited { // dead end or no more visited nodes diff --git a/solver/solver.go b/solver/solver.go index 68f4f2f..80186f0 100644 --- a/solver/solver.go +++ b/solver/solver.go @@ -33,6 +33,6 @@ func (f *SolverFactory) Get() Solver { panic(fmt.Sprintf("Unrecognized solver type %q", *f.Type)) } -func wasVisited(node *maze.Node) bool { +func visited(node *maze.Node) bool { return node == nil || node.Visited }