Class: Amaze::Algorithm::BinaryTree
- Inherits:
-
Amaze::Algorithm
- Object
- Amaze::Algorithm
- Amaze::Algorithm::BinaryTree
- Defined in:
- lib/amaze/algorithm/binary_tree.rb
Instance Attribute Summary
Attributes inherited from Amaze::Algorithm
Instance Method Summary collapse
Methods inherited from Amaze::Algorithm
Instance Method Details
#status ⇒ Object
17 18 19 |
# File 'lib/amaze/algorithm/binary_tree.rb', line 17 def status "Binary tree algorithm: #{duration}s" end |
#work(grid) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/amaze/algorithm/binary_tree.rb', line 4 def work grid count = 0 # visualize grid.each_cell do |cell| links = [cell.north, cell.east].compact cell.link links[rand(links.size)] unless links.empty? yield Stat.new( # visualize current: [cell], # info: "Cell: #{count += 1}") if block_given? # end grid end |