Prerequisites:
- Docker (*nix) or Docker Desktop (Windows/Mac)
- *nix-based Command Line Environment (i.e. WSL2 on Windows)
With Docker running, execute the following commands in order.
This will generate the container image. It needs to be run each time the container configuration changes.
docker build -t cpp-container .
This will use the current code, attempt to build it, and run its tests within the container. If you change the code (and not the container configuration), you only need to repeat this command.
docker run -v "$(pwd)":/usr/src -it cpp-container
This will:
- Clean previous builds
- Build the code from scratch
- Launch the tests
- Generate branch coverage report
Piece has four possible values: X,O,Invalid, and Blank
board
board is a 2D vector of Pieces that represents the playing board
Piece turn
turn represents whose turn it is to place a piece (defaults to X)
Piezas()
Constructor sets an empty board (3 rows, 4 columns) and specifies it is X's turn first
void reset();
Resets each board location to the Blank Piece value, with a board of the same size as previously specified
Piece dropPiece(int column)
Places a piece of the current turn on the board, returns what piece is placed, and toggles which Piece's turn it is. dropPiece does NOT allow to place a piece in a location where a column is full. In that case, placePiece returns Piece Blank value Out of bounds coordinates return the Piece Invalid value. Trying to drop a piece where it cannot be placed loses the player's turn
Piece pieceAt(int row, int column)
Returns what piece is at the provided coordinates, or Blank if there are no pieces there, or Invalid if the coordinates are out of bounds
Piece gameState()
Returns which Piece has won, if there is a winner, Invalid if the game is not over, or Blank if the board is filled and no one has won ("tie"). For a game to be over, all locations on the board must be filled with X's and O's (i.e. no remaining Blank spaces). The winner is which player has the most adjacent pieces in a single line. Lines can go either vertically or horizontally. If both X's and O's have the same max number of pieces in a line, it is a tie.