Top Level Namespace
Defined Under Namespace
Classes: Acorn, Cell, Diehard, Display, Grid, RPentomino, Seed, SimpleSpaceship
Instance Method Summary collapse
Instance Method Details
#neighbor_indices ⇒ Object
36 37 38 39 40 41 42 43 44 |
# 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 |