The task of the project is here
Wiki here and thx for him
This is a console program that builds a graph based on the data transmitted by the user and distributes the ants along the paths so that everyone reaches from A
to B
in a minimum of steps.
Also you can use web version for visualize your result. To do this, insert the map with result into the
text result
block and click on Set Params. Now your graph is represented graphically.
Program takes only 1 argument. It can be filename or flags.
"filename"
- your file path with graph data
--file="filename"
- as default input. Just an explicit launch with a file--http=":port"
- starts run server on your port. Using for visualization.
For run project:
go run ./cmd (filename | --http=:port | --file=filename)
Run program:
$ go run ./cmd example.txt
#My comment
3
##start
start 2 2
r1 3 1
r2 3 3
r3 4 1
##end
end 5 2
start-r1
start-r2
r1-r3
r2-end
r3-end
L1-r2 L2-r1
L1-end L2-r3 L3-r2
L2-end L3-end
Also Get Steps Count:
$ go run ./cmd example.txt | grep '^L' | wc -l
3
Run visualization:
$ go run ./cmd --http=:8080
YYYY/MM/DD hh:mm:ss Server started on http://localhost:8080
The program is provided with information about the graph (anthill) at the input:
- Number of
ants
(ants > 0) - The name of the vertices and their coordinates. The
##start
and##end
commands specify the starting and ending vertices of the path. (x > 0 & y > 0) - Edges connecting vertices.
- Optional comments starting by
#
(program ignore them)
The map file looks like this
#My comment
3
##start
start 2 2
r1 3 1
r2 3 3
r3 4 1
##end
end 5 2
start-r1
start-r2
r1-r3
r2-end
r3-end
To learn more, read the wiki