Hi danimal, and welcome to Brainden.
Not to call you out, but either you didn't read and understand the posts in this thread, or you're looking for an excuse [saying the puzzle is flawed] for not coming up with a solution to a challenging riddle.
Here's why I say that ...
[1] The problem never states what ratio of black hats to red hats there are or will be.
Distribution is not implied, and it's not relevant.
[2] Bonanova's solution won't work if ... [there are certain color distributions].
Distribution is not implied, and it's not relevant. You probably didn't understand the riddle.
[3] The prisoner at the end and moving up the line will have a look at a larger sample size of the hats and might figure out that black and red hats are not distributed evenly, but as you get to the middle of the line, it becomes a wash and the prisoners don't see enough hats in front of them to make an informed decision.
This simply makes no sense in the context of the riddle:
Sample size is irrelevant. Distribution is irrelevant. Seeing "enough hats" is irrelevant. [4] The problem also does not state whether each prisoner will be able to hear their fellow prisoner's answer as to red or black or know the outcome of their answer; if they got it right and they get to live or die. Since they are all facing forward, and the King starts at the back of the line, no one is allowed to look back and see what happens. If the prisoners' answers and outcome are unknown to everyone else, it makes the decisions more of just a random guess.
Can they hear? - Where does it say they are deaf?
Do they know the outcome? - They don't need to.
No one is allowed to look back. They don't need to.
The decisions become a random guess. - Nope. Nineteen go free, guaranteed.
[5] A lot of flaws to the original problem.
It's challenging - perhaps both to understand and to solve - but not flawed.