A Combinatorial Approach to Ebert's Hat Game with Many Colors

This paper proves an optimal strategy for Ebert's hat game with three players and more than two hat colors. In general, for n players and k hat colours, we construct a strategy that is asymptotically optimal as k → ∞. Computer calculation for particular values of n and k suggests that, as long as n is linear with k, the strategy is asymptotically optimal. We conclude by comparing our strategy with the strategy of Lenstra and Seroussi and with the bound of Alon, and suggest our strategy is better when 2k n 7. There have been several different versions of hat games and various generalizations of the games' rules. For example, the paper [1] discusses the " hybrid " hat game that combines rules from a hat game where players stand on a single line and the Ebert's hat game, with the generalization on the number of hat colors. In this paper, we will focus on Ebert's hat game, and the generalization on the number of possible hat colors. The simple version of Ebert's hat game is stated as follows [2]: three players walk into a room and each of them is given a hat. Each hat is either red or blue, and the probabilities of the colors of each of the three hats are equally and independently distributed. Each player can see the colors of the other players' hats but cannot see the color of his own hat. No communication of any type is allowed after the players walk into the room. After each player looks at the other players' hats, each of them has to guess the color of his own hat or pass. Each player does not know what the other players' responses are. They win collectively if at least one of the players guesses the color of his own hat correctly and no other player guesses incorrectly. Otherwise (if at least one player guesses incorrectly or everyone passes), they lose. Before the three players walk into the room and receive


The Problem
There have been several different versions of hat games and various generalizations of the games' rules. For example, the paper [1] discusses the "hybrid" hat game that combines rules from a hat game where players stand on a single line and the Ebert's hat game, with the generalization on the number of hat colors. In this paper, we will focus on Ebert's hat game, and the generalization on the number of possible hat colors.
The simple version of Ebert's hat game is stated as follows [2]: three players walk into a room and each of them is given a hat. Each hat is either red or blue, and the probabilities of the colors of each of the three hats are equally and independently distributed. Each player can see the colors of the other players' hats but cannot see the color of his own hat. No communication of any type is allowed after the players walk into the room. After each player looks at the other players' hats, each of them has to guess the color of his own hat or pass. Each player does not know what the other players' responses are. They win collectively if at least one of the players guesses the color of his own hat correctly and no other player guesses incorrectly. Otherwise (if at least one player guesses incorrectly or everyone passes), they lose. Before the three players walk into the room and receive hats, they may plan a strategy of responses. The question is: What is the best strategy to optimize the chance of winning?
In this paper we will use n as the number of players and k as the number of colors in Ebert's hat game. The simple version above (n = 3 and k = 2) has a proven optimal strategy with a winning probability of 3/4. 1 In fact, for k = 2 and n = 2 m − 1 for some positive integer m > 1, there is a proof of the optimal strategy [5]. The solution when n = 2 m − 1 is tied closely with the particular structure of the set of losing positions known as the 1-error-correcting binary Hamming Code. The question is: what about when k > 2?
In this paper, we will show, with a combinatorial optimization proof, the optimal strategy for Ebert's hat game with n = 3 and k > 2. (The case n = 1 is trivial. For n = 2, fix one color c 0 . The strategy is to instruct each player to guess c 0 if he does not see c 0 , and pass otherwise. It is easy to show that the strategy is optimal with the winning probability 2(k − 1)/k 2 .) There has been a construction of strategy for Ebert's hat game with three players and k colors [3]. With the case k = 3, that strategy is proved to be optimal in [3]. However, it was not known whether that strategy is optimal for any k > 3. We will show in this paper that the strategy is indeed optimal.
Furthermore, we will construct a strategy for general n and k, and compare the winning probability of that strategy with Lenstra and Seroussi's strategy [5] and Alon's lower bound [4,Theorem 7.1]. Computer search suggests that our strategy has a higher winning probability when 2k n 7 than Lenstra and Seroussi's strategy and Alon's bound. We discuss that Lenstra and Seroussi's strategy and Alon's bound are not preferable in the case k being linear with n. We prove an upper bound for the probability of winning of nk n −1 n+k−1 /k n , and we show that our strategy's winning probability approaches this bound for fixed n while k approaching infinity. In addition, computer calculation leads to a conjecture that in the case k being linear with n, and we let n → ∞, then the probability of winning still approaches this same upper bound.

