summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-04-22 16:41:33 +0200
committerNoah Loomans <noahloomans@gmail.com>2018-04-22 16:41:46 +0200
commite5b08e0edb4c1c30c368c338a9148b846b087f5f (patch)
treee5b59a4da5a523eaadc6212c9b57da204e660b73
parentdf356d42954107688b7484b595ff1e33cd70291c (diff)
Refactor print statements
-rw-r--r--maze_generator.rb8
-rw-r--r--maze_solver.rb9
-rw-r--r--tui.rb2
3 files changed, 11 insertions, 8 deletions
diff --git a/maze_generator.rb b/maze_generator.rb
index 5022c89..fcecd26 100644
--- a/maze_generator.rb
+++ b/maze_generator.rb
@@ -24,7 +24,9 @@ class MazeGenerator
if ENV["DEBUG"] == "visual"
TUI::Screen.save
TUI::Screen.reset
- print "\n [ #{TUI::Color.purple}Generating maze...#{TUI::Color.reset} ]\n\n"
+ puts
+ puts " [ #{TUI::Color.magenta}Generating maze...#{TUI::Color.reset} ]"
+ puts
TUI::Cursor.save
end
@@ -33,8 +35,8 @@ class MazeGenerator
if ENV["DEBUG"] == "visual"
TUI::Cursor.restore
- print @maze.to_s(" ")
- print "\n\n"
+ puts @maze.to_s(" ")
+ puts
puts " Stack size: #{@stack.length}"
if @stack.length < @stack_threshold
puts " Current algorithm: Depth-first search"
diff --git a/maze_solver.rb b/maze_solver.rb
index 5633515..90af0c1 100644
--- a/maze_solver.rb
+++ b/maze_solver.rb
@@ -18,9 +18,10 @@ class MazeSolver
if ENV["DEBUG"] == "visual"
TUI::Screen.save
TUI::Screen.reset
- print "\n [ #{TUI::Color.purple}Solving maze...#{TUI::Color.reset} ]\n\n"
+ puts
+ puts " [ #{TUI::Color.magenta}Solving maze...#{TUI::Color.reset} ]"
+ puts
TUI::Cursor.save
-
end
while @stack.last != @end_pos
@@ -28,8 +29,8 @@ class MazeSolver
if ENV["DEBUG"] == "visual"
TUI::Cursor.restore
- print @maze.to_s(" ", @stack)
- print "\n\n"
+ puts @maze.to_s(" ", @stack)
+ puts
puts " Stack size: #{@stack.length}"
puts " Current algorithm: Depth-first search"
end
diff --git a/tui.rb b/tui.rb
index c1ab434..edc34d0 100644
--- a/tui.rb
+++ b/tui.rb
@@ -29,7 +29,7 @@ module TUI
"\e[0;31;1m"
end
- def self.purple
+ def self.magenta
"\e[1;35m"
end