20_jurassic_jigsaw.rb
# Selects tiles of a line (row or column) and orients.
# Pass in size to limit the size, or a block to say when to stop.
Selects tiles of a line (row or column) and orients.
Pass in size to limit the size, or a block to say when to stop.
Selects tiles of a line ( row or column ) and orients . Pass in size to limit the size or a block to say when to stop .
def build_line(first, prev_border, line, size: nil)
  raise "Don't know when to stop" if !size && !block_given?
  case line
  when :row
    match_border_current = :left
    match_border_prev = :right
  when :column
    match_border_current = :top
    match_border_prev = :bottom
  else
    raise "bad line #{line}"
  end
  line = [first]
  prev = first
  until line.size == size
    current, current_border = prev.neigh[prev_border]
    current.make_match_border!(match_border_current, prev.borders[match_border_prev])
    prev_border = OPPOSITE[current_border]
    line << current
    break if block_given? && yield(current)
    prev = current
  end
  line
end
def build_line ( first , prev_border , line , size : nil ) raise "Don't know when to stop" if ! size && ! block_given? case line when :row match_border_current = :left match_border_prev = :right when :column match_border_current = :top match_border_prev = :bottom else raise "bad line #{line}" end line = [ first ] prev = first until line . size == size current , current_border = prev . neigh [ prev_border ] current . make_match_border! ( match_border_current , prev . borders [ match_border_prev ] ) prev_border = OPPOSITE [ current_border ] line << current break if block_given? && yield ( current ) prev = current end line end
Selects tiles of a line (row or column) and orients.
Selects tiles of a line ( row or column ) and orients .
first
<not_specific>
prev_border
<not_specific>
line
<not_specific>
size
<not_specific>