Three Players and more than Two Colors
Let k > 2 be a positive integer. Label the colors 1, 2, . . . , k. In the 3-player Ebert's hat game, each player receives a hat from among the k equally probable colors. Let S = {(a, b, c) : a, b, c ∈ {1, 2, 3, . . . , k}} represent all equally probable k 3 outcomes of hat colors distributed among three players. The first number in a triple represents the color of the first player's hat, and so on.
For a given strategy, let X ⊆ S be the set of all losing positions, and W ⊆ S be the set of all winning positions. Each possibility will be either a winning or losing position (A typical strategy that instructs a player to definitely do a certain action is called a deterministic strategy. A strategy that instructs a player to do one of more than one possible responses according to the given probabilities (a non-deterministic strategy) will give a winning probability as a linear combination of other deterministic strategies. It therefore is sufficient to consider only all possible deterministic strategies [5]). Therefore, (X, W ) is a partition of S. Also, any given strategy will determine the sets X and W . Definition 1. A line is a set of k triples in S all of which have the same coordinates in two dimensions. For example, {(1, 3, 4), (2,3,4), . . . , (k, 3, 4)} and {(1, 1, 4), (1,2,4), . . . , (1, k, 4)} are both lines.
Definition 2. For each w ∈ W , a line consisting of k − 1 losing positions and w is called a supporting line of w. If there can be more than one supporting line for w, pick only one to be a supporting line for w.
The following theorem is the same as the Claim in [4, Section 7], but we quote it in terms of a supporting line.
Theorem 3. The given partition of S into X and W will represent a possible strategy if and only if each w ∈ W has a supporting line.
Because of Theorem 3, from now on it is sufficient to maximize the size of W subject to the condition that for each w ∈ W , there exists a line consisting of k −1 losing positions and w.
We consider the strategy as appeared in [3,Subsection 29.4], which satisfies |W | = 3k 2 − 6k + 6, and now demonstrate that this strategy is optimal.
Assume that there exists a possible strategy corresponding to a pair (X, W ) such that |W | 3k 2 − 6k + 7. If |W | 3k 2 − 6k + 8, we can choose one of the winning positions and turn that into a losing position. The new pair (X, W ) will still hold the condition that for each w ∈ W , there exists a line consisting of k − 1 losing positions and w. Therefore, it is sufficient to consider only when |W | = 3k 2 − 6k + 7 and prove that |W | = 3k 2 − 6k + 7 is impossible. Assume |W | = 3k 2 − 6k + 7. Since |W | + |X| = k 3 , we have |X| = k 3 − 3k 2 + 6k − 7. Let L be the set of all 3k 2 − 6k + 7 supporting lines in this strategy. Let Since each w ∈ W has exactly one supporting line, which corresponds to exactly k − 1 elements in C, |C| = (k − 1)|W |. Let x ∈ X, l is a line, and x ∈ l} − C Then, M and C are disjoint, and we get since any position in S is contained in exactly three different lines. We split the S into k planes P 1 , P 2 , P 3 , . . . , P k , where Let a i denote the number of losing positions in P i . For any a i ∈ {0, 1, 2, . . . , k 2 }, let h(a i ) denote the minimum possible size of M i given that there are a i losing positions in that plane i. We will find a lower bound for k i=1 h(a i ) subject to the condition k i=1 a i = total number of losing positions = k 3 − 3k 2 + 6k − 7. We state several Lemmas in order to find the bound. Lemmas 4, 5, 6, 8, and 9 below are stated with the detailed proofs and calculations deferred to Appendix A.
Intuitively, this is because having "too many" losing positions will not give enough spaces for winning positions to use supporting lines formed within that plane.
For each m ∈ {0, 1, 2, . . . , 2(k − 1)}, let f (m) denote the minimum number of losing positions in the plane that is needed to generate m supporting lines in that plane.
The idea is to try to let as many losing positions as possible to be in two supporting lines.
For each a i ∈ {0, 1, 2, . . . , (k − 1) 2 }, let g(a i ) denote the maximum possible number of supporting lines in the plane that can be created given that there are a i losing positions in that plane.
Lemma 6. For all a i ∈ {0, 1, 2, . . . , (k − 1) 2 }, The lemma can be proved using f (a i ) in Lemma 5. We now show how defining g(a i ) may help us to find h(a i ).
Proof. Each losing position increases the size of T i by 2, and each supporting line in the plane P i corresponds to k − 1 ordered pairs in C which decreases the size of M i by k − 1.
Now, we use these Lemmas to finally find a lower bound for k i=1 h(a i ) subject to two conditions: This can be done by translating h(a i ) into g(a i ) term and give an upper bound to the sum Note that we split the entire cube S into k planes P 1 , P 2 , P 3 , . . . , P k in order to obtain the lower bound on k i=1 h(a i ). However, we could have done the splitting in two other similar ways but in different orientations of the cubes. Applying similar idea of Lemma 8 to all three ways of splitting and using double counting argument, we get the bound for |M |: We are now ready to state the main result in this section, namely that the strategy for winning Ebert's hat game in [3, Subsection 29.4] is optimal.

The General Case
We now consider Ebert's hat game with more than three players. First, we will look at the case where 2k n: in other words, we have a large number of colors relative to the number of players.

Case 2k n:
Label the colors 1, 2, 3, . . . , k. Consider a symmetric strategy as follows: For i = 1 to k, if a player does not see a hat of color i, guess i. If a player sees one hat of color i, pass. If a player sees two or more hats of color i, increment i and repeat the process. Now, we will find the winning probability from this strategy. Let be the set of all k n possibilities of colors of n hats, where c i represents the color of the hat of player i.
Definition 11. Let c = (c 1 , c 2 , c 3 , . . . , c n ) ∈ S. Let d j be the number of appearances of color j in c 1 , c 2 , . . . , c n . Then, c has property P 0 if 1 appears before 0 in the sequence Theorem 12. An element (c 1 , c 2 , c 3 , . . . , c n ) ∈ S is a winning position according to the strategy described above if and only if (c 1 , c 2 , c 3 , . . . , c n ) satisfies the property P 0 .
Proof. First, suppose an element c ∈ S has the property P 0 with the least positive integer i appears exactly once. It is clear to see that the player with hat color i will guess correctly and the rest will pass. Hence, the team will win. Second, suppose we have an element c ∈ S that does not satisfy the property P 0 . Let i be the least positive integer that does not appear more than once. Since i does not appear, any player with a hat color d > i will incorrectly guess color i, so the team will lose. If there is no player with a hat color d > i, i.e. 2k = n and each color appears two times, every player will pass, and the team will lose.
Theorem 13. The number of winning positions in the strategy we constructed (where 2k n) is Proof. The number of winning positions of the strategy is equal to the number of elements in S that has the property P 0 . In order to count that, we will use generating functions. The degree of the term will represent the length of the string of numbers constructed. The factorial in the denominator of a term represents all permutations of the same numbers being considered the same. Therefore, the number of elements satisfying P 0 with i being the least positive integer that appears once is the coefficient of the term x n n! in . Thus, the total number of elements the electronic journal of combinatorics 21(4) (2014), #P4.33 Since e x − x − 1 has only terms with degree at least 2, (e x − x − 1) k has only terms with degree at least 2k. Therefore, the term (e x − x − 1) k in the expression (3.1) will only contribute terms with degree at least 2k + 1, which, from 2k n, is at least n + 1. However, we consider only the term of degree n, so we can neglect (e x − x − 1) k . The expression then becomes Case 2k < n: A more general strategy is as follows: For i = 0 to n−1 2k : For j = 1 to k: if a player sees exactly 2i hats of color j, guess j. If a player sees exactly 2i + 1 hats of color j, pass. Else, go to the next case.
The following definition is the natural generalization of P 0 .
Definition 14. Let c = (c 1 , c 2 , c 3 , . . . , c n ) ∈ S. Let d j be the number of appearances of color j in c 1 , c 2 , . . . , c n . Then, for each non-negative integer i, c has property P i if d j 2i for all j, and 2i + 1 appears before 2i in the sequence d 1 , d 2 , . . . , d k .
Analogously to Theorem 12, we can prove that the sequence of n integer will represent a winning position if and only if that sequence satisfies P i for some i. The number of sequences in which every integer appears at least 2i times, and the least integer j ∈ {1, 2, 3, . . . , k} which appears no more than 2i + 2 times appears exactly 2i + 1 times is the electronic journal of combinatorics 21(4) (2014), #P4.33 The total number of winning positions then is the coefficient of With some computation, we deduce that the number of winning positions is the coefficient (2) This expression may be more helpful when is used by computer to calculate the exact coefficient of x n−1 n! .

The Behavior of the Constructed Strategy
In this paper, the symbol ∼ means that the ratio of quantities in the left and right is approaching one. Before we start, consider the simple upper bound for |W |. The bound |W | nk n n+k−1 is stated in [5] and [3], and proved in [3]. Proposition 5 in [5, Subsection 3.1] implies that there is no strategy which gives |W | to be exactly nk n n+k−1 for any k > 2. The paper, however, does not include the proof of that proposition. The following theorem can be used to prove both the bound and the proposition.  We get |M | = n|X| − |C|. Since each winning position will be counted exactly k − 1 times in C, we have Now, suppose |M | = 0. Then, |X| = k n − |W | = (k−1)k n n+k−1 . We split S into k n−2 nonintersecting planes P 1 , P 2 , . . . , P k n−2 , and let a i be the number of losing positions in the i th plane. Because |M | = 0, we must have h(a i ) = 0 for all i = 1, 2, 3, . . . , k n−2 (here we use the same definition for M i , T i , and h as in the proof of the 3-player game). However, h(a i ) = 0 if and only if a i = 0 or (k − 1) 2 . Therefore, |X| = k n−2 i=1 a i must be a multiple of (k − 1) 2 . We have (k − 1) 2 | |X|, which is the same as (k − 1) 2 | (k−1)k n n+k−1 . This gives k − 1 | k n , and so k − 1 | 1. But for all k > 2, this is impossible. Therefore, |M | 1. This gives From the last section, we have a construction of the strategy with We will investigate the ratio of |W | from this construction to the upper bound nk n −1 n+k−1 . Some values are shown in Table 1. More samples are shown in Appendix B.
One observation is that the ratio gets close to 1 as k grows. The computation suggests that for n 50, one need k n/2 for the probability to be at least 99% of the simple upper bound, and as n grows, the ratio k/n we need to attain the same 99% ratio seems to get smaller. Below is the mathematical proof that the strategy indeed is asymptotically optimal as k → ∞.    Proof. Because n is fixed and k is growing, we can assume 2k n and use |W | = n! n−1 i=0 (−1) n−1+i k i i! . Then, As k → ∞, since both numerator and denominator are a polynomial of variable k of degree n, we only need to take ratio of the coefficients of the leading terms k n . Thus, The upper incomplete gamma function is defined as Γ(n, −k) = ∞ −k t n−1 e −t dt. When n is a positive integer, by induction on n, Γ(n, −k) is equal to (n − 1)!e k n−1 i=0 (−k) i i! . Therefore, |W | = n! n−1 i=0 (−1) n−1+i k i i! can be written as |W | = n(−1) n−1 e −k Γ(n, −k). Then, Theorem 16 can also be viewed as the asymptotic behavior of the incomplete gamma function Γ(n, −k) as n is fixed and k → ∞.
We also investigate the asymptotic behavior in the case when k is linear with n. Table  2 and 3 provide some evidences that the ratio |W |/ nk n −1 n+k−1 still approaches 1 as n → ∞, which lead us to Conjecture 17.
Conjecture 17. As long as k αn, for some fixed positive real α, then as n → ∞, The convergence seems to be slower if α is closer to 0. If we constrain this conjecture only with α 1/2, we can look at the conjecture in two other perspectives: the electronic journal of combinatorics 21(4) (2014), #P4.33 1. From the conjecture |W | = n! n−1 i=0 (−1) n−1+i k i i! ∼ nk n n+k , multiply by −1, add k n , and then divide by n! to both sides. The conjecture is then equivalent to the approximation of a finite alternating exponential series: The approximation of a finite alternating exponential series seems to be more precise than to think about Taylor series expansion of e −k , since the next term of the Taylor series k n+1 (n+1)! α(αe) n √ 2nπ (from Stirling's approximation) which bounds the error grows to infinity.
2. From |W | = n(−1) n−1 e −k Γ(n, −k), the statement |W | ∼ nk n n+k is equivalent to |Γ(n, −k)| ∼ e k k n n + k This last statement may be further investigated whether it still holds for general n, k in some real and/or complex domain. Now we will compare the combinatorial strategy constructed in this paper to Lenstra and Seroussi's and Alon's bound. Specifically, we want to know in what case our strategy will have higher winning probability and observe asymptotic behaviors in the case k = αn for some α > 0 as well.

Comparison with Lenstra and Seroussi's strategy
Lenstra and Seroussi's strategy [5] is constructed using the algebraic method and matrix multiplication so that the probability of winning 1 − 1 − 1 k log 2 (n+1) approaches 1 as n → ∞. However, as k grows, even moderately around a hundred, the probability goes down rapidly. In other words, the strategy is good for big n, but not with big k, whereas the combinatorial strategy in this paper works well for big k. Examples of performance of this strategy is shown in Table 5 in Appendix B.
Conjecture 18. When 2k n 7, the winning probability of the combinatorial strategy in this paper is greater than Also, if 2k is still "close enough" to n, such as when n = 50 and k = 10 or 20, the winning probability from combinatorial construction seems to be greater as well. How exactly "close" it should be is still unknown. If we have k = αn for some α > 0, then as n → ∞, the ratio will converge to 0 because 1 − 1 αn log 2 (n) converges to 1.

