class Object

Public Instance Methods

neighbor_indices() click to toggle source
# File lib/cell.rb, line 36
def neighbor_indices
  y_neighbors = [-1, 0, 1].product([@coordinates[1]]).map(&:sum)
  x_neighbors = [-1, 0, 1].product([@coordinates[0]]).map(&:sum)
  neighbors = x_neighbors.product(y_neighbors)
  neighbors -= [@coordinates]
  neighbors.map do |n_coords|
    [n_coords[0] % Grid::ROWS, n_coords[1] % Grid::COLS]
  end
end