-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·46 lines (36 loc) · 1.63 KB
/
run.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
#Author: Jack Robbins
#A simple runner script for the puzzle solver
#Fault toreance for inputs has been added -- should be adequately user proof
#!/bin/bash
#Make sure that the files exists
if [[ ! -f ./solve.c ]] || [[ ! -f ./generate_start_config.c ]] || [[ ! -f ./solve_multi_threaded.c ]]; then
echo "Files not found."
exit 1;
fi
#Compile with aggressive warnings
gcc -Wall -Wextra generate_start_config.c puzzle.c -o generate_start_config
gcc -Wall -Wextra solve.c puzzle.c -o solve
#IMPORTANT - must link pthread library when compiling
gcc -Wall -Wextra -pthread solve_multi_threaded.c puzzle.c -o solve_multi_threaded
#Get the puzzle size from user
read -p "Enter a positive integer for the NxN puzzle size: " SIZE
#Faulty input tolerance -- stop user until positive integer is inputted
while [[ $SIZE -lt 1 ]]; do
read -p "Enter a positive integer for the NxN puzzle size: " SIZE
done
#Get the complexity of the puzzle from the user
read -p "Enter a positive integer for complexity of initial configuration: " COMPLEXITY
#Faulty input tolerance -- stop user until positive integer is inputted
while [[ $COMPLEXITY -lt 0 ]]; do
read -p "Enter a positive integer for complexity of initial configuration: " COMPLEXITY
done
#Get the multithreaded option from user
read -p "Do you want to use multithreading[Y/n]: " MULTITHREADED
#Grab the input(last line of gen output)
input=$(./generate_start_config $SIZE $COMPLEXITY | tail -n 1)
#Use the appropriate version of the program depending on what the user inputted
if [[ $MULTITHREADED == "Y" ]] || [[ $MULTITHREADED == "y" ]]; then
./solve_multi_threaded $SIZE $input
else
./solve $SIZE $input
fi