From f5bcd76d2c0420e61425f3cfd000f6a86445cb62 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Sun, 22 Apr 2018 14:59:57 +0200 Subject: Add default stack_treshold --- main.rb | 2 +- maze_generator.rb | 10 ++++++++-- 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 -- cgit v1.1