  The following general variant of deterministic Hats game is analyzed. Several
sages wearing colored hats occupy the vertices of a graph, the $k$-th sage can
have hats of one of $h(k)$ colors. Each sage tries to guess the color of his
own hat merely on the basis of observing the hats of his neighbors without
exchanging any information. A predetermined guessing strategy is winning if it
guarantees at least one correct individual guess for every assignment of
colors.
  For complete graphs and for cycles we solve the problem of describing
functions $h(k)$ for which the sages win. We demonstrate here winning
strategies for the sages on complete graphs, and analyze the Hats game on
almost complete graphs. We develop "theory of constructors", that is a
collection of theorems demonstrating how one can construct new graphs for which
the sages win. We define also new game "Check by rook" which is equivalent to
Hats game on 4-cycle and give complete analysis of this game.
