From 65576c9331f46effe754e428513c41eab1e4f903 Mon Sep 17 00:00:00 2001 From: hhlal Date: Tue, 14 May 2024 18:31:00 +0300 Subject: [PATCH] declare all paths --- maze/maze.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/maze/maze.go b/maze/maze.go index c51baea..8771e51 100644 --- a/maze/maze.go +++ b/maze/maze.go @@ -192,18 +192,17 @@ func (maze *Maze) Solve() { } func (maze *Maze) explorePaths(currentRoom Room, endRoom string, currentPath []string, paths *[]string) { - currentPath = append(currentPath, currentRoom.name) // is the end room + currentPath = append(currentPath, currentRoom.name) if currentRoom.name == endRoom { // is the end room *paths = append(*paths, strings.Join(currentPath, " -> ")) return } - // Explore all possible paths from current room + // explore all possible paths from current room for _, nextRoomName := range currentRoom.paths { for _, room := range maze.rooms { if room.name == nextRoomName { - // Explore next room if it's not already visited if !contains(currentPath, room.name) { maze.explorePaths(room, endRoom, currentPath, paths) }