From e5b08e0edb4c1c30c368c338a9148b846b087f5f Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Sun, 22 Apr 2018 16:41:33 +0200 Subject: Refactor print statements --- maze_generator.rb | 8 +++++--- maze_solver.rb | 9 +++++---- tui.rb | 2 +- 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 -- cgit v1.1