Refactor: wasVisited -> visited
This commit is contained in:
parent
408b4c84c4
commit
49d98d84d2
@ -107,7 +107,7 @@ func (s *BFSSolver) Solve(m *maze.Maze) *maze.SolvedMaze {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *BFSSolver) addIfNotVisited(node *maze.Node, current_history []*maze.Node) {
|
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)
|
new_history := make([]*maze.Node, len(current_history)+1)
|
||||||
copy(new_history, current_history)
|
copy(new_history, current_history)
|
||||||
new_history[len(current_history)] = node
|
new_history[len(current_history)] = node
|
||||||
|
@ -18,7 +18,7 @@ func (s *DFSSolver) Solve(m *maze.Maze) *maze.SolvedMaze {
|
|||||||
for current != end {
|
for current != end {
|
||||||
current.Visited = true
|
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 {
|
if left_visited && right_visited && up_visited && down_visited {
|
||||||
// dead end or no more visited nodes
|
// dead end or no more visited nodes
|
||||||
|
@ -33,6 +33,6 @@ func (f *SolverFactory) Get() Solver {
|
|||||||
panic(fmt.Sprintf("Unrecognized solver type %q", *f.Type))
|
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
|
return node == nil || node.Visited
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user