try to get paths
This commit is contained in:
parent
c8bc135c86
commit
11ce220347
|
@ -0,0 +1,10 @@
|
|||
4
|
||||
##start
|
||||
1 2 3
|
||||
##end
|
||||
3 5 2
|
||||
2 5 6
|
||||
1-3
|
||||
1-2
|
||||
2-3
|
||||
3-2
|
30
maze/maze.go
30
maze/maze.go
|
@ -15,12 +15,15 @@ type Maze struct {
|
|||
}
|
||||
|
||||
type Room struct {
|
||||
connections []Room
|
||||
distance int
|
||||
name string
|
||||
occupancies int
|
||||
paths []string
|
||||
}
|
||||
|
||||
var collection [][]string
|
||||
|
||||
|
||||
// Load method to load the maze from input
|
||||
func Load(inputStream *bufio.Reader) *Maze {
|
||||
maze := &Maze{}
|
||||
|
@ -165,11 +168,32 @@ func (maze *Maze) mapFarm(line string) bool {
|
|||
}
|
||||
|
||||
// Establish connection between rooms
|
||||
room1.connections = append(room1.connections, *room2)
|
||||
room2.connections = append(room2.connections, *room1)
|
||||
// room1. = append(room1.connections, *room2)
|
||||
// room2.connections = append(room2.connections, *room1)
|
||||
collection = append(collection, []string{room1Name, room2Name})
|
||||
return true
|
||||
}
|
||||
|
||||
func (maze *Maze) Solve() {
|
||||
log.Println("Solving the maze...")
|
||||
//l want to declare all paths
|
||||
var path string;
|
||||
var currentcol = collection[0][0]
|
||||
var flage bool
|
||||
|
||||
for !strings.HasPrefix(currentcol, maze.endRoom){
|
||||
|
||||
if strings.HasPrefix(currentcol, maze.startRoom) {
|
||||
path = currentcol
|
||||
flage = true
|
||||
break
|
||||
}
|
||||
|
||||
if flage {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
log.Println(collection)
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue