diff options
author | Noah Loomans <noahloomans@gmail.com> | 2018-04-22 14:59:57 +0200 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2018-04-22 14:59:57 +0200 |
commit | f5bcd76d2c0420e61425f3cfd000f6a86445cb62 (patch) | |
tree | b11c83081fd94a3d813cb07bf5aa1fe09483c271 | |
parent | ba3c0382264fd6844fee3b1ea26c47c9d5332b82 (diff) |
Add default stack_treshold
-rw-r--r-- | main.rb | 2 | ||||
-rw-r--r-- | maze_generator.rb | 10 |
2 files changed, 9 insertions, 3 deletions
@@ -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 |