Method: Grid#initialize

Defined in:
lib/pathfinding/core/grid.rb

#initialize(matrix) ⇒ Grid

Creates a grid from a matrix:

  • 0 (or less) represents a walkable node

  • A number greater than 0 does not represents a walkable node

The width represents the number of columns whereas the height is the number of rows of the grid. The node attribute is the list of nodes.



26
27
28
29
30
# File 'lib/pathfinding/core/grid.rb', line 26

def initialize(matrix)
  @height = matrix.length
  @width = matrix[0].length
  @nodes = Grid.build_nodes(@width, @height, matrix)
end