-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_one_map.sh
106 lines (95 loc) · 2.68 KB
/
test_one_map.sh
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# **************************************************************************** #
# #
# ::: :::::::: #
# test_one_map.sh :+: :+: :+: #
# +:+ +:+ +:+ #
# By: cgiron <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/06/19 17:57:30 by cgiron #+# #+# #
# Updated: 2019/08/12 12:16:27 by cgiron ### ########.fr #
# #
# **************************************************************************** #
#!/bin/bash
################################ Functions #####################################
function usage() {
printf "\nusage: sh ./test_one_map.sh [map] [-a number of ants] [-l options][-h usage]\n\n"
printf "Lemin map test and displayer\n\
- with map\n\
- with a amount of ants\
- with -l or lemin options"
}
########################## Variables initialization ############################
map=$1
shift
ants=
program=./lem-in
visu=./visu_lemin
loptions="-es"
error=
############################# Options parser ###################################
while [ "$1" != "" ]; do
OPT=$1
case $OPT in
-h | --help)
usage
exit 0
;;
-a)
shift
ants=$1
;;
-l)
shift
loptions=$1
;;
*)
usage
exit
;;
esac
shift
done
################################ Main loop #####################################
usage
echo "\n\n MAP :\033[0;32m" $map
echo "\033[0mlemin options :\033[0;32m" $loptions
echo "\033[0mAmount of ant given\033[0;32m" $ants
echo "\033[0m"
if test -f "$program"; then
echo "\033[0;32m$program exist\033[0m"
else
echo "\033[0;31m$program absent\033[0m"
exit 1
fi
if test -f "$map"; then
echo "\033[0;32m$map exist\033[0m"
else
echo "\033[0;31m map absente\033[0m"
exit 1
fi
if [ ! -z "$ants" ]; then
$program $loptions -a $ants <$map
error=$($program -a $ants <$map | grep "ERROR")
else
$program $loptions <$map
error=$($program <$map | grep "ERROR")
fi
if [ ! -z "$error" ]; then
exit
fi
echo "\n\n\033[0;32mWant to see the result ? \033[0m 0 [no] 1 [just active paths] 2 [Whole]\n\n"
read -p "answer : " answer
if [ "$answer" == "1" ]; then
if [ ! -z "$ants" ]; then
$program -v -a $ants <$map | $visu&
else
$program -v <$map | $visu&
fi
fi
if [ "$answer" == "2" ]; then
if [ ! -z "$ants" ]; then
$program -vu -a $ants <$map | $visu&
else
$program -vu <$map | $visu&
fi
fi