There are $n{}$ wise men in a hall and everyone sees each other. Each man will wear a black or white hat. The wise men should simultaneously write down on their piece of paper a guess about the color of their hat. If at least one does not guess, they will all be executed.

The wise men can discuss a strategy before the test and they know that the layout of the hats will be chosen randomly from the set of all $2^n$ layouts. They want to choose their strategy so that the number of layouts for which everyone guesses correctly is as high as possible. What is this number equal to?
1. **Understanding the Problem:**
   - There are \( n \) wise men, each wearing either a black or white hat.
   - Each wise man can see the hats of all the others but not his own.
   - They must simultaneously guess the color of their own hat.
   - If at least one wise man does not guess, they will all be executed.
   - The goal is to maximize the number of layouts for which everyone guesses correctly.

2. **Analyzing the Constraints:**
   - The total number of possible hat layouts is \( 2^n \) since each of the \( n \) wise men can have either a black or white hat.
   - Each wise man has a \( \frac{1}{2} \) chance of guessing his hat color correctly if he guesses randomly.

3. **Optimal Strategy:**
   - The wise men can discuss a strategy beforehand.
   - A possible strategy is for each wise man to guess based on the sum of the hat colors he sees.

4. **Detailed Strategy:**
   - Let’s denote the hat colors as binary values: 0 for white and 1 for black.
   - Each wise man can see the hats of the other \( n-1 \) wise men.
   - They can agree on a strategy where each wise man guesses that the sum of all the hats (including his own) is 0 modulo 2 (i.e., even).

5. **Mathematical Formulation:**
   - Let \( h_i \) be the hat color of the \( i \)-th wise man.
   - Each wise man \( i \) sees the sum \( \sum_{j \neq i} h_j \).
   - The strategy is for each wise man to guess that \( h_i = \sum_{j \neq i} h_j \mod 2 \).

6. **Correctness of the Strategy:**
   - If the total sum of all hats \( \sum_{i=1}^n h_i \) is 0 modulo 2, then each wise man’s guess will be correct.
   - This is because \( h_i = \sum_{j \neq i} h_j \mod 2 \) implies \( \sum_{i=1}^n h_i = 0 \mod 2 \).

7. **Counting the Successful Layouts:**
   - The total sum \( \sum_{i=1}^n h_i \) can be either 0 or 1 modulo 2.
   - There are \( 2^{n-1} \) layouts where the sum is 0 modulo 2 (even number of 1s).
   - There are \( 2^{n-1} \) layouts where the sum is 1 modulo 2 (odd number of 1s).

8. **Conclusion:**
   - The number of layouts for which everyone guesses correctly is \( 2^{n-1} \).

The final answer is \( \boxed{ 2^{n-1} } \).