Following Guess your hat color, but you don't have to and it's interpretation via Covering codes I tried to create a puzzle with more hat variativity, i.g. 3 types of hats.
4 hats are put on 4 logicians, each hat color is selected randomly: Red, Green or Blue.
As usual, every logician doesn't see the hat on his own head, but sees the rest. They cannot communicate in any way possible.
Each logician at the same moment must answer the question - "what color is the hat on your head?". And there are only 3 possible answers they can say: "Red", "Green", "Blue" and "I don't know".
If at least one color is named incorrectly logicians fail and die. If no one named a correct color they die just the same. Otherwise (if at least one answer is correct) - logicians survive.
As usual, they have time to discuss a strategy before the hats are put on their heads.
What's the strategy, which gives the highest probability to survive?
I picked number of logicians $N=4$ and number of colors $M=3$, because these are the numbers a generalized covering code exists for ($N=(3^2-1)/2$, see wiki). There by the puzzle solution:
Logician number themselves with 2D vectors:
$L_1 = (0,1)$;
$L_2 = (1,0)$;
$L_3 = (1,1)$;
$L_4 = (1,2)$.
And colors with integers:
$c_{red} = 0$;
$c_{green} = 1$;
$c_{blue} = 2$.
They calculate a sum S of all hats as $\sum(c_i \cdot L_i) \mod 3$. For example, if hats are like GRRB, then $S = [ (0,1)+0+0+2*(1,2) ] \mod 3 = (2,5) \mod 3 = (2 \mod 3,5 \mod 3) = (2,2)$
With each hat placement there will be exactly one person who is not sure whether $S = (0,0)$ or not. And logicians agree that only that person may speak. And that they must always assume that $S \neq (0,0)$ and name the color appropriately - randomly choosing one of the two colors.
Due to the fact that 8 non-zero combinations: $1\cdot L_i$ and $2\cdot L_i$ cover all 8 possible non zero vectors $(0,1); (0,2); (1,0); (1,1); (1,2); (2,0); (2,1); (2,2)$ the sum $S$ can take all $9$ possible results with the same probability of $1/9$. Thereby the logicians lose for sure in $1/9$ of the cases when $S=0$ and they win with probability of $50\%$ in the rest of the cases. Giving survival probability of $P_{survival} = 4/9$.
That's all good, but the probability is much less than expected. The upper estimate of survival probability is $P_{survival} \le N/(N+M-1) = 2/3$. Here is why:
For each situation a specific person speaks up their color there will be 1 hat distribution where they are correct and $M-1$ hat distributions where they are wrong. To survive they need at least one person to speak. When they die there can be $N$ speaking logicians at most. Thereby
$K_{goodDisctributions} \cdot (M-1) \le N \cdot K_{deadlyDistributions}$,
$K_{goodDisctributions} / K_{deadlyDistributions} \le N / (M-1) $,
$P_{survival} = K_{goodDisctributions} / (K_{goodDisctributions} + K_{deadlyDistributions}) \le N / (N+M-1)$
This number was achievable in the similar cases for $M=2$ (when $N=2^k-1$). But now I have no idea how to achieve it. Thereby two questions:
Is there a solution for the mentioned puzzle ($N=4$, $M=3$) with probability $P_{survival} > 4/9$?
Is there a combination of $N\ge 2$ and $M\ge 3$ where $P_{survival} = N/(N+M-1)$ is achiavable?
Edit:
@tehtmi answer proves that $P_{limit} = N/(N+M-1)$ is not achievable. I've rewarded this proof with a bounty. Now I want to reward the best strategy with a bounty.
@Reinier's strategy gives (if I've not messed up the calculations)
$P=16/27 \approx 59.3\%$ for $N=4,M=3$,
$P=55/81 \approx 67.9\%$ for $N=5,M=3$,
$P=17/32 \approx 53.1\%$ for $N=4,M=4$,
$P=75/128 \approx 58.6\%$ for $N=5,M=4$
Is there a better strategy for any of those cases?