-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rb
65 lines (56 loc) · 1.3 KB
/
main.rb
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
params = ARGV
$help = params.include?("--help")
$version = params.include?("--version")
if RUBY_PLATFORM == "java"
$jruby = true
else
$jruby = false
end
if params.include?("--verbose") or params.include?("-v")
$verbose = true
else
$verbose = false
end
if params.include?("--benchmark") or params.include?("-b")
$benchmark = true
else
$benchmark = false
end
if params.include?("--method") or params.include?("-m")
if params.include?("--method")
index = params.index("--method")
elsif params.include?("-m")
index = params.index("-m")
else
exit 1
end
$method = params[index + 1]
else
$method = "dijkstra"
end
if $help
puts ""
puts "USAGE: ruby main.rb [options]"
puts " --benchmark times the process of solving the selected maze"
puts " --method specifies which pathfinding algorithm to use - defaults to Dijkstra"
puts " breadth_first_search"
puts " depth_first_search"
puts " dijkstra"
puts " --verbose displays progress bars at various points in the program"
puts " --version displays the version number"
puts " --help shows this message"
puts ""
puts "Example"
puts "ruby main.rb --benchmark --verbose --method breadth_first_search"
puts ""
exit
end
if $version
puts ""
puts "Maze Solver"
puts "Version: 0.7"
puts ""
exit
end
require_relative 'maze'
maze