Werewolves II

Run LPL Code  ,  PDF Document

Problem

This problem is related to wolves.


Listing 1: The Complete Model implemented in LPL [2]
model wolves1 "Werewolves II"; 
  set p := [A B C] "Persons"; 
  binary variable x{p}; y{p}; 
  constraint 
    A: xor{p} y; 
    B{p}: y -> x  "The werewolf is a knight"; 
    Asays: x[1] <-> or{p} ~x "At least one is a knave, says A"; 
    Bsays: x[2] = x[3] "B says: C is a knight"; 
  minimize any: y[1]; 
  Write{p}('%s is a %5s\n', p, if (x,'knight','knave')); 
  Write{p|y}('%s is a werewolf\n', p); 
end

References

[1]   MatMod. Homepage for Learning Mathematical Modeling :  https://matmod.ch.

[2]   Hürlimann T. Reference Manual for the LPL Modeling Language, most recent version. https://matmod.ch/lpl/doc/manual.pdf.