Skip to content

Instantly share code, notes, and snippets.

@bokmann
Created December 9, 2013 23:47
Show Gist options
  • Save bokmann/7883209 to your computer and use it in GitHub Desktop.
Save bokmann/7883209 to your computer and use it in GitHub Desktop.
a board class template for connect 4, for a coding challenge.
class C4Board
BLACK = :black
RED = :red
EMPTY = nil
# returns an array of all the columns a piece can be dropped in currently
def moves
end
# returns a new board with the to_move's piece dropped in the provided column
def move(position)
end
# returns :red or :black, depending on whose turn it is.
def player_to_move
end
# truthy if won, false otherwise
def won?
end
# should return 2d array suitable for displaying
def cells
end
# returns a board initialized to be empty, with :black set as the current player.
def self.starting_board
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment