Determine the final stage of a game Peter and Chris are playing a game. At the beginning, each of them has some balls, where each ball is red, blue, or green. There is also a ball pool which contains more than enough balls of each colour for Peter and Chris to draw.
Peter and Chris take turns to move, and Peter moves first. After each turn, if Peter has exactly one ball and Chris has none, the game will end immediately.
Each move consists of the following steps:

*

*If the player has less than two balls, he draws red balls from the pool until he has two.
The player chooses two of his balls and throws them into the pool.

*If the two chosen balls are of the same colour, the opponent player gets from the pool one ball of the same colour. Otherwise the opponent player gets from the pool one ball of colour different from the colours of both chosen balls.

For example, if Peter chooses two red balls, Chris will get a red ball from the pool. If Peter chooses a red ball and a blue ball instead, Chris will get a green ball from the pool.
Determine the colour of Peter's final ball, given $R_1, G_1, B_1, R_2, G_2, B_2$.
$R_1, G_1, B_1$ represent the number of red, green and blue balls, respectively, that Peter has at the beginning of the game.
$R_2, G_2, B_2$ represent the number of red, green and blue balls, respectively, that Chris has at the beginning of the game.
The answer claims that if $$(G_1 + B_2 - B_1 - G_2) \equiv 0 (\mod 3)$$, then the final ball is in red, if the same expression $\equiv 1 (\mod 3)$ then the final ball is green. Otherwise, it will be in blue.
I cannot wrap my head around it for a while, can anyone explain this to me please? Thanks in advance.
 A: Let $g_1(n)$ be the number of green balls that Peter has after $n$ moves have been played, $g_2(n)$ the number of green balls that Chris has after $n$ moves have been played, $b_1(n)$ the number of blue balls that Peter has after $n$ moves have been played, and $b_2(n)$ the number of blue balls that Chris has after $n$ moves have been played. By examining the six possibilities you can show that
$$g_1(n+1)+b_2(n+1)-b_1(n+1)-g_2(n+1)\\
=g_1(n)+b_2(n)-b_1(n)-g_2(n)\tag{1}$$
no matter what move is made. For example, suppose that $n$ is even, so that it is Peter’s turn to move, and Peter chooses a blue and a red ball. Chris gets a green ball, so
$$b_1(n+1)=b_1(n)-1$$
and
$$g_2(n+1)=g_2(n)+1\,,$$
and $(1)$ holds. This implies that
$$g_1(n)+b_2(n)-b_1(n)-g_2(n)\\
=g_1(0)+b_2(0)-b_1(0)-g_2(0)\tag{2}$$
Say that the game ends after $m$ moves. At that point Chris has no balls, so $b_2(m)=g_2(m)=0$, and $(2)$ tells us that
$$g_1(m)-b_1(m)=g_1(0)+b_2(0)-b_1(0)-g_2(0)\,.$$
If you now use the fact that Peter has exactly one ball at this point, you should be able to finish the argument from here.