Comparison with Alon's bound
Alon's paper [4] uses a probabilistic argument to show an existence of a strategy with probability of winning at least 1 − m( k−1 k ) n − 1 n , where m = k n log n (k−1) n−1 n . The bound obtained is good for the asymptotic behavior n → ∞, which is even better than Lenstra and Seroussi's when n is big enough. For example, roughly n 500 for k = 3. Again, the strategy however does not work well when k grows. Examples of performance of this strategy is shown in Table 6 in Appendix B.
Theorem 19. When 2k n 7, the winning probability of the combinatorial strategy in this paper is greater than 1 − k n log n 1 − (n − 2) log n + 2 2n The last expression is a function of n, where after n ≈ 9.61, will be less than 0. For n = 7, 8, 9, we can compute directly that the statement is true.
As we can see from the proof in Theorem 19, Alon's bound itself does not give any information for k 2n. In fact, for any α > 0, if k αn (k linear with n) and n → ∞, the bound still eventually will not be useful. This is because (k−1) log n+1 n will asymptotically behave to be at least α log n, and so the term (3) will become negative as n grows.

Conclusion
It is interesting to see how different approaches solve the same hat problem. The combinatorial approach seems to work well with low values of n and big values of k, and with asymptotically when k αn for some α > 0. In fact, the strategy seems to approach the proven upper bound. In contrast, when n gets bigger, for example when n is much bigger than 2k, or when n → ∞ while k is fixed, Lenstra and Seroussi's and Alon's strategies may be better alternatives. Between Lenstra and Seroussi's and Alon's strategies, when n → ∞ with fixed k, Alon's bound converges closer to 1, with the exception of some moderate values of n.
the electronic journal of combinatorics 21(4) (2014), #P4.33 in the same plane using those (k − 1)-by-(k − 1) losing positions. Since equality can be Second, h((k − 1) 2 ) = 0 because we can arrange (k − 1) 2 losing positions in a (k − 1)by-(k − 1) square in a plane and let 2k − 2 winning positions in the plane adjacent to that square have supporting lines in the same plane using those (k − 1)-by-(k − 1) losing positions. The last winning position (i, k, k) may have supporting line that does not lie in plane i. Third, when 0 a i (k − 1) 2 − 1, because a newly added losing position to P i will increase the size of T i by only 2, and we can put a newly added losing position replacing a winning position that has supporting line not in P i . Thus, the size of M i cannot increase by more than 2. If the set of a i that minimizes k i=1 h(a i ) has some a j > (k − 1) 2 , let a t be an element in the set of a i that is less than (k − 1) 2 (such a t exists because k i=1 a i = k 3 − 3k 2 + 6k − 7 and k 3). We may create a new set of a i by reducing a j by 1 and increasing a t by 1. By (4) and (5), the new set of a i will have k i=1 h(a i ) less than or equal to the one with the old set of a i . We may keep doing this until no a j is greater than (k − 1) 2 .
Proof of Lemma 9. Recall when we split the entire cube S into k planes P 1 , P 2 , P 3 , . . . , P k , where P i = {(i, b, c) ∈ S : 1 b, c k}, and when we let However, we can also split the cube S into k planes in two other ways: the electronic journal of combinatorics 21(4) (2014), #P4.33 Using Lemma 8 similarly, we get k i=1 |N i | 4k − 10 and k i=1 |O i | 4k − 10. Each element in M = {(x, l) : x ∈ X, l is a line, and x ∈ l} − C will be counted exactly twice among sets M i , N i , O i because a line can be contained in exactly two different planes in P i , Q i , R i . Also, M i , N i , O i ⊆ M for all i = 1, 2, 3, . . . , k. Therefore,  Table 4 shows the ratio |W |/ nk n −1 n+k−1 of the combinatorial strategy constructed in this paper for several values of n, k.   Table 5 shows the ratio of probability of winning of Lenstra and Seroussi's strategy 1 − 1 − 1 k log 2 (n+1) to the upper bound nk n −1 n+k−1 /k n . In their paper [5], their strategy only works when n = 2 m − 1 for some positive integer m. Here we use 1 − 1 − 1 k log 2 (n+1) (from equation 5 in the paper) for general n only to see the big picture of comparison between winning probabilities of two strategies.   Table 6 shows the ratio of the lower bound of probability of winning in Alon's paper [4], 1 − k n log n (k−1) n−1 n ( k−1 k ) n − 1 n , to the upper bound nk n −1 n+k−1 /k n . Sometimes the lower bound 1 − k n log n (k−1) n−1 n ( k−1 k ) n − 1 n is less than 0, in which case we put 0 in the table instead.