-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
58 lines (47 loc) · 1.1 KB
/
main.go
File metadata and controls
58 lines (47 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"log"
"os"
"sort"
"strings"
)
var (
Route []Vertex
NumberAnts int
)
func main() {
if len(os.Args) != 2 {
log.Fatal("Usage: go run . <filename>")
}
filename := os.Args[1]
// Read data from file
data, err := os.ReadFile(filename)
if err != nil {
log.Fatal(err)
}
content := strings.Split(string(data), "\n")
NumberAnts = ValidateAnts(content)
MyMap, index := ValidateRooms(content)
CheckDuplicateNames(&MyMap)
MyMap = ValidateLinks(content[index:], &MyMap)
for k := range MyMap {
if k.Start {
RecursivePathFinder(k, Route)
}
}
AllPossibleCombs := CombinePaths(AllPaths)
for i := range AllPossibleCombs {
AllPossibleCombs[i].FindTotalTurns(NumberAnts)
}
if len(AllPossibleCombs) == 0 {
log.Fatal("Error: No valid path found from start to end")
}
sort.Slice(AllPossibleCombs, func(i, j int) bool {
return AllPossibleCombs[i].TotalTurns < AllPossibleCombs[j].TotalTurns
})
MaxFlow := AllPossibleCombs[0].PathComb
QueuedAnts := QueueThem(NumberAnts, MaxFlow)
fmt.Println(string(data) + "\n")
PrintResult(QueuedAnts, MaxFlow, NumberAnts)
}