Demonstration software

Click the link below to download the demo program:
Prisoners and Hats Demo

The program can be executed by the following command from command prompt:

java -jar pah.jar

It will give you the opportunity to distribute hat colors over prisoners A to D. After which the program will show what the prisoners know during certain stages of the puzzle.

An example execution is show below:

Prison: C-> B-> A-> |wall| <-D
The arrows represent the viewing direction of the prisoners
What color of hat is A wearing? (case sensitive)
>>orange
What color of hat is B wearing?
>>purple
What color of hat is C wearing?
>>orange
What color of hat is D wearing?
>>purple
Prison hats distributed, press return to start.
>>
Prisoner A keeps quiet because he is not yet sure about his hat color.
Prisoner B keeps quiet because he is not yet sure about his hat color.
Prisoner C keeps quiet because he is not yet sure about his hat color.
Prisoner D keeps quiet because he is not yet sure about his hat color.
Press return to continue.
>>
Prisoner A keeps quiet because he is not yet sure about his hat color.
I, prisoner B know that my hat has the color purple
Prisoner C keeps quiet because he is not yet sure about his hat color.
Prisoner D keeps quiet because he is not yet sure about his hat color.
Press return to continue.
>>
The prisoners have already left the jail

The user of the program is completely free in what color hats he distributes, it would also be possible to for example distribute four hats of the same color. The prisoners will reason about any situation you throw at them (they only won't always be able to make it out alive.)

Click here to download the source code of the program.