public void Set(Position position, PieceType piece) { // Remove a piece. if (piece.Equals(PieceType.Empty) && !_data[position.Row, position.Col].Equals(PieceType.Empty)) { _pieceCount--; } // Place a piece. else if (!piece.Equals(PieceType.Empty) && _data[position.Row, position.Col].Equals(PieceType.Empty)) { _pieceCount++; } _data[position.Row, position.Col] = piece; }
/** * Get the piece type of the piece being promoted. * Always a Queen. TODO: Underpromotion. */ private PieceType getPromotion(PieceType piece) { if (piece.Equals(PieceType.p)) { return PieceType.q; } else { return PieceType.Q; } }