What Hat Are You Wearing?

by Janice Kim on December 27, 2011

Perhaps you are familiar with logic puzzles involving hats. No? For example, imagine there are 10 prisoners and 10 hats. Each prisoner is assigned a random hat, either red or blue, but the number of each color hat is not known to the prisoners. The prisoners will be lined up single file where each can see the hats in front of him but not behind. Starting with the prisoner in the back of the line and moving forward, they must each, in turn, say only one word which must be “red” or “blue”. If the word matches their hat color they are released, if not, they are killed on the spot. A friendly guard warns them of this test one hour beforehand and tells them that they can formulate a plan together to help them survive within the given parameters. How many prisoners could you guarantee to save?

While I was thinking about hats, I thought about how it might relate to go, and outlined in broad strokes my new Hat Theory in the comments of the go game below.

[sgfPrepared id=”0″]


{ 6 comments… read them below or add one }

Harald January 3, 2012 at 5:06 am

Thank you! Very good comments that we all can learn from! Keep it up!


frodwith January 3, 2012 at 8:38 am

Very interesting way of looking at the game, not at all what I’m used to. We kyu players should try thinking about which hat we should be wearing in our upcoming games :)


Skymnolf January 3, 2012 at 8:44 am

Hello Ms. Kim,
Thanks for the lesson and for putting together this great blog. I think there might be a glitch though in the .sgf viewer. None of the moves for white are showing up on my screen. Just thought I’d let you know. Thanks again.


Denommus January 3, 2012 at 2:03 pm

One of the things I fing more confusing about go is when a movement is an attack and when it’s a defense. Could you make a post about it?


Eric Backus January 4, 2012 at 11:27 am

“How many prisoners could you guarantee to save?”

Hm. Guarantee is a pretty strong word. Assuming the friendly guard isn’t just making it all up, and assuming all 10 prisoners are incredibly smart and don’t screw up under pressure, I think 9 of the 10 could be guaranteed to be saved. But in real life, I’d probably opt for a simpler strategy that guarantees to save only 6 of them:

Group them into groups of 3. Within a group of 3, if the second two have the same color hat, the first one says “red”, else “blue”. The second one looks at the hat in front of him, and using his knowledge of what the first one said, figures out his correct hat color. The third one does the same based on the previous two responses. So, 2 of the 3 are guaranteed to be saved, and we have 3 groups of 3 so 6 are guaranteed to be saved.

Oh wait. This is supposed to be about go, right?

OK, thanks for the game review, it was a fun read and might even help my game.



John Harriman January 7, 2012 at 7:21 am

This question is about parity. And for the go tie in the first person sacrifices himself for everyone else.
Beforehand they decide that they will target an even number of red hats. If the first person sees an odd numbe rof red hats, he says “red” to create even parity of red hats seen, heard and said.
Each person does the same. If the total of red hats he he sees plus the number of times someone behind him says “red” is even, he says blue. If odd he says red.
First person sees RBBRBRRBB – 4 red and so says blue
second person sees BBRBRRBB – 3 red plus he heard blue (0 red so far), so he says red to maintain even parity.
3rd person sees BRBRRBB – 3 red plus he heard 1 red total = 4 so he says blue.
And so on.
So, we can expect 9 and sometimes 10 saved.


Next post: