Module: Boutaoshi
- Defined in:
- lib/algorithms/boutaoshi.rb
Instance Method Summary collapse
Instance Method Details
#generate ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/algorithms/boutaoshi.rb', line 11 def generate init_panels each_panels do |panel, x, y| if post?(x,y) && y == 2 random_floor(four_panels(x,y)).set_kind(:wall) end end each_panels do |panel, x, y| if post?(x,y) && y != 2 random_floor(three_panels(x,y)).set_kind(:wall) end end end |
#init_panels ⇒ Object
4 5 6 7 8 9 |
# File 'lib/algorithms/boutaoshi.rb', line 4 def init_panels each_panels do |panel, x, y| panel.set_kind(:floor) panel.set_kind(:wall) if post?(x,y) end end |
#post?(x, y) ⇒ Boolean
27 28 29 |
# File 'lib/algorithms/boutaoshi.rb', line 27 def post?(x,y) ( x % 2 ) == 1 && ( y % 2 ) == 1 end |