Drawing balls of an urn, probability of one colour run out (with replacement) I am trying to solve a probability problem but I do not manage to figure out a solution. I implemented the problem in C++ to convince myself of a solution but it didn't help (btw it shows that some colors run out with a low probability) Here is the problem:
"In a Urn, there are 17 red balls, 15 blue balls and 13 yellow balls. Each time randomly pick two balls, if they are in the same color, return both of them to the urn, if they are in different colors, they replace them with 2 balls in the third color. Will we run out of one of the color of balls?"
If you have any hint to help. I would be glad to hear any of them.
Thank you
EDIT: (Thanks to Daniel Mathias, adding a precision on the different outcomes: each state can still remain unchanged)
Can we take an example with smaller numbers of balls and extend it to the previous problem?
Let's say we have 1 red ball; 3 blue balls and 5 yellow balls. Then we have the couple 
(1,3,5) -- state 0 
The different outcomes of the state 0 are: 
(0,2,7) -- game ends
(0,5,4) -- game ends
(3,2,4) -- state 1
(1,3,5) -- return state 0
Then the outcomes of the state 1 are:
(5,1,3) -- return state 0
(2,4,3) -- return state 1
(2,1,6) -- state 2
The outcomes of the state 2 are:
(4,0,5) -- game ends
(1,0,8) -- game ends
(1,3,5) -- return state 0
Then it is clear that the probability of one of the color of balls runs out is different from 0.
 A: Since the problem statement does not say how many times you can remove and replace balls, presumably the question is about the likelihood that you can keep on doing this forever without running out of any color.
If the numbers of balls of each color are $(n - 2, n, n + 2)$ at the start,
then it will always be true that there is at least one color with $n$ balls or fewer.
(Actually there will always be a color with $n-1$ balls or fewer, but that's a stronger statement than we need so I won't take the trouble to prove it.)
If there are $n$ or fewer balls of one color, there is at least an
$\frac{2^nn!}{(3n)^n}$ probability that the next $n$ moves will reduce the number of balls of that color to zero.
Hence there is at most a $1 - \frac{2^nn!}{(3n)^n}$ probability that all three colors are still in the urn after $n$ moves.
Now consider the probability you still have all three colors after $2n$ moves,
or after $3n$ moves.
With these considerations you should be able to put an upper bound on the expected number of moves until one color has run out.
More to the point, you should be able to put a lower bound on the probability that you run out of one color in some finite number of moves.
A: We have the starting conditions
$$
\left\{ \matrix{
  R(0) = 17 \hfill \cr 
  B(0) = 15 \hfill \cr 
  Y(0) = 13 \hfill \cr 
  T = 45 \hfill \cr}  \right.
$$
and the total number $T$ is stable along the process.
We then have
$$
\eqalign{
  & 1 = {{\left( {R(n) + B(n) + Y(n)} \right)^2 } \over {T^2 }} =   \cr 
  &  = {{R(n)^2  + B(n)^2  + Y(n)^2 } \over {T^2 }} + 2{{R(n)B(n) + R(n)Y(n) + B(n)Y(n)} \over {T^2 }} \cr} 
$$
and the probability to choose two different colors is
$$
P_{XY} (n) = 2{{X(n)Y(n)} \over {T^{\,2} }}\quad \left| {\;X \ne Y} \right.
$$
According to the rules governing the process,  the expected number of 
red balls at step $n$ will be:
$$
\eqalign{
  & R(n + 1)
 = R(n) + 2 \cdot 2 \cdot {{B(n)Y(n)} \over {T^{\,2} }} - 1 \cdot 2 \cdot {{R(n)Y(n)} \over {T^{\,2} }} - 1 \cdot 2 \cdot {{R(n)B(n)} \over {T^{\,2} }} =   \cr 
  &  = R(n) + 4 \cdot {{B(n)Y(n)} \over {T^{\,2} }} - 2 \cdot {{R(n)\left( {T - R(n)} \right)} \over {T^{\,2} }} =   \cr 
  &  = R(n)\left( {1 - 2{{\left( {T - R(n)} \right)} \over {T^{\,2} }}} \right) + 4 \cdot {{B(n)Y(n)} \over {T^{\,2} }} =   \cr 
  &  = R(n)\left( {{{\left( {T - 1} \right)^{\,2}  + 2R(n) - 1} \over {T^{\,2} }}} \right) + 4 \cdot {{B(n)Y(n)} \over {T^{\,2} }} \cr} 
$$
It is easy to see that $R(n)=B(n)=Y(n)=T/3$ is an equilibrium point.
However we cannot reach it from the starting configuration.   
In fact, let's take one color (e.g. Y) as reference.
Along the process the difference $B-Y$ either increases/decreases by $3$ or remains stable. 
So, starting from $2$ we cannot null it. Same for the other. Thus, given the starting data, no two colors will attain the same amount
at any step in the process.
It is also clear that there are particular paths that will lead to
empty the urn from one of the colors:
it is sufficient to have a repeated sequence of $XY$ choices to
reach and get empty the color (X or Y) which has the minimum
presence.   
And if we could start from a position in which the two colors are in the same amount,
then we can erase both of them. But as said, this is not the case with the given starting configuration.
A: Here are some charts drawn from the results of my simulations. The x-axis is the number of draws. The y-axis is the probability of running out of some color in fewer than $x$ draws. The first shows up to one million draws, the second up to two million draws, and the third up to five million draws.

Edit: This chart was drawn from calculated values. I would be interested in finding a function that fits the data.

