summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.rb2
-rw-r--r--maze_generator.rb10
2 files changed, 9 insertions, 3 deletions
diff --git a/main.rb b/main.rb
index 800cb89..6355d01 100644
--- a/main.rb
+++ b/main.rb
@@ -5,7 +5,7 @@ require_relative 'pos'
width = ARGV[0].to_i
height = ARGV[1].to_i
-maze_generator = MazeGenerator.new(width, height, 10000000)
+maze_generator = MazeGenerator.new(width, height)
maze_generator.generate!
maze = maze_generator.maze
diff --git a/maze_generator.rb b/maze_generator.rb
index 9afb459..5261f87 100644
--- a/maze_generator.rb
+++ b/maze_generator.rb
@@ -4,9 +4,15 @@ require_relative 'maze'
class MazeGenerator
attr_reader :maze
- def initialize(width, height, stack_threshold)
+ def initialize(width, height, stack_threshold = nil)
@maze = Maze.new(width, height)
- @stack_threshold = stack_threshold
+
+ @stack_threshold = if stack_threshold
+ stack_threshold
+ else
+ width * height
+ end
+
@visitedTiles = Array.new(width) { Array.new(height) { false } }
end