Hat Puzzle Game

Rule:

Choose Prisoner:

You 2nd Prisoner 3rd Prisoner 4th Prisoner 5th Prisoner 6th Prisoner 7th Prisoner
Black White Guess Black White Guess Black White Guess Black White Guess Black White Guess Black White Guess Black White Guess

Your Guess:


1st Prisoner 2nd Prisoner 3rd Prisoner 4th Prisoner 5th Prisoner 6th Prisoner 7th Prisoner
Guessed Color ? ? ? ? ? ? ?

Correct Guesses: ?


Wrong Guesses: ?


Start Again


There are 7 prisoners lining up in a queue.

Each of them is assigned a hat, black or white, randomly where each can see the hats in front of him but not behind.

Starting from the prisoner in the back, each of them says the word "black" or "white".

If 6 or more words match the hat colors of the prisoners who say it, all 7 prisoners are released.
If 2 or more words do not match the hat colors, they will all be killed.

Is there a way to guarantee their release?
Images from clipart-library.com, betterlesson.com