Skip to content

Instantly share code, notes, and snippets.

@EdmundLeex
Created August 8, 2015 18:17
Show Gist options
  • Save EdmundLeex/7483949731d4521709a7 to your computer and use it in GitHub Desktop.
Save EdmundLeex/7483949731d4521709a7 to your computer and use it in GitHub Desktop.
class Board
def initialize(grid = nil)
@grid = grid || Array.new(3, Array.new(3))
end
def grid
@grid.each { |row| p row }
end
def [](row, col)
@grid[row][col]
end
def []=(row, col, mark)
@grid[row][col] = mark
end
def place_mark(pos, mark)
# raise Exception if empty?(*pos)
self[*pos] = mark
end
def empty?(pos)
self[*pos].nil?
end
def winner
end
def over?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment