summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-04-22 12:42:42 +0200
committerNoah Loomans <noahloomans@gmail.com>2018-04-22 12:42:50 +0200
commit98ddcffd5264e355fb6d651d18be9b51c34ae544 (patch)
treecb6472e53336475a06132a956da0e0c4cb6afa38
parentbbcdf015a9248e866153e85684b6a88df735bedc (diff)
Rename limit to threshold
-rw-r--r--maze_generator.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/maze_generator.rb b/maze_generator.rb
index d0526a9..9afb459 100644
--- a/maze_generator.rb
+++ b/maze_generator.rb
@@ -4,9 +4,9 @@ require_relative 'maze'
class MazeGenerator
attr_reader :maze
- def initialize(width, height, stack_limit)
+ def initialize(width, height, stack_threshold)
@maze = Maze.new(width, height)
- @stack_limit = stack_limit
+ @stack_threshold = stack_threshold
@visitedTiles = Array.new(width) { Array.new(height) { false } }
end
@@ -30,8 +30,8 @@ class MazeGenerator
print "\e[u" # Restore the cursor position
print @maze.to_s(" ")
print "\n\n"
- puts " Stack size: #{@stack.length}"
- if @stack.length < @stack_limit
+ puts " Stack size: #{@stack.length}/#{@stack_threshold}"
+ if @stack.length < @stack_threshold
puts " Current algorithm: Depth-first-search"
else
puts " Current algorithm: Breath-first-search"
@@ -45,7 +45,7 @@ class MazeGenerator
end
def step()
- current_tile = if @stack.length < @stack_limit
+ current_tile = if @stack.length < @stack_threshold
@stack.last
else
@stack.first
@@ -57,7 +57,7 @@ class MazeGenerator
end
if neighbors.empty?
- if @stack.length < @stack_limit
+ if @stack.length < @stack_threshold
@stack.pop()
else
@stack.shift()