4. In a chess tournament, $n$ players participate in a round-robin competition. After players A and B each played two games, they withdrew from the competition due to certain reasons. It is known that a total of 81 games were ultimately played. Then $n=$ $\qquad$ .
4. 15 .

If there is no match between A and B, then
$$
\mathrm{C}_{n-2}^{2}+2 \times 2=81 \text {, }
$$

this equation has no positive integer solution.
If A and B have a match, then
$$
\mathrm{C}_{n-2}^{2}+3=81 \Rightarrow n=15 .
$$