coloured hat puzzles

Puzzles about a group of people wearing different coloured hats, in which the objective is to determine when someone will be able to deduce the colour of his or her hat. The original puzzle of this type is:

A king captures three prisoners and tells them "I have here three white hats and two black hats. I will blindfold you and put a hat on each of your heads, without letting you know what colour your hat is. Then I will remove the blindfolds so that you can all see each other's hats but not your own, and if you see a white hat, you must raise your hand. The first one who can prove logically (not just guess) that he is wearing a white hat will go free." The king puts a white hat on all three prisoners' heads, and all three raise their hands. After a while, the smartest prisoner figures out that his hat must be white. How did he know?

Answer: call the prisoners A, B and C, with C being the smartest. C thinks "If my hat were black, then A would know that his hat was white, because otherwise B wouldn't have raised his hand. (B would also know that his own hat was white, for the same reason.) Since A and B haven't said anything, my hat must be white."

This puzzle is not very well specified, because it requires the prisoners to make guesses about each other's reasoning skills. A better version of the same puzzle is if three people sit in a column, with C at the back, B in front of her, and A at the front, so that C can see A and B's hats, B can only see A's hat, and A can't see any hats. Again, there are three white hats and only two black hats, and each person is wearing a white hat. This time everyone is a perfect logician and knows that the others are perfect logicians too. We ask each person in turn, starting with C, "Do you know the colour of your hat?" C doesn't, and nor does B, but A does - she reasons that if her hat had been black, B would have known that his hat must be white, because otherwise C would have seen two black hats and would have known that she was wearing a white hat.