-
Notifications
You must be signed in to change notification settings - Fork 0
/
mazemaker
executable file
·92 lines (72 loc) · 1.31 KB
/
mazemaker
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
#!/bin/sh
mazemakerDir=/opt/Mazemaker;
supportDir=$mazemakerDir/mazemaker_support;
parse_input(){
if [ $# = 0 ]; then
make
exit
fi;
local R=60
local C=80
while [ "$#" -ge 1 ];
do
key="$1";
case $key in
-h|--help)
print_help;
exit
;;
-c|--clean)
clean
exit
;;
[0-9]*)
local R=$1
local C=$2
shift 2
;;
--uninstall)
sudo $mazemakerDir/uninstall.sh
exit
;;
*) # unknown option
echo "Usage: $0 [options] rows columns"
exit
;;
esac
#shift # past argument or value
done
make $R $C
}
clean(){
rm -f maze*.png;
rm -f maze.txt path.txt;
}
#creates a maze of the given size
make(){
local R=$1;
local C=$2;
$supportDir/mazemake ${R:=60} ${C:=80} > maze.txt;
$supportDir/mazesolve < maze.txt > path.txt;
mazename="maze_${R}x${C}.png";
pathname="maze_path_${R}x${C}.png";
$supportDir/mazeshow 10 maze.txt | convert - $mazename;
$supportDir/mazeshow 10 maze.txt path.txt | convert - $pathname;
rm maze.txt path.txt;
}
#Displays a list of possible commands
print_help(){
echo "Usage: $0 [options] rows columns"
echo
echo "OPTIONS"
echo " -c, --clean"
echo " Removes maze files from the current directory"
echo
echo " -h, --help"
echo " Displays this screen"
echo
echo " --uninstall"
echo " uninstalls Mazemaker from the machine"
echo
}
parse_input $@;