/*
 * Faculty of Applied Science and Engineering, University of Toronto
 * CSC181: Introduction to Computer Programming, Fall 2000
 *
 * File: rtournament.h
 * Contains: Interface for RTBoard Connect Four class (for tournament
 * play).
 * Author: Ray Ortigas (rayo@dgp.toronto.edu)
 */

#ifndef RTOURNAMENT_H
#define RTOURNAMENT_H

#include <iostream.h>
#include "tournament.h"

/*
 * Represents a Connect Four board. A simple array-based 
 * implementation of TBoard interface.
 */
class RTBoard : public TBoard {
private:
	// The Red player for this board.
	TPlayer* red;

	// The Black player for this board.
	TPlayer* black;

	// The grid of squares on this board. Each square is
	// represented by a pointer, which can take on one of three
	// possible values: the red pointer, indicating that a Red
	// piece occupies the square; black, indicating that a Black
	// piece occupies the square; and 0 (the null pointer),
	// indicating that no piece occupies the square.
	TPlayer* board[T_NUM_ROWS][T_NUM_COLUMNS];

	// The number of pieces in each column. columnCounts[c] is
	// the number of pieces in column c.
	int columnCounts[T_NUM_COLUMNS];

public:
	/*
	 * Constructs a new RTBoard with Red player rp and Black
	 * player bp.
	 */
	RTBoard(TPlayer* rp, TPlayer* bp);

	/*
	 * Copy constructor.
	 */
	RTBoard(const RTBoard& b);

	// ------------------------------------
	// INHERITED METHODS (See TBoard class)
	// ------------------------------------
	TBoard* clone() const;
	TPlayer* getRed() const;
	TPlayer* getBlack() const;
	TPlayer* getPiece(int r, int c) const;
	TPlayer* getPiece(const TPosition& p) const;
	int countRed(const TPosition ps[], int n) const;
	int countBlack(const TPosition ps[], int n) const;
	TPlayer* getWinner() const;
	bool isLegalMove(int c) const;
	bool hasLegalMoves() const;
	void dropPiece(TPlayer* p, int c);
	TPlayer* removeTopPiece(int c);
};

/*
 * Outputs a string representation of b to os.
 */
ostream& operator<< (ostream& os, const TBoard& b);

#endif
