Refactor: wasVisited -> visited

This commit is contained in:
Karma Riuk 2023-08-15 15:42:53 +02:00
parent 408b4c84c4
commit 49d98d84d2
3 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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
}