Skip to content

Instantly share code, notes, and snippets.

@iannguyen
Last active August 29, 2015 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iannguyen/07b0336a79ddc9d1fc22 to your computer and use it in GitHub Desktop.
Save iannguyen/07b0336a79ddc9d1fc22 to your computer and use it in GitHub Desktop.
Recursive goodness
def reveal(pos)
tile = self[*pos]
return if tile.revealed
tile.revealed = true
if tile.value == 0
adjacent_squares(pos).each do |square|
neighbor_tile = self[*square]
reveal(square)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